|
1 | 1 | package games
|
2 | 2 |
|
3 | 3 | import (
|
4 |
| - //"reflect" |
5 |
| - //"sort" |
| 4 | + "reflect" |
| 5 | + "sort" |
6 | 6 | "testing"
|
7 | 7 | )
|
8 | 8 |
|
@@ -671,7 +671,7 @@ var GroupTestCases = []ValidGroupEntry{
|
671 | 671 | Card{0, NoneSuit, JokerRank},
|
672 | 672 | Card{0, SpadesSuit, TwoRank},
|
673 | 673 | },
|
674 |
| - IsRun: true, |
| 674 | + IsRun: false, |
675 | 675 | IsKind: false,
|
676 | 676 | },
|
677 | 677 | GroupEntry{
|
@@ -1005,6 +1005,29 @@ var HandTestCases = []ValidHandEntry{
|
1005 | 1005 | },
|
1006 | 1006 | },
|
1007 | 1007 | },
|
| 1008 | + ValidHandEntry{ |
| 1009 | + Solver: setAceLow(true, threeThirteenSolver(QueenRank)), |
| 1010 | + Entries: []HandEntry{ |
| 1011 | + HandEntry{ |
| 1012 | + Hand: []Card{ |
| 1013 | + Card{107, ClubsSuit, AceRank}, // 0 |
| 1014 | + Card{3, DiamondsSuit, AceRank}, // 1 |
| 1015 | + Card{62, SpadesSuit, ThreeRank}, // 2 |
| 1016 | + Card{83, ClubsSuit, ThreeRank}, // 3 |
| 1017 | + Card{55, SpadesSuit, FourRank}, // 4 |
| 1018 | + Card{102, SpadesSuit, EightRank}, // 5 |
| 1019 | + Card{67, HeartsSuit, KingRank}, // 6 |
| 1020 | + |
| 1021 | + Card{1, HeartsSuit, QueenRank}, // 7 |
| 1022 | + Card{2, SpadesSuit, QueenRank}, // 8 |
| 1023 | + Card{3, DiamondsSuit, QueenRank}, // 9 |
| 1024 | + Card{4, ClubsSuit, QueenRank}, // 10 |
| 1025 | + Card{0, FancySuit, JokerRank}, // 11 |
| 1026 | + }, |
| 1027 | + Score: 5, |
| 1028 | + }, |
| 1029 | + }, |
| 1030 | + }, |
1008 | 1031 | }
|
1009 | 1032 |
|
1010 | 1033 | func TestIsValidGroup(t *testing.T) {
|
@@ -1040,71 +1063,72 @@ func TestIsValidGroup(t *testing.T) {
|
1040 | 1063 | }
|
1041 | 1064 | */
|
1042 | 1065 | // base_groups [[17 12 11 10 16] [14 15 13]] hand [Card{40, DiamondsSuit, ThreeRank} Card{54, HeartsSuit, JackRank} Card{21, DiamondsSuit, TenRank} Card{12, SpadesSuit, JackRank} Card{38, DiamondsSuit, SixRank} Card{29, SpadesSuit, EightRank} Card{28, SpadesSuit, SixRank} Card{5, DiamondsSuit, NineRank} Card{27, SpadesSuit, TenRank} Card{34, ClubsSuit, JackRank} Card{32, ClubsSuit, TenRank} Card{45, FancySuit, JokerRank} Card{31, ClubsSuit, EightRank} Card{48, DiamondsSuit, KingRank} Card{36, ClubsSuit, KingRank} Card{10, HeartsSuit, KingRank} Card{43, ClubsSuit, SixRank} Card{35, ClubsSuit, NineRank}] groups [[35 31 45 32 43] [36 10 48]]
|
1043 |
| - base_groups := [][]int{[]int{17, 12, 11, 10, 16}, []int{14, 15, 13}} |
1044 |
| - hand := []Card{ |
1045 |
| - Card{40, DiamondsSuit, ThreeRank}, |
1046 |
| - Card{54, HeartsSuit, JackRank}, |
1047 |
| - Card{21, DiamondsSuit, TenRank}, |
1048 |
| - Card{12, SpadesSuit, JackRank}, |
1049 |
| - Card{38, DiamondsSuit, SixRank}, |
1050 |
| - Card{29, SpadesSuit, EightRank}, |
1051 |
| - Card{28, SpadesSuit, SixRank}, |
1052 |
| - Card{5, DiamondsSuit, NineRank}, |
1053 |
| - Card{27, SpadesSuit, TenRank}, |
1054 |
| - Card{34, ClubsSuit, JackRank}, |
| 1066 | + /* |
| 1067 | + base_groups := [][]int{[]int{17, 12, 11, 10, 16}, []int{14, 15, 13}} |
| 1068 | + hand := []Card{ |
| 1069 | + Card{40, DiamondsSuit, ThreeRank}, |
| 1070 | + Card{54, HeartsSuit, JackRank}, |
| 1071 | + Card{21, DiamondsSuit, TenRank}, |
| 1072 | + Card{12, SpadesSuit, JackRank}, |
| 1073 | + Card{38, DiamondsSuit, SixRank}, |
| 1074 | + Card{29, SpadesSuit, EightRank}, |
| 1075 | + Card{28, SpadesSuit, SixRank}, |
| 1076 | + Card{5, DiamondsSuit, NineRank}, |
| 1077 | + Card{27, SpadesSuit, TenRank}, |
| 1078 | + Card{34, ClubsSuit, JackRank}, |
1055 | 1079 |
|
1056 |
| - Card{32, ClubsSuit, TenRank}, // 10 |
1057 |
| - Card{45, FancySuit, JokerRank}, |
1058 |
| - Card{31, ClubsSuit, EightRank}, |
| 1080 | + Card{32, ClubsSuit, TenRank}, // 10 |
| 1081 | + Card{45, FancySuit, JokerRank}, |
| 1082 | + Card{31, ClubsSuit, EightRank}, |
1059 | 1083 |
|
1060 |
| - Card{48, DiamondsSuit, KingRank}, |
1061 |
| - Card{36, ClubsSuit, KingRank}, |
1062 |
| - Card{10, HeartsSuit, KingRank}, |
| 1084 | + Card{48, DiamondsSuit, KingRank}, |
| 1085 | + Card{36, ClubsSuit, KingRank}, |
| 1086 | + Card{10, HeartsSuit, KingRank}, |
1063 | 1087 |
|
1064 |
| - Card{43, ClubsSuit, SixRank}, |
1065 |
| - Card{35, ClubsSuit, NineRank}, |
1066 |
| - } |
1067 |
| - t.Log("min score", defaultSolver.MinScoreBelowUsing(hand, 99, base_groups)) |
1068 |
| - /* |
1069 |
| - return |
1070 |
| - for _, tc := range GroupTestCases { |
1071 |
| - for _, entry := range tc.Entries { |
1072 |
| - group := entry.Group |
1073 |
| - cards := make([]int, len(group)) |
1074 |
| - for index := range group { |
1075 |
| - cards[index] = index |
1076 |
| - } |
1077 |
| - actual_group := (&tc.Solver).IsValidGroup(group, cards) |
1078 |
| - actual_run := (&tc.Solver).IsRun(group, cards) |
1079 |
| - actual_kind := (&tc.Solver).IsKind(group, cards) |
| 1088 | + Card{43, ClubsSuit, SixRank}, |
| 1089 | + Card{35, ClubsSuit, NineRank}, |
| 1090 | + } |
| 1091 | + t.Log("min score", defaultSolver.MinScoreBelowUsing(hand, 99, base_groups)) |
| 1092 | + */ |
1080 | 1093 |
|
1081 |
| - if actual_group != (entry.IsRun || entry.IsKind) || actual_run != entry.IsRun || actual_kind != entry.IsKind { |
1082 |
| - t.Error("ERROR Expected:", entry.IsRun || entry.IsKind, entry.IsRun, entry.IsKind, "got:", actual_group, actual_run, actual_kind, "\nfor group\n", group, "\nand solver\n", tc.Solver) |
1083 |
| - } |
1084 |
| - actual_score := (&tc.Solver).MinScoreBelow(group, 100) |
1085 |
| - if (entry.IsRun || entry.IsKind) == (actual_score != 0) { |
1086 |
| - if len(group) > 10 { |
1087 |
| - continue |
1088 |
| - } |
1089 |
| - //m := (&tc.Solver).AllMatches(group, cards) |
1090 |
| - //if len(m) < 12 { |
1091 |
| - // t.Log("All matches", m) |
1092 |
| - //} |
1093 |
| - t.Log("Mostly", tc.Solver.MostlyWildGroups, "all", tc.Solver.AllWildGroups) |
1094 |
| - t.Error("ERROR Expected:", (entry.IsRun || entry.IsKind), "got:", actual_score, "\nfor group\n", group, "\nand solver\n", tc.Solver) |
| 1094 | + for _, tc := range GroupTestCases { |
| 1095 | + for _, entry := range tc.Entries { |
| 1096 | + group := entry.Group |
| 1097 | + cards := make([]int, len(group)) |
| 1098 | + for index := range group { |
| 1099 | + cards[index] = index |
| 1100 | + } |
| 1101 | + actual_group := (&tc.Solver).IsValidGroup(group, cards) |
| 1102 | + actual_run := (&tc.Solver).IsRun(group, cards) |
| 1103 | + actual_kind := (&tc.Solver).IsKind(group, cards) |
| 1104 | + |
| 1105 | + if actual_group != (entry.IsRun || entry.IsKind) || actual_run != entry.IsRun || actual_kind != entry.IsKind { |
| 1106 | + t.Error("ERROR Expected:", entry.IsRun || entry.IsKind, entry.IsRun, entry.IsKind, "got:", actual_group, actual_run, actual_kind, "\nfor group\n", group, "\nand solver\n", tc.Solver) |
| 1107 | + } |
| 1108 | + actual_score := (&tc.Solver).MinScoreBelow(group, 100) |
| 1109 | + if (entry.IsRun || entry.IsKind) == (actual_score != 0) { |
| 1110 | + if len(group) > 10 { |
| 1111 | + continue |
1095 | 1112 | }
|
| 1113 | + //m := (&tc.Solver).AllMatches(group, cards) |
| 1114 | + //if len(m) < 12 { |
| 1115 | + // t.Log("All matches", m) |
| 1116 | + //} |
| 1117 | + t.Log("Mostly", tc.Solver.MostlyWildGroups, "all", tc.Solver.AllWildGroups) |
| 1118 | + t.Error("ERROR Expected:", (entry.IsRun || entry.IsKind), "got:", actual_score, "\nfor group\n", group, "\nand solver\n", tc.Solver) |
1096 | 1119 | }
|
1097 | 1120 | }
|
1098 |
| - for _, tc := range HandTestCases { |
1099 |
| - for _, entry := range tc.Entries { |
1100 |
| - group := entry.Hand |
1101 |
| - cards := make([]int, len(group)) |
1102 |
| - regular := make([]int, 0, len(group)) |
1103 |
| - for index, card := range group { |
1104 |
| - cards[index] = index |
1105 |
| - if !(&tc.Solver).IsWildCard(card) { |
1106 |
| - regular = append(regular, index) |
1107 |
| - } |
| 1121 | + } |
| 1122 | + |
| 1123 | + for _, tc := range HandTestCases { |
| 1124 | + for _, entry := range tc.Entries { |
| 1125 | + group := entry.Hand |
| 1126 | + cards := make([]int, len(group)) |
| 1127 | + regular := make([]int, 0, len(group)) |
| 1128 | + for index, card := range group { |
| 1129 | + cards[index] = index |
| 1130 | + if !(&tc.Solver).IsWildCard(card) { |
| 1131 | + regular = append(regular, index) |
1108 | 1132 | }
|
1109 | 1133 | wc := len(cards) - len(regular)
|
1110 | 1134 |
|
@@ -1167,5 +1191,6 @@ func TestIsValidGroup(t *testing.T) {
|
1167 | 1191 | t.Error("ERROR Expected:", entry.Score, "got:", actual_score, "\nfor group\n", entry.Hand, "\nand solver\n", tc.Solver)
|
1168 | 1192 | }
|
1169 | 1193 | }
|
1170 |
| - }*/ |
| 1194 | + } |
| 1195 | + } |
1171 | 1196 | }
|
0 commit comments