企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
- [棋牌项目](https://github.com/dwg255/landlord.git) > # 牌的编码 - 0~12 方块 A234567890JQK - 13~25 梅花 A234567890JQK - 26~38 红桃 A234567890JQK - 39~51 黑桃 A234567890JQK - 52 小王 53 大王 **黑桃>红桃>梅花>方块** ~~~ func ToPoker(card byte) (poker []int) { if card == 'W' { return []int{52} } if card == 'w' { return []int{53} } cards := "A234567890JQK" for i, c := range []byte(cards) { if c == card { return []int{i, i + 13, i + 13*2, i + 13*3} } } return []int{54} } ~~~ - 牌和编码 ~~~ //将牌转换为编号 func ToPoker(card byte) (poker []int) { if card == 'W' { return []int{52} } if card == 'w' { return []int{53} } cards := "A234567890JQK" for i, c := range []byte(cards) { if c == card { return []int{i, i + 13, i + 13*2, i + 13*3} } } return []int{54} } //将机器人要出的牌转换为编号 func pokersInHand(num []int, findPokers string) (pokers []int) { var isInResPokers = func(poker int) bool { for _, p := range pokers { if p == poker { return true } } return false } for _, poker := range findPokers { poker := ToPoker(byte(poker)) out: for _,pItem := range poker { for _, n := range num { if pItem == n && !isInResPokers(n) { pokers = append(pokers, pItem) break out } } } } return } ~~~