Refactor code, added new checkXu test cases(9 latterns)

This commit is contained in:
2024-04-12 23:45:45 +00:00
parent e341a048fc
commit 4b10dbb65d
11 changed files with 212 additions and 176 deletions
+90 -90
View File
@@ -2,108 +2,108 @@ package main
import ( import (
"fmt" "fmt"
pkg "mjhelper/pkg" pattern "mjhelper/pkg/pattern"
"github.com/mowshon/iterium" "github.com/mowshon/iterium"
) )
func allFans() []pkg.Fan { func allFans() []pattern.Fan {
testFans := []pkg.Fan{ testFans := []pattern.Fan{
{Id: 1, Name: "大四喜", Pattern: pkg.PatternDivision{Ke: 4, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{38, 49, 62, 63}, Value: 88}, {Id: 1, Name: "大四喜", Pattern: pattern.PatternDivision{Ke: 4, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{38, 49, 62, 63}, Value: 88},
{Id: 2, Name: "大三元", Pattern: pkg.PatternDivision{Ke: 3, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 88}, {Id: 2, Name: "大三元", Pattern: pattern.PatternDivision{Ke: 3, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 88},
{Id: 3, Name: "绿一色", Pattern: pkg.PatternDivision{Ke: 4, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 88}, {Id: 3, Name: "绿一色", Pattern: pattern.PatternDivision{Ke: 4, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 88},
{Id: 4, Name: "九莲宝灯", Pattern: pkg.PatternDivision{Ke: 2, Shun: 0, Dui: 0, Gang: 0}, ExcludeIds: []int{}, Value: 88}, {Id: 4, Name: "九莲宝灯", Pattern: pattern.PatternDivision{Ke: 2, Shun: 0, Dui: 0, Gang: 0}, ExcludeIds: []int{}, Value: 88},
{Id: 5, Name: "四杠", Pattern: pkg.PatternDivision{Ke: 4, Shun: 0, Dui: 1, Gang: 4}, ExcludeIds: []int{}, Value: 88}, {Id: 5, Name: "四杠", Pattern: pattern.PatternDivision{Ke: 4, Shun: 0, Dui: 1, Gang: 4}, ExcludeIds: []int{}, Value: 88},
{Id: 6, Name: "连七对", Pattern: pkg.PatternDivision{Ke: 0, Shun: 0, Dui: 7, Gang: 0}, ExcludeIds: []int{}, Value: 88}, {Id: 6, Name: "连七对", Pattern: pattern.PatternDivision{Ke: 0, Shun: 0, Dui: 7, Gang: 0}, ExcludeIds: []int{}, Value: 88},
{Id: 7, Name: "十三幺", Pattern: pkg.PatternDivision{Ke: 0, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 88}, {Id: 7, Name: "十三幺", Pattern: pattern.PatternDivision{Ke: 0, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 88},
{Id: 8, Name: "清幺九", Pattern: pkg.PatternDivision{Ke: 4, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 64}, {Id: 8, Name: "清幺九", Pattern: pattern.PatternDivision{Ke: 4, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 64},
{Id: 9, Name: "小四喜", Pattern: pkg.PatternDivision{Ke: 3, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 64}, {Id: 9, Name: "小四喜", Pattern: pattern.PatternDivision{Ke: 3, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 64},
{Id: 10, Name: "小三元", Pattern: pkg.PatternDivision{Ke: 2, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 64}, {Id: 10, Name: "小三元", Pattern: pattern.PatternDivision{Ke: 2, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 64},
{Id: 11, Name: "字一色", Pattern: pkg.PatternDivision{Ke: 4, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 64}, {Id: 11, Name: "字一色", Pattern: pattern.PatternDivision{Ke: 4, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 64},
{Id: 12, Name: "四暗刻", Pattern: pkg.PatternDivision{Ke: 4, Shun: 0, Dui: 2, Gang: 0}, ExcludeIds: []int{}, Value: 64}, {Id: 12, Name: "四暗刻", Pattern: pattern.PatternDivision{Ke: 4, Shun: 0, Dui: 2, Gang: 0}, ExcludeIds: []int{}, Value: 64},
{Id: 13, Name: "一色双龙会", Pattern: pkg.PatternDivision{Ke: 0, Shun: 4, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 64}, {Id: 13, Name: "一色双龙会", Pattern: pattern.PatternDivision{Ke: 0, Shun: 4, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 64},
{Id: 14, Name: "一色四同顺", Pattern: pkg.PatternDivision{Ke: 0, Shun: 4, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 48}, {Id: 14, Name: "一色四同顺", Pattern: pattern.PatternDivision{Ke: 0, Shun: 4, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 48},
{Id: 15, Name: "一色四节高", Pattern: pkg.PatternDivision{Ke: 4, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 48}, {Id: 15, Name: "一色四节高", Pattern: pattern.PatternDivision{Ke: 4, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 48},
{Id: 16, Name: "一色四步高", Pattern: pkg.PatternDivision{Ke: 0, Shun: 4, Dui: 2, Gang: 0}, ExcludeIds: []int{}, Value: 32}, {Id: 16, Name: "一色四步高", Pattern: pattern.PatternDivision{Ke: 0, Shun: 4, Dui: 2, Gang: 0}, ExcludeIds: []int{}, Value: 32},
{Id: 17, Name: "三杠", Pattern: pkg.PatternDivision{Ke: 3, Shun: 0, Dui: 1, Gang: 3}, ExcludeIds: []int{}, Value: 32}, {Id: 17, Name: "三杠", Pattern: pattern.PatternDivision{Ke: 3, Shun: 0, Dui: 1, Gang: 3}, ExcludeIds: []int{}, Value: 32},
{Id: 18, Name: "混幺九", Pattern: pkg.PatternDivision{Ke: 4, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 32}, {Id: 18, Name: "混幺九", Pattern: pattern.PatternDivision{Ke: 4, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 32},
{Id: 19, Name: "七对", Pattern: pkg.PatternDivision{Ke: 0, Shun: 0, Dui: 7, Gang: 0}, ExcludeIds: []int{}, Value: 24}, {Id: 19, Name: "七对", Pattern: pattern.PatternDivision{Ke: 0, Shun: 0, Dui: 7, Gang: 0}, ExcludeIds: []int{}, Value: 24},
{Id: 20, Name: "七星不靠", Pattern: pkg.PatternDivision{Ke: 0, Shun: 0, Dui: 0, Gang: 0}, ExcludeIds: []int{}, Value: 24}, {Id: 20, Name: "七星不靠", Pattern: pattern.PatternDivision{Ke: 0, Shun: 0, Dui: 0, Gang: 0}, ExcludeIds: []int{}, Value: 24},
{Id: 21, Name: "全双刻", Pattern: pkg.PatternDivision{Ke: 4, Shun: 0, Dui: 2, Gang: 0}, ExcludeIds: []int{}, Value: 24}, {Id: 21, Name: "全双刻", Pattern: pattern.PatternDivision{Ke: 4, Shun: 0, Dui: 2, Gang: 0}, ExcludeIds: []int{}, Value: 24},
{Id: 22, Name: "清一色", Pattern: pkg.PatternDivision{Ke: 0, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 24}, {Id: 22, Name: "清一色", Pattern: pattern.PatternDivision{Ke: 0, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 24},
{Id: 23, Name: "一色三同顺", Pattern: pkg.PatternDivision{Ke: 0, Shun: 3, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 24}, {Id: 23, Name: "一色三同顺", Pattern: pattern.PatternDivision{Ke: 0, Shun: 3, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 24},
{Id: 24, Name: "一色三节高", Pattern: pkg.PatternDivision{Ke: 3, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 24}, {Id: 24, Name: "一色三节高", Pattern: pattern.PatternDivision{Ke: 3, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 24},
{Id: 25, Name: "全大", Pattern: pkg.PatternDivision{Ke: 0, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 24}, {Id: 25, Name: "全大", Pattern: pattern.PatternDivision{Ke: 0, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 24},
{Id: 26, Name: "全中", Pattern: pkg.PatternDivision{Ke: 0, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 24}, {Id: 26, Name: "全中", Pattern: pattern.PatternDivision{Ke: 0, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 24},
{Id: 27, Name: "全小", Pattern: pkg.PatternDivision{Ke: 0, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 24}, {Id: 27, Name: "全小", Pattern: pattern.PatternDivision{Ke: 0, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 24},
{Id: 28, Name: "清龙", Pattern: pkg.PatternDivision{Ke: 3, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 16}, {Id: 28, Name: "清龙", Pattern: pattern.PatternDivision{Ke: 3, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 16},
{Id: 29, Name: "三色双龙会", Pattern: pkg.PatternDivision{Ke: 4, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 16}, {Id: 29, Name: "三色双龙会", Pattern: pattern.PatternDivision{Ke: 4, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 16},
{Id: 30, Name: "一色三步高", Pattern: pkg.PatternDivision{Ke: 3, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 16}, {Id: 30, Name: "一色三步高", Pattern: pattern.PatternDivision{Ke: 3, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 16},
{Id: 31, Name: "全带五", Pattern: pkg.PatternDivision{Ke: 0, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 16}, {Id: 31, Name: "全带五", Pattern: pattern.PatternDivision{Ke: 0, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 16},
{Id: 32, Name: "三同刻", Pattern: pkg.PatternDivision{Ke: 3, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 16}, {Id: 32, Name: "三同刻", Pattern: pattern.PatternDivision{Ke: 3, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 16},
{Id: 33, Name: "三暗刻", Pattern: pkg.PatternDivision{Ke: 3, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 16}, {Id: 33, Name: "三暗刻", Pattern: pattern.PatternDivision{Ke: 3, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 16},
{Id: 34, Name: "全不靠", Pattern: pkg.PatternDivision{Ke: 0, Shun: 0, Dui: 0, Gang: 0}, ExcludeIds: []int{}, Value: 12}, {Id: 34, Name: "全不靠", Pattern: pattern.PatternDivision{Ke: 0, Shun: 0, Dui: 0, Gang: 0}, ExcludeIds: []int{}, Value: 12},
{Id: 35, Name: "组合龙", Pattern: pkg.PatternDivision{Ke: 0, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 12}, {Id: 35, Name: "组合龙", Pattern: pattern.PatternDivision{Ke: 0, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 12},
{Id: 36, Name: "大于五", Pattern: pkg.PatternDivision{Ke: 0, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 12}, {Id: 36, Name: "大于五", Pattern: pattern.PatternDivision{Ke: 0, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 12},
{Id: 37, Name: "小于五", Pattern: pkg.PatternDivision{Ke: 0, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 12}, {Id: 37, Name: "小于五", Pattern: pattern.PatternDivision{Ke: 0, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 12},
{Id: 38, Name: "三风刻", Pattern: pkg.PatternDivision{Ke: 3, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 12}, {Id: 38, Name: "三风刻", Pattern: pattern.PatternDivision{Ke: 3, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 12},
{Id: 39, Name: "花龙", Pattern: pkg.PatternDivision{Ke: 3, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 8}, {Id: 39, Name: "花龙", Pattern: pattern.PatternDivision{Ke: 3, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 8},
{Id: 40, Name: "推不倒", Pattern: pkg.PatternDivision{Ke: 0, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 8}, {Id: 40, Name: "推不倒", Pattern: pattern.PatternDivision{Ke: 0, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 8},
{Id: 41, Name: "三色三同顺", Pattern: pkg.PatternDivision{Ke: 0, Shun: 3, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 8}, {Id: 41, Name: "三色三同顺", Pattern: pattern.PatternDivision{Ke: 0, Shun: 3, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 8},
{Id: 42, Name: "三色三节高", Pattern: pkg.PatternDivision{Ke: 3, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 8}, {Id: 42, Name: "三色三节高", Pattern: pattern.PatternDivision{Ke: 3, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 8},
{Id: 43, Name: "无番和", Pattern: pkg.PatternDivision{Ke: 0, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 8}, {Id: 43, Name: "无番和", Pattern: pattern.PatternDivision{Ke: 0, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 8},
{Id: 44, Name: "妙手回春", Pattern: pkg.PatternDivision{Ke: 0, Shun: 0, Dui: 0, Gang: 0}, ExcludeIds: []int{}, Value: 8}, {Id: 44, Name: "妙手回春", Pattern: pattern.PatternDivision{Ke: 0, Shun: 0, Dui: 0, Gang: 0}, ExcludeIds: []int{}, Value: 8},
{Id: 45, Name: "海底捞月", Pattern: pkg.PatternDivision{Ke: 0, Shun: 0, Dui: 0, Gang: 0}, ExcludeIds: []int{}, Value: 8}, {Id: 45, Name: "海底捞月", Pattern: pattern.PatternDivision{Ke: 0, Shun: 0, Dui: 0, Gang: 0}, ExcludeIds: []int{}, Value: 8},
{Id: 46, Name: "杠上开花", Pattern: pkg.PatternDivision{Ke: 0, Shun: 0, Dui: 0, Gang: 1}, ExcludeIds: []int{}, Value: 8}, {Id: 46, Name: "杠上开花", Pattern: pattern.PatternDivision{Ke: 0, Shun: 0, Dui: 0, Gang: 1}, ExcludeIds: []int{}, Value: 8},
{Id: 47, Name: "抢杠和", Pattern: pkg.PatternDivision{Ke: 0, Shun: 0, Dui: 0, Gang: 0}, ExcludeIds: []int{}, Value: 8}, {Id: 47, Name: "抢杠和", Pattern: pattern.PatternDivision{Ke: 0, Shun: 0, Dui: 0, Gang: 0}, ExcludeIds: []int{}, Value: 8},
// 双暗杠 98版计6番,06版计8番 // 双暗杠 98版计6番,06版计8番
{Id: 48, Name: "双暗杠", Pattern: pkg.PatternDivision{Ke: 3, Shun: 0, Dui: 1, Gang: 2}, ExcludeIds: []int{}, Value: 6}, {Id: 48, Name: "双暗杠", Pattern: pattern.PatternDivision{Ke: 3, Shun: 0, Dui: 1, Gang: 2}, ExcludeIds: []int{}, Value: 6},
{Id: 49, Name: "碰碰和", Pattern: pkg.PatternDivision{Ke: 4, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 6}, {Id: 49, Name: "碰碰和", Pattern: pattern.PatternDivision{Ke: 4, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 6},
{Id: 50, Name: "混一色", Pattern: pkg.PatternDivision{Ke: 0, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 6}, {Id: 50, Name: "混一色", Pattern: pattern.PatternDivision{Ke: 0, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 6},
{Id: 51, Name: "三色三步高", Pattern: pkg.PatternDivision{Ke: 0, Shun: 3, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 6}, {Id: 51, Name: "三色三步高", Pattern: pattern.PatternDivision{Ke: 0, Shun: 3, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 6},
{Id: 52, Name: "三色三节高", Pattern: pkg.PatternDivision{Ke: 3, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 6}, {Id: 52, Name: "三色三节高", Pattern: pattern.PatternDivision{Ke: 3, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 6},
{Id: 53, Name: "五门齐", Pattern: pkg.PatternDivision{Ke: 0, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 6}, {Id: 53, Name: "五门齐", Pattern: pattern.PatternDivision{Ke: 0, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 6},
{Id: 54, Name: "全求人", Pattern: pkg.PatternDivision{Ke: 0, Shun: 0, Dui: 0, Gang: 0}, ExcludeIds: []int{}, Value: 6}, {Id: 54, Name: "全求人", Pattern: pattern.PatternDivision{Ke: 0, Shun: 0, Dui: 0, Gang: 0}, ExcludeIds: []int{}, Value: 6},
// 明暗杠 06版计6番,存疑 // 明暗杠 06版计6番,存疑
{Id: 55, Name: "明暗杠", Pattern: pkg.PatternDivision{Ke: 0, Shun: 0, Dui: 0, Gang: 0}, ExcludeIds: []int{}, Value: 6}, {Id: 55, Name: "明暗杠", Pattern: pattern.PatternDivision{Ke: 0, Shun: 0, Dui: 0, Gang: 0}, ExcludeIds: []int{}, Value: 6},
{Id: 56, Name: "双箭刻", Pattern: pkg.PatternDivision{Ke: 2, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 6}, {Id: 56, Name: "双箭刻", Pattern: pattern.PatternDivision{Ke: 2, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 6},
{Id: 57, Name: "全带幺", Pattern: pkg.PatternDivision{Ke: 0, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 4}, {Id: 57, Name: "全带幺", Pattern: pattern.PatternDivision{Ke: 0, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 4},
{Id: 58, Name: "不求人", Pattern: pkg.PatternDivision{Ke: 0, Shun: 0, Dui: 0, Gang: 0}, ExcludeIds: []int{}, Value: 4}, {Id: 58, Name: "不求人", Pattern: pattern.PatternDivision{Ke: 0, Shun: 0, Dui: 0, Gang: 0}, ExcludeIds: []int{}, Value: 4},
{Id: 59, Name: "双明杠", Pattern: pkg.PatternDivision{Ke: 2, Shun: 0, Dui: 1, Gang: 2}, ExcludeIds: []int{}, Value: 4}, {Id: 59, Name: "双明杠", Pattern: pattern.PatternDivision{Ke: 2, Shun: 0, Dui: 1, Gang: 2}, ExcludeIds: []int{}, Value: 4},
{Id: 60, Name: "和绝张", Pattern: pkg.PatternDivision{Ke: 0, Shun: 0, Dui: 0, Gang: 0}, ExcludeIds: []int{}, Value: 4}, {Id: 60, Name: "和绝张", Pattern: pattern.PatternDivision{Ke: 0, Shun: 0, Dui: 0, Gang: 0}, ExcludeIds: []int{}, Value: 4},
{Id: 61, Name: "箭刻", Pattern: pkg.PatternDivision{Ke: 1, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 2}, {Id: 61, Name: "箭刻", Pattern: pattern.PatternDivision{Ke: 1, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 2},
{Id: 62, Name: "圈风刻", Pattern: pkg.PatternDivision{Ke: 1, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 2}, {Id: 62, Name: "圈风刻", Pattern: pattern.PatternDivision{Ke: 1, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 2},
{Id: 63, Name: "门风刻", Pattern: pkg.PatternDivision{Ke: 1, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 2}, {Id: 63, Name: "门风刻", Pattern: pattern.PatternDivision{Ke: 1, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 2},
{Id: 64, Name: "门前清", Pattern: pkg.PatternDivision{Ke: 0, Shun: 0, Dui: 0, Gang: 0}, ExcludeIds: []int{}, Value: 2}, {Id: 64, Name: "门前清", Pattern: pattern.PatternDivision{Ke: 0, Shun: 0, Dui: 0, Gang: 0}, ExcludeIds: []int{}, Value: 2},
{Id: 65, Name: "平和", Pattern: pkg.PatternDivision{Ke: 0, Shun: 4, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 2}, {Id: 65, Name: "平和", Pattern: pattern.PatternDivision{Ke: 0, Shun: 4, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 2},
{Id: 66, Name: "四归一", Pattern: pkg.PatternDivision{Ke: 0, Shun: 0, Dui: 0, Gang: 0}, ExcludeIds: []int{}, Value: 2}, {Id: 66, Name: "四归一", Pattern: pattern.PatternDivision{Ke: 0, Shun: 0, Dui: 0, Gang: 0}, ExcludeIds: []int{}, Value: 2},
{Id: 67, Name: "双同刻", Pattern: pkg.PatternDivision{Ke: 2, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 2}, {Id: 67, Name: "双同刻", Pattern: pattern.PatternDivision{Ke: 2, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 2},
{Id: 68, Name: "双暗刻", Pattern: pkg.PatternDivision{Ke: 2, Shun: 0, Dui: 0, Gang: 0}, ExcludeIds: []int{}, Value: 2}, {Id: 68, Name: "双暗刻", Pattern: pattern.PatternDivision{Ke: 2, Shun: 0, Dui: 0, Gang: 0}, ExcludeIds: []int{}, Value: 2},
{Id: 69, Name: "暗杠", Pattern: pkg.PatternDivision{Ke: 1, Shun: 0, Dui: 1, Gang: 1}, ExcludeIds: []int{}, Value: 2}, {Id: 69, Name: "暗杠", Pattern: pattern.PatternDivision{Ke: 1, Shun: 0, Dui: 1, Gang: 1}, ExcludeIds: []int{}, Value: 2},
{Id: 70, Name: "断幺", Pattern: pkg.PatternDivision{Ke: 0, Shun: 0, Dui: 0, Gang: 0}, ExcludeIds: []int{}, Value: 2}, {Id: 70, Name: "断幺", Pattern: pattern.PatternDivision{Ke: 0, Shun: 0, Dui: 0, Gang: 0}, ExcludeIds: []int{}, Value: 2},
{Id: 71, Name: "一般高", Pattern: pkg.PatternDivision{Ke: 0, Shun: 2, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 1}, {Id: 71, Name: "一般高", Pattern: pattern.PatternDivision{Ke: 0, Shun: 2, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 1},
{Id: 72, Name: "喜相逢", Pattern: pkg.PatternDivision{Ke: 0, Shun: 2, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 1}, {Id: 72, Name: "喜相逢", Pattern: pattern.PatternDivision{Ke: 0, Shun: 2, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 1},
{Id: 73, Name: "连六", Pattern: pkg.PatternDivision{Ke: 0, Shun: 2, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 1}, {Id: 73, Name: "连六", Pattern: pattern.PatternDivision{Ke: 0, Shun: 2, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 1},
{Id: 74, Name: "老少副", Pattern: pkg.PatternDivision{Ke: 0, Shun: 2, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 1}, {Id: 74, Name: "老少副", Pattern: pattern.PatternDivision{Ke: 0, Shun: 2, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 1},
{Id: 75, Name: "幺九刻", Pattern: pkg.PatternDivision{Ke: 1, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 1}, {Id: 75, Name: "幺九刻", Pattern: pattern.PatternDivision{Ke: 1, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 1},
{Id: 76, Name: "明杠", Pattern: pkg.PatternDivision{Ke: 1, Shun: 0, Dui: 0, Gang: 1}, ExcludeIds: []int{}, Value: 1}, {Id: 76, Name: "明杠", Pattern: pattern.PatternDivision{Ke: 1, Shun: 0, Dui: 0, Gang: 1}, ExcludeIds: []int{}, Value: 1},
{Id: 77, Name: "缺一门", Pattern: pkg.PatternDivision{Ke: 0, Shun: 0, Dui: 0, Gang: 0}, ExcludeIds: []int{}, Value: 1}, {Id: 77, Name: "缺一门", Pattern: pattern.PatternDivision{Ke: 0, Shun: 0, Dui: 0, Gang: 0}, ExcludeIds: []int{}, Value: 1},
{Id: 78, Name: "无字", Pattern: pkg.PatternDivision{Ke: 0, Shun: 0, Dui: 0, Gang: 0}, ExcludeIds: []int{}, Value: 1}, {Id: 78, Name: "无字", Pattern: pattern.PatternDivision{Ke: 0, Shun: 0, Dui: 0, Gang: 0}, ExcludeIds: []int{}, Value: 1},
{Id: 79, Name: "边张", Pattern: pkg.PatternDivision{Ke: 0, Shun: 1, Dui: 0, Gang: 0}, ExcludeIds: []int{}, Value: 1}, {Id: 79, Name: "边张", Pattern: pattern.PatternDivision{Ke: 0, Shun: 1, Dui: 0, Gang: 0}, ExcludeIds: []int{}, Value: 1},
{Id: 80, Name: "坎张", Pattern: pkg.PatternDivision{Ke: 0, Shun: 1, Dui: 0, Gang: 0}, ExcludeIds: []int{}, Value: 1}, {Id: 80, Name: "坎张", Pattern: pattern.PatternDivision{Ke: 0, Shun: 1, Dui: 0, Gang: 0}, ExcludeIds: []int{}, Value: 1},
{Id: 81, Name: "单钓将", Pattern: pkg.PatternDivision{Ke: 0, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 1}, {Id: 81, Name: "单钓将", Pattern: pattern.PatternDivision{Ke: 0, Shun: 0, Dui: 1, Gang: 0}, ExcludeIds: []int{}, Value: 1},
{Id: 82, Name: "自摸", Pattern: pkg.PatternDivision{Ke: 0, Shun: 0, Dui: 0, Gang: 0}, ExcludeIds: []int{}, Value: 1}, {Id: 82, Name: "自摸", Pattern: pattern.PatternDivision{Ke: 0, Shun: 0, Dui: 0, Gang: 0}, ExcludeIds: []int{}, Value: 1},
{Id: 82, Name: "花牌", Pattern: pkg.PatternDivision{Ke: 0, Shun: 0, Dui: 0, Gang: 0}, ExcludeIds: []int{}, Value: 1}, {Id: 82, Name: "花牌", Pattern: pattern.PatternDivision{Ke: 0, Shun: 0, Dui: 0, Gang: 0}, ExcludeIds: []int{}, Value: 1},
} }
return testFans return testFans
} }
func AllFansToFile() { func AllFansToFile() {
allFans := allFans() allFans := allFans()
pkg.FansToFile(allFans, "test.json") pattern.FansToFile(allFans, "test.json")
} }
func GenerateFan(fan pkg.Fan) { func GenerateFan(fan pattern.Fan) {
} }
@@ -144,7 +144,7 @@ func main() {
"1B", "2B", "3B", "4B", "5B", "6B", "7B", "8B", "9B", "1B", "2B", "3B", "4B", "5B", "6B", "7B", "8B", "9B",
"DO", "XI", "NA", "BE", "ZH", "FA", "BA"}, 1) "DO", "XI", "NA", "BE", "ZH", "FA", "BA"}, 1)
fmt.Println(result2_1.Count() * result2_2.Count()) fmt.Println(result2_1.Count() * result2_2.Count())
for i := range result2_1.Chan() { /*for i := range result2_1.Chan() {
fmt.Println(i) fmt.Println(i)
} }*/
} }
+3 -4
View File
@@ -2,7 +2,6 @@ module mjhelper
go 1.20 go 1.20
require ( require github.com/mowshon/iterium v1.0.0
github.com/mowshon/iterium v1.0.0 // indirect
golang.org/x/exp v0.0.0-20230307190834-24139beb5833 // indirect require golang.org/x/exp v0.0.0-20230307190834-24139beb5833 // indirect
)
+4
View File
@@ -1,4 +1,8 @@
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/mowshon/iterium v1.0.0 h1:04pku9dTNnfVvshf+DQIV3E92T/EwmnXKtXMkmZ3+5Q= github.com/mowshon/iterium v1.0.0 h1:04pku9dTNnfVvshf+DQIV3E92T/EwmnXKtXMkmZ3+5Q=
github.com/mowshon/iterium v1.0.0/go.mod h1:Bnchn9HAYNQ/7MLUwKDyvjduSuVJQQwrNxmXJDqpXg4= github.com/mowshon/iterium v1.0.0/go.mod h1:Bnchn9HAYNQ/7MLUwKDyvjduSuVJQQwrNxmXJDqpXg4=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
golang.org/x/exp v0.0.0-20230307190834-24139beb5833 h1:SChBja7BCQewoTAU7IgvucQKMIXrEpFxNMs0spT3/5s= golang.org/x/exp v0.0.0-20230307190834-24139beb5833 h1:SChBja7BCQewoTAU7IgvucQKMIXrEpFxNMs0spT3/5s=
golang.org/x/exp v0.0.0-20230307190834-24139beb5833/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= golang.org/x/exp v0.0.0-20230307190834-24139beb5833/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
+67
View File
@@ -0,0 +1,67 @@
package pkg
import (
"fmt"
"mjhelper/pkg/tiles"
)
const (
// 未出场
tl_notshow = 0
// 本家状态
tl_mhand = 1
tl_mshow = 2
tl_mdisc = 3
// 下家状态
tl_nhand = 4
tl_nshow = 5
tl_ndisc = 6
// 对家状态
tl_ohand = 7
tl_oshow = 8
tl_odisc = 9
// 上家状态
tl_phand = 10
tl_pshow = 11
tl_pdisc = 12
)
type environment struct {
board [4][34]int
}
func (e environment) Print() {
for i := 0; i < len(e.board)+1; i++ {
for j := 0; j < len(e.board[0]); j++ {
if i == 0 {
fmt.Printf("|% 3s", tiles.TileTypes[j])
} else {
fmt.Printf("|% 3d", e.board[i-1][j])
}
}
fmt.Printf("|\n")
}
}
func (e environment) PatternNormalization() [3][34]int {
var ret [3][34]int
for i := 0; i < len(e.board[0]); i++ {
hand := 0
disc := 0
noshow := 0
for j := 0; j < len(e.board); j++ {
switch e.board[j][i] {
case tl_mhand, tl_mshow:
hand += 1
case tl_mdisc, tl_ndisc, tl_nshow, tl_odisc, tl_oshow, tl_pdisc, tl_pshow:
disc += 1
case tl_notshow:
noshow += 1
}
}
ret[0][i] = hand
ret[1][i] = disc
ret[2][i] = noshow
}
return ret
}
+17
View File
@@ -0,0 +1,17 @@
package pkg
import (
"fmt"
"testing"
)
func TestPrint(t *testing.T) {
var env environment
env.Print()
}
func TestPatternNormalization(t *testing.T) {
var env environment
handTiles := env.PatternNormalization()
fmt.Println(handTiles)
}
+1 -1
View File
@@ -1,4 +1,4 @@
package pkg package pattern
import ( import (
"encoding/json" "encoding/json"
+1 -1
View File
@@ -1,4 +1,4 @@
package pkg package pattern
import ( import (
"fmt" "fmt"
+13
View File
@@ -0,0 +1,13 @@
package pattern
type pattern struct {
}
type shun struct {
}
type ke struct {
}
type jiang struct {
}
+5 -64
View File
@@ -1,4 +1,4 @@
package pkg package tiles
import ( import (
"errors" "errors"
@@ -8,80 +8,21 @@ import (
"sort" "sort"
) )
const ( var TileTypes = [34]string{
// 未出场
tl_notshow = 0
// 本家状态
tl_mhand = 1
tl_mshow = 2
tl_mdisc = 3
// 下家状态
tl_nhand = 4
tl_nshow = 5
tl_ndisc = 6
// 对家状态
tl_ohand = 7
tl_oshow = 8
tl_odisc = 9
// 上家状态
tl_phand = 10
tl_pshow = 11
tl_pdisc = 12
)
var tileTypes = [34]string{
"1W", "2W", "3W", "4W", "5W", "6W", "7W", "8W", "9W", "1W", "2W", "3W", "4W", "5W", "6W", "7W", "8W", "9W",
"1T", "2T", "3T", "4T", "5T", "6T", "7T", "8T", "9T", "1T", "2T", "3T", "4T", "5T", "6T", "7T", "8T", "9T",
"1B", "2B", "3B", "4B", "5B", "6B", "7B", "8B", "9B", "1B", "2B", "3B", "4B", "5B", "6B", "7B", "8B", "9B",
"DO", "XI", "NA", "BE", "ZH", "FA", "BA"} "DO", "XI", "NA", "BE", "ZH", "FA", "BA"}
var tileHuaTypes = [8]string{"ME", "LA", "ZU", "JU", "CH", "XA", "QI", "DN"} var tileHuaTypes = [8]string{"ME", "LA", "ZU", "JU", "CH", "XA", "QI", "DN"}
type environment struct { // Given two tiles, return if first tile is smaller the second tile, functions used as comparator for ordering
board [4][34]int // Default order is: 万 < 条 < 饼 < 字(东西南北中发白)
}
func (e environment) Print() {
for i := 0; i < len(e.board)+1; i++ {
for j := 0; j < len(e.board[0]); j++ {
if i == 0 {
fmt.Printf("|% 3s", tileTypes[j])
} else {
fmt.Printf("|% 3d", e.board[i-1][j])
}
}
fmt.Printf("|\n")
}
}
func (e environment) PatternNormalization() [3][34]int {
var ret [3][34]int
for i := 0; i < len(e.board[0]); i++ {
hand := 0
disc := 0
noshow := 0
for j := 0; j < len(e.board); j++ {
switch e.board[j][i] {
case tl_mhand, tl_mshow:
hand += 1
case tl_mdisc, tl_ndisc, tl_nshow, tl_odisc, tl_oshow, tl_pdisc, tl_pshow:
disc += 1
case tl_notshow:
noshow += 1
}
}
ret[0][i] = hand
ret[1][i] = disc
ret[2][i] = noshow
}
return ret
}
func TileComparator(i, j string) (bool, error) { func TileComparator(i, j string) (bool, error) {
if i == j { if i == j {
return false, nil return false, nil
} }
ii, ij := -1, -1 ii, ij := -1, -1
for k, v := range tileTypes { for k, v := range TileTypes {
if i == v { if i == v {
ii = k ii = k
} }
+5
View File
@@ -0,0 +1,5 @@
package tiles
type tileStruct struct {
}
+6 -16
View File
@@ -1,23 +1,11 @@
package pkg package tiles
import ( import (
"fmt"
"log" "log"
"reflect" "reflect"
"testing" "testing"
) )
func TestPrint(t *testing.T) {
var env environment
env.Print()
}
func TestPatternNormalization(t *testing.T) {
var env environment
handTiles := env.PatternNormalization()
fmt.Println(handTiles)
}
func TestTileComparator(t *testing.T) { func TestTileComparator(t *testing.T) {
type testcase struct { type testcase struct {
Args [2]string Args [2]string
@@ -76,13 +64,15 @@ func TestCheckXushuTile(t *testing.T) {
{Name: "三同顺或三同刻", Args: []string{"3W", "3W", "3W", "4W", "4W", "4W", "5W", "5W", "5W"}, Want: [][][]string{{{"3W", "3W", "3W"}, {"4W", "4W", "4W"}, {"5W", "5W", "5W"}}, {{"3W", "4W", "5W"}, {"3W", "4W", "5W"}, {"3W", "4W", "5W"}}}}, {Name: "三同顺或三同刻", Args: []string{"3W", "3W", "3W", "4W", "4W", "4W", "5W", "5W", "5W"}, Want: [][][]string{{{"3W", "3W", "3W"}, {"4W", "4W", "4W"}, {"5W", "5W", "5W"}}, {{"3W", "4W", "5W"}, {"3W", "4W", "5W"}, {"3W", "4W", "5W"}}}},
{Name: "三步四张齐", Args: []string{"3W", "3W", "3W", "3W", "4W", "4W", "4W", "4W", "5W", "5W", "5W", "5W"}, Want: [][][]string{{{"3W", "3W", "3W", "3W"}, {"4W", "4W", "4W", "4W"}, {"5W", "5W", "5W", "5W"}}, {{"3W", "4W", "5W"}, {"3W", "3W", "3W"}, {"4W", "4W", "4W"}, {"5W", "5W", "5W"}}, {{"3W", "4W", "5W"}, {"3W", "4W", "5W"}, {"3W", "4W", "5W"}, {"3W", "4W", "5W"}}, {{"3W", "3W"}, {"3W", "3W"}, {"4W", "4W"}, {"4W", "4W"}, {"5W", "5W"}, {"5W", "5W"}}}}, {Name: "三步四张齐", Args: []string{"3W", "3W", "3W", "3W", "4W", "4W", "4W", "4W", "5W", "5W", "5W", "5W"}, Want: [][][]string{{{"3W", "3W", "3W", "3W"}, {"4W", "4W", "4W", "4W"}, {"5W", "5W", "5W", "5W"}}, {{"3W", "4W", "5W"}, {"3W", "3W", "3W"}, {"4W", "4W", "4W"}, {"5W", "5W", "5W"}}, {{"3W", "4W", "5W"}, {"3W", "4W", "5W"}, {"3W", "4W", "5W"}, {"3W", "4W", "5W"}}, {{"3W", "3W"}, {"3W", "3W"}, {"4W", "4W"}, {"4W", "4W"}, {"5W", "5W"}, {"5W", "5W"}}}},
{Name: "三张不靠", Args: []string{"1W", "4W", "7W"}, Want: [][][]string{{{"1W"}, {"4W"}, {"7W"}}}}, {Name: "三张不靠", Args: []string{"1W", "4W", "7W"}, Want: [][][]string{{{"1W"}, {"4W"}, {"7W"}}}},
{Name: "两张不靠#1", Args: []string{"4W", "7W"}, Want: [][][]string{{{"4W"}, {"7W"}}}}, {Name: "两张不靠", Args: []string{"4W", "7W"}, Want: [][][]string{{{"4W"}, {"7W"}}}},
{Name: "两张不靠#2", Args: []string{"1W", "4W"}, Want: [][][]string{{{"1W"}, {"4W"}}}}, {Name: "两张不靠", Args: []string{"1W", "4W"}, Want: [][][]string{{{"1W"}, {"4W"}}}},
{Name: "两张不靠#3", Args: []string{"1W", "7W"}, Want: [][][]string{{{"1W"}, {"7W"}}}}, {Name: "两张不靠", Args: []string{"1W", "7W"}, Want: [][][]string{{{"1W"}, {"7W"}}}},
{Name: "", Args: []string{"1W", "1W", "9W"}, Want: [][][]string{{{"1W"}, {"1W"}, {"9W"}}}}, {Name: "", Args: []string{"1W", "1W", "9W"}, Want: [][][]string{{{"1W"}, {"1W"}, {"9W"}}}},
{Name: "", Args: []string{"1W", "9W", "9W"}, Want: [][][]string{{{"1W"}, {"9W"}, {"9W"}}}}, {Name: "", Args: []string{"1W", "9W", "9W"}, Want: [][][]string{{{"1W"}, {"9W"}, {"9W"}}}},
{Name: "", Args: []string{"1W", "9W"}, Want: [][][]string{{{"1W"}, {"9W"}}}}, {Name: "", Args: []string{"1W", "9W"}, Want: [][][]string{{{"1W"}, {"9W"}}}},
{Name: "无组合", Args: []string{"1W", "3W", "5W"}, Want: [][][]string{}}, {Name: "无组合", Args: []string{"1W", "3W", "5W"}, Want: [][][]string{}},
{Name: "九连宝灯", Args: []string{"1W", "1W", "1W", "2W", "3W", "4W", "5W", "6W", "7W", "8W", "9W", "9W", "9W", "1W"}, Want: [][][]string{{{"1W", "2W", "3W"}, {"1W", "1W", "1W"}, {"4W", "5W", "6W"}, {"7W", "8W", "9W"}, {"9W", "9W"}}}},
{Name: "九连宝灯", Args: []string{"1W", "1W", "1W", "2W", "3W", "4W", "5W", "6W", "7W", "8W", "9W", "9W", "9W", "5W"}, Want: [][][]string{{{"1W", "1W", "1W"}, {"2W", "3W", "4W"}, {"5W", "5W"}, {"6W", "7W", "8W"}, {"9W", "9W", "9W"}}}},
} }
for _, tc := range testcases { for _, tc := range testcases {
t.Run(tc.Name, func(t *testing.T) { t.Run(tc.Name, func(t *testing.T) {