Documentation
¶
Index ¶
- Constants
- Variables
- type Card
- type CardCombo
- type Poker
- func (p *Poker) AppendLaizi(data []int64)
- func (p *Poker) AutoLaizi(num int64)
- func (p *Poker) CardBinarySearch(cards []*Card, target int64) *Card
- func (p *Poker) CardToNum(cards interface{}) []int64
- func (p *Poker) CardsAssignPop(num []int64) bool
- func (p *Poker) CardsAssignValuePop(num []int64) ([]*Card, bool)
- func (p *Poker) CardsGetByValue(v int64) []*Card
- func (p *Poker) CardsPop(num int64) []*Card
- func (p *Poker) CompareFeature(curFeature, lastFeature int64) int64
- func (p *Poker) ContainLaizi(cards interface{}) int64
- func (p *Poker) DecodeFeature(feature int64) (int64, int, int64, int64)
- func (p *Poker) Disrupt(nums []*Card)
- func (p *Poker) EncodeFeature(cardType int64, section int, cardValue int64, fix int64) int64
- func (p *Poker) GetCards(cards []*Card, target int64, num int) []*Card
- func (p *Poker) GetCardsFeature(nCards []int64, comboType int64) int64
- func (p *Poker) GetCardsForLaizi(cards []*Card, target int64) []*Card
- func (p *Poker) GetLaizi() []int64
- func (p *Poker) GetMaxNoJoker(cards []*Card) int64
- func (p *Poker) GetMinBomb(cards []*Card, feature int64, isJoker bool) *cardCombo
- func (p *Poker) GetMinFourWithTwoPair(cards []*Card, feature int64, bomb, divide, laizi bool) *cardCombo
- func (p *Poker) GetMinFourWithTwoSingle(cards []*Card, feature int64, bomb, divide, laizi bool) *cardCombo
- func (p *Poker) GetMinLaizi(cards []*Card, num int64) []*Card
- func (p *Poker) GetMinOnePair(cards []*Card, feature int64, bomb, divide, laizi bool) *cardCombo
- func (p *Poker) GetMinPairStraight(cards []*Card, feature int64, bomb, divide, laizi bool) *cardCombo
- func (p *Poker) GetMinSingle(cards []*Card, feature int64, bomb, divide, laizi bool) *cardCombo
- func (p *Poker) GetMinSingleStraight(cards []*Card, feature int64, bomb, divide, laizi bool) *cardCombo
- func (p *Poker) GetMinTrio(cards []*Card, feature int64, bomb, divide, laizi bool) *cardCombo
- func (p *Poker) GetMinTrioStraight(cards []*Card, feature int64, bomb, divide, laizi bool) *cardCombo
- func (p *Poker) GetMinTrioStraightWithPair(cards []*Card, feature int64, bomb, divide, laizi bool) *cardCombo
- func (p *Poker) GetMinTrioStraightWithSingle(cards []*Card, feature int64, bomb, divide, laizi bool) *cardCombo
- func (p *Poker) GetMinTrioWithPair(cards []*Card, feature int64, bomb, divide, laizi bool) *cardCombo
- func (p *Poker) GetMinTrioWithSingle(cards []*Card, feature int64, bomb, divide, laizi bool) *cardCombo
- func (p *Poker) HaveJoker(cards []*Card) bool
- func (p *Poker) HintCardCombo(numCards []int64, feature int64) *CardCombo
- func (p *Poker) IsLaizi(card int64) bool
- func (p *Poker) IsUse(cards []*Card) bool
- func (p *Poker) NumToCard(num interface{}) []*Card
- func (p *Poker) RandomGet(nums []*Card, n int) []*Card
- func (p *Poker) RandomGetDifferent(nums []*Card, n int) []*Card
- func (p *Poker) SetLaizi(data []int64)
- func (p *Poker) ShuffleProbability(data [][3]int64)
- func (p *Poker) ShuffleRandom()
- func (p *Poker) SortCards(cards []*Card)
- func (p *Poker) StorageBaseCards(baseCards []int64)
- func (p *Poker) UnUse(cards []*Card)
- func (p *Poker) Use(cards []*Card, target []*Card)
Constants ¶
const ( Single int64 = 1 // 单张 OnePair int64 = 2 // 对子 Trio int64 = 3 // 三张 TrioWithSingle int64 = 4 // 三带单 TrioWithPair int64 = 5 // 三张带对子 FourWithTwoSingle int64 = 8 // 四带两张单 FourWithTwoPair int64 = 9 // 四带两对 SingleStraight int64 = 21 // 单顺 PairStraight int64 = 22 // 连对 TrioStraight int64 = 23 // 飞机(不带牌) TrioStraightWithSingle int64 = 24 // 飞机带单张 TrioStraightWithPair int64 = 25 // 飞机带对子 Bomb int64 = 41 // 炸弹 JokePair int64 = 51 // 王炸 )
Variables ¶
var Cards = []int64{31, 32, 33, 34, 41, 42, 43, 44, 51, 52, 53, 54, 61, 62, 63, 64, 71, 72, 73, 74, 81, 82, 83, 84,
91, 92, 93, 94, 101, 102, 103, 104, 111, 112, 113, 114, 121, 122, 123, 124, 131, 132, 133, 134, 141, 142, 143, 144,
151, 152, 153, 154, 160, 170}
Functions ¶
This section is empty.
Types ¶
type Card ¶
type Card struct { Type int64 // 牌的类型, 1:方块♦,2:梅花♣,3:红桃♥,4:黑桃♠,5:小王🃏,6:大王🃏 Value int64 // 牌的值 小王:160,大王:170 IsLaizi bool // 是否癞子牌 IsUse bool // 是否已经使用,复合牌型需要判断牌是否被使用 }
Card 扑克牌对象,牌值 121 方块 Q -> 牌对象(类型 1, 值 12) 支持单张或多张
type Poker ¶
type Poker struct {
// contains filtered or unexported fields
}
func NewPokerAlgorithm ¶
func NewPokerAlgorithm() *Poker
func (*Poker) AppendLaizi ¶
func (*Poker) CardBinarySearch ¶
CardBinarySearch cards的二分查找
func (*Poker) CardToNum ¶
CardToNum 扑克牌对象转换为数字表示方式的值 cards: 扑克牌对象。可以是单个卡牌对象,也可以是卡牌类型的切片 []*Card return: 扑克牌对象数字表示方式的值,因为可以有多个输入值,所以返回的是一个数组
func (*Poker) CardsAssignValuePop ¶
pop指定类型
func (*Poker) CardsGetByValue ¶
func (*Poker) CompareFeature ¶
CompareFeature 比较特征值 curFeature: 要使用牌型组合的特征值 lastFeature: 要对比的特征值 return: 大 (可以出牌) = 1;小 (不能出牌)=-1;牌型不符 = 0
func (*Poker) DecodeFeature ¶
DecodeFeature 解析特征值 feature: 特征值 return: 1: 卡牌组合类型;2: 节数;3: 牌值;4:癞子牌
func (*Poker) EncodeFeature ¶
EncodeFeature 计算特征值 cardType:卡牌组合类型 section: 节数 cardValue: 牌值 fix: 1:带有癞子牌,3:纯癞子,4:默认没有癞子牌
func (*Poker) GetCardsFeature ¶
GetCardsFeature 获取牌型特征值 nCards: 计算牌型的卡牌数据 comboType: 牌的类型 return: 牌型特征值
func (*Poker) GetCardsForLaizi ¶
GetCards 获取n张癞子牌
func (*Poker) GetMaxNoJoker ¶
func (*Poker) GetMinBomb ¶
GetMinBomb 获取最小的炸弹
func (*Poker) GetMinFourWithTwoPair ¶
func (p *Poker) GetMinFourWithTwoPair(cards []*Card, feature int64, bomb, divide, laizi bool) *cardCombo
GetMinFourWithTwoPair 四带两对 cards: 卡牌数据 feature: 调用传入的特征值 bomb:是否使用炸弹,divide:是否拆牌,laizi:是否使用癞子
func (*Poker) GetMinFourWithTwoSingle ¶
func (p *Poker) GetMinFourWithTwoSingle(cards []*Card, feature int64, bomb, divide, laizi bool) *cardCombo
GetMinFourWithTwoSingle 四带单 cards: 卡牌数据 feature: 调用传入的特征值 bomb:是否使用炸弹,divide:是否拆牌,laizi:是否使用癞子
func (*Poker) GetMinLaizi ¶
GetMinLaizi 获取最小的癞子
func (*Poker) GetMinOnePair ¶
GetMinOnePair 获取对子 cards: 卡牌数据 feature: 调用传入的特征值 bomb:是否使用炸弹,divide:是否拆牌,laizi:是否使用癞子
func (*Poker) GetMinPairStraight ¶
func (p *Poker) GetMinPairStraight(cards []*Card, feature int64, bomb, divide, laizi bool) *cardCombo
GetMinPairStraight 获取连对 cards: 卡牌数据 feature: 调用传入的特征值 bomb:是否使用炸弹,divide:是否拆牌,laizi:是否使用癞子
func (*Poker) GetMinSingle ¶
GetMinSingle 获取单张牌型,优先给出最多只有一张的牌 单张顺序:硬单张、拆一对的硬单张、拆三条的硬单张、硬炸,拆同一硬炸的硬单张、再硬炸,拆同一硬炸的硬单张,
func (*Poker) GetMinSingleStraight ¶
func (p *Poker) GetMinSingleStraight(cards []*Card, feature int64, bomb, divide, laizi bool) *cardCombo
GetMinSingleStraight 获取单顺 cards: 卡牌数据 feature: 调用传入的特征值 bomb:是否使用炸弹,divide:是否拆牌,laizi:是否使用癞子
func (*Poker) GetMinTrio ¶
GetMinTrio 获取三张组合 cards: 卡牌数据 feature: 调用传入的特征值 bomb:是否使用炸弹,divide:是否拆牌,laizi:是否使用癞子
func (*Poker) GetMinTrioStraight ¶
func (p *Poker) GetMinTrioStraight(cards []*Card, feature int64, bomb, divide, laizi bool) *cardCombo
GetMinTrioStraight 飞机不带 cards: 卡牌数据 feature: 调用传入的特征值 bomb:是否使用炸弹,divide:是否拆牌,laizi:是否使用癞子
func (*Poker) GetMinTrioStraightWithPair ¶
func (p *Poker) GetMinTrioStraightWithPair(cards []*Card, feature int64, bomb, divide, laizi bool) *cardCombo
GetMinTrioStraightWithPair 飞机带对子 cards: 卡牌数据 feature: 调用传入的特征值 bomb:是否使用炸弹,divide:是否拆牌,laizi:是否使用癞子
func (*Poker) GetMinTrioStraightWithSingle ¶
func (p *Poker) GetMinTrioStraightWithSingle(cards []*Card, feature int64, bomb, divide, laizi bool) *cardCombo
GetMinTrioStraightWithSingle 飞机带单牌 cards: 卡牌数据 feature: 调用传入的特征值 bomb:是否使用炸弹,divide:是否拆牌,laizi:是否使用癞子
func (*Poker) GetMinTrioWithPair ¶
func (p *Poker) GetMinTrioWithPair(cards []*Card, feature int64, bomb, divide, laizi bool) *cardCombo
GetMinTrioWithPair 获取三带两张组合 cards: 卡牌数据 feature: 调用传入的特征值 bomb:是否使用炸弹,divide:是否拆牌,laizi:是否使用癞子
func (*Poker) GetMinTrioWithSingle ¶
func (p *Poker) GetMinTrioWithSingle(cards []*Card, feature int64, bomb, divide, laizi bool) *cardCombo
GetMinTrioWithSingle 获取三张带单组合 cards: 卡牌数据 feature: 调用传入的特征值 bomb:是否使用炸弹,divide:是否拆牌,laizi:是否使用癞子
func (*Poker) HintCardCombo ¶
HintCardCombo 返回传入的牌中所有可用的牌型组合 numCards: 传入的牌的值 feature: 需要对比的牌的特征值。如果为 0 则表示所有的牌型都可以使用。
func (*Poker) RandomGetDifferent ¶
从牌组中随机几张不相同的牌
func (*Poker) ShuffleProbability ¶
通过配置牌型出现概率来洗牌 data:牌型出现的概率, 0:牌型,1:出现的概率,2:出现的数量 userNum:游戏人数 handNum:手牌数量
func (*Poker) ShuffleRandom ¶
func (p *Poker) ShuffleRandom()