ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的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 } ~~~