-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhst_forcing_chains_test.go
237 lines (219 loc) · 6.23 KB
/
hst_forcing_chains_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
package sudoku
import (
"strconv"
"testing"
)
func TestForcingChains(t *testing.T) {
techniqueVariantsTestHelper(t, "Forcing Chain",
"Forcing Chain (1 steps)",
"Forcing Chain (2 steps)",
"Forcing Chain (3 steps)",
"Forcing Chain (4 steps)",
"Forcing Chain (5 steps)",
"Forcing Chain (6 steps)",
)
//TODO: the fact that every time we make a relatively small change to the forcing chain algo
//we have to manually swizzle the test cases around reveals that the exact behavior of forcing
//chains is fundamentally arbitrary. That makes me nervous. We should probably add a bunch more
//tests.
//Tester puzzle: http://www.komoroske.com/sudoku/index.php?puzzle=Q6Ur5iYGINSUFcyocqaY6G91DpttiqYzs
tests := []multipleValidStepLoopOptions{
{
targetCells: CellRefSlice{{0, 1}},
targetNums: IntSlice([]int{7}),
pointerCells: CellRefSlice{{1, 0}},
pointerNums: IntSlice([]int{1, 2}),
description: "cell (1,0) only has two options, 1 and 2, and if you put either one in and see the chain of implications it leads to, both ones end up with 7 in cell (0,1), so we can just fill that number in",
extra: 6,
},
{
targetCells: CellRefSlice{{0, 1}},
targetNums: IntSlice([]int{7}),
pointerCells: CellRefSlice{{5, 1}},
pointerNums: IntSlice([]int{1, 2}),
//Explicitly don't test description after the first one.
extra: 4,
},
//Another particularly long one
{
targetCells: CellRefSlice{{1, 0}},
targetNums: IntSlice([]int{1}),
pointerCells: CellRefSlice{{0, 1}},
pointerNums: IntSlice([]int{2, 7}),
extra: 5,
},
{
targetCells: []CellRef{{1, 0}},
targetNums: IntSlice([]int{1}),
pointerCells: []CellRef{{0, 6}},
pointerNums: IntSlice([]int{3, 7}),
extra: 5,
},
{
targetCells: []CellRef{{1, 8}},
targetNums: IntSlice([]int{4}),
pointerCells: []CellRef{{1, 0}},
pointerNums: IntSlice([]int{1, 2}),
extra: 6,
},
{
targetCells: []CellRef{{1, 8}},
targetNums: IntSlice([]int{4}),
pointerCells: []CellRef{{4, 0}},
pointerNums: IntSlice([]int{1, 2}),
extra: 6,
},
{
targetCells: []CellRef{{1, 8}},
targetNums: IntSlice([]int{4}),
pointerCells: []CellRef{{5, 1}},
pointerNums: IntSlice([]int{1, 2}),
extra: 6,
},
{
targetCells: []CellRef{{1, 8}},
targetNums: IntSlice([]int{4}),
pointerCells: []CellRef{{5, 7}},
pointerNums: IntSlice([]int{1, 3}),
extra: 6,
},
{
targetCells: []CellRef{{4, 0}},
targetNums: IntSlice([]int{2}),
pointerCells: []CellRef{{0, 1}},
pointerNums: IntSlice([]int{2, 7}),
extra: 5,
},
{
targetCells: []CellRef{{4, 0}},
targetNums: IntSlice([]int{2}),
pointerCells: []CellRef{{0, 6}},
pointerNums: IntSlice([]int{3, 7}),
extra: 5,
},
{
targetCells: []CellRef{{4, 5}},
targetNums: IntSlice([]int{7}),
pointerCells: []CellRef{{5, 4}},
pointerNums: IntSlice([]int{2, 3}),
extra: 6,
},
{
targetCells: []CellRef{{5, 1}},
targetNums: IntSlice([]int{1}),
pointerCells: []CellRef{{0, 1}},
pointerNums: IntSlice([]int{2, 7}),
extra: 5,
},
{
targetCells: []CellRef{{8, 3}},
targetNums: IntSlice([]int{7}),
pointerCells: []CellRef{{8, 7}},
pointerNums: IntSlice([]int{1, 2}),
extra: 6,
},
/* Steps that got dropped out when we switched to DFS
//This next one's particularly long implication chain
{
targetCells: []cellRef{{0, 1}},
targetNums: IntSlice([]int{7}),
pointerCells: []cellRef{{4, 0}},
pointerNums: IntSlice([]int{1, 2}),
},
{
targetCells: []cellRef{{0, 1}},
targetNums: IntSlice([]int{7}),
pointerCells: []cellRef{{5, 7}},
pointerNums: IntSlice([]int{1, 3}),
},
*/
/* Steps that dropped out when we switched to backwards intersect
{
targetCells: []cellRef{{0, 6}},
targetNums: IntSlice([]int{3}),
pointerCells: []cellRef{{5, 1}},
pointerNums: IntSlice([]int{1, 2}),
},
{
targetCells: []cellRef{{5, 1}},
targetNums: IntSlice([]int{1}),
pointerCells: []cellRef{{0, 6}},
pointerNums: IntSlice([]int{3, 7}),
},
*/
/* Steps that are too long now
{
targetCells: []cellRef{{0, 1}},
targetNums: IntSlice([]int{7}),
pointerCells: []cellRef{{5, 4}},
pointerNums: IntSlice([]int{2, 3}),
},
{
targetCells: []cellRef{{8, 3}},
targetNums: IntSlice([]int{7}),
pointerCells: []cellRef{{5, 4}},
pointerNums: IntSlice([]int{2, 3}),
},
{
targetCells: []cellRef{{8, 3}},
targetNums: IntSlice([]int{7}),
pointerCells: []cellRef{{5, 7}},
pointerNums: IntSlice([]int{1, 3}),
},
{
targetCells: []cellRef{{0, 6}},
targetNums: IntSlice([]int{3}),
pointerCells: []cellRef{{1, 0}},
pointerNums: IntSlice([]int{1, 2}),
},
{
targetCells: []cellRef{{8, 3}},
targetNums: IntSlice([]int{7}),
pointerCells: []cellRef{{7, 8}},
pointerNums: IntSlice([]int{2, 7}),
},
*/
/*
Steps that are valid, but that we don't expect the technique to find
right now.
{
targetCells: []cellRef{{0, 1}},
targetNums: IntSlice([]int{7}),
pointerCells: []cellRef{{1, 0}},
pointerNums: IntSlice([]int{1, 2}),
},
//Another particularly long one
{
targetCells: []cellRef{{5, 1}},
targetNums: IntSlice([]int{1}),
pointerCells: []cellRef{{0, 6}},
pointerNums: IntSlice([]int{3, 7}),
},
//Another particularly long one
{
targetCells: []cellRef{{1, 0}},
targetNums: IntSlice([]int{1}),
pointerCells: []cellRef{{0, 6}},
pointerNums: IntSlice([]int{3, 7}),
},
//Another particularly long one
{
targetCells: []cellRef{{5, 1}},
targetNums: IntSlice([]int{1}),
pointerCells: []cellRef{{0, 6}},
pointerNums: IntSlice([]int{3, 7}),
},
{
targetCells: []cellRef{{8, 3}},
targetNums: IntSlice([]int{7}),
pointerCells: []cellRef{{5, 7}},
pointerNums: IntSlice([]int{1, 3}),
},
*/
}
for i := range tests {
tests[i].variantName = "Forcing Chain (" + strconv.Itoa(tests[i].extra.(int)) + " steps)"
}
multipleValidStepsTestHelper(t, "forcingchain_test1.sdk", "Forcing Chain", tests)
//TODO: test all other valid steps that could be found at this grid state for this technique.
}