-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_queller.py
335 lines (291 loc) · 5.98 KB
/
test_queller.py
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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
#!/usr/bin/env python
# coding: utf-8
from queller import Board
from queller import Searcher
import unittest
# Quell levels
# Introduction
shelf1928_level1 = """
x xxxxx
x p x
x p d pxx
x px x
x x x x
"""
# Easy going
shelf1928_level2 = """
xxxxxxxx
xxp x
xp x
x x
xxxxx x
x x
xpd x
xxx
"""
# Side to side
shelf1928_level3 = """
xxxxxxxxxxx
p xxxp
x
d xp
x x x
pxx
xxxx
xxxxxxxxxxx
"""
# No way back
shelf1928_level4 = """
xxxxxxxxx
xxp x xx
x x x x x
x p g x
x x x
xxd x pxx
xxxxxxxxx
"""
# Look sharp
shelf1928_level5 = """
xxxxxxxxx
xxxxxx <
> p xx
x d p x
xx x
xxx p p x
xxxxxxxxx
"""
# The blunt truth
shelf1928_level6 = """
xx xx
xxxxxxxxx
xxvp vxx
xx xx
xx d xx
xx p ^ p x
xxxxxxxxx
xx xx
"""
# One way
shelf1928_level7 = """
pxxxx
xxx v xx
xx> xx
pxx> d p
xx> xx
p
xxxxx
"""
# Frozen
shelf1928_level8 = """
xxxxxxxxxxxx
xv xpxx
x g d x
x x
xp x
xx + xx
xxxxxxxxxxxx
"""
# A certain ring
shelf1928_level9 = """
xxxxx
x ox
x pxxx
xx xxpx
x dxo x
xxxxx
"""
# Step in the right direction
shelf1928_level10 = """
xxx xx
xv xxx x
xx xxxx xx
xxop xp oxx
xx xxx xx
x pxxxd x
xxx xx
"""
# At a push (8)
shelf1928_level11 = u"""
xxxxv
xxxp x
x xxx x
x ♀ p x
x xx x
xd ♂xxxx
x x
xxxx
"""
# Down to Earth
shelf1937_level1 = u"""
x xp x
x xx x
xx g xx
xxxxxxxxpxxxx
xxxxxx xxx
xxpg d xxxx
x x x x
x x x
"""
# Illusion of Choice
shelf1937_level2 = u"""
xxxxxxx
xp
x xgx x
xpgdgpx
x xgx x
xx p xx
xxxxxxx
"""
# More Haste
shelf1937_level3 = u"""
p p
x x
x p gg pdx
x x x x
x x
x x
"""
# Worth its Weight
shelf1937_level4 = """
xxxxxxxxxxxxxxx
xx p x xxx
x px xp xx
x p xp x
xxd x x xx
xxx px x pxxx
xxxxxxxxxxxxxxx
"""
# Tunnel Vision
shelf1937_level5 = """
xxxxxxxxxxxxxxx
x g g g g p x
xgxxxxxxx xxxxx
x g x pg x
x xxx x xdxxx x
x xxx xgxxx g x
xpxp x gp xxx
xxxxxxxxxxxxxxx
"""
# The Trap
shelf1937_level6 = """
xxxxxxxxxxx
> p <
xx
d xp p
+ xx
xxxp x
x xx
"""
# Open and Shut Case
shelf1937_level7 = """
g
dgp
g
g p
"""
class TestQueller(unittest.TestCase):
def solution_should_be(self, level, solution):
board = Board.fromString(level)
searcher = Searcher(board)
moves = searcher.search()
self.assertEqual(moves, solution)
def test_shelf1928_level1(self):
self.solution_should_be(
shelf1928_level1,
['right', 'up', 'left', 'down', 'right'],
)
def test_shelf1928_level2(self):
self.solution_should_be(
shelf1928_level2,
['left', 'up', 'left', 'down', 'right', 'up', 'left'],
)
def test_shelf1928_level3(self):
self.solution_should_be(
shelf1928_level3,
['left', 'right', 'down', 'left', 'up', 'right'],
)
def test_shelf1928_level4(self):
self.solution_should_be(
shelf1928_level4,
['right', 'up', 'left', 'right', 'down', 'left', 'up', 'right',
'up', 'left', 'down'],
)
def test_shelf1928_level5(self):
self.solution_should_be(
shelf1928_level5,
['up', 'right', 'down', 'left', 'up'],
)
def test_shelf1928_level6(self):
self.solution_should_be(
shelf1928_level6,
['right', 'down', 'left', 'up', 'left', 'down'],
)
def test_shelf1928_level7(self):
self.solution_should_be(
shelf1928_level7,
['right', 'down', 'right'],
)
def test_shelf1928_level8(self):
self.solution_should_be(
shelf1928_level8,
['left', 'down', 'right', 'up', 'left', 'up', 'right', 'down', 'right', 'up'],
)
def test_shelf1928_level9(self):
self.solution_should_be(
shelf1928_level9,
['up', 'right', 'up', 'down', 'left', 'down', 'right'],
)
def test_shelf1928_level10(self):
self.solution_should_be(
shelf1928_level10,
['up', 'right', 'down', 'right', 'up', 'left'],
)
def test_shelf1928_level11(self):
self.solution_should_be(
shelf1928_level11,
[],
)
del test_shelf1928_level11
def test_shelf1937_level1(self):
self.solution_should_be(
shelf1937_level1,
['left', 'down', 'right', 'up', 'left', 'down', 'left', 'down'],
)
def test_shelf1937_level2(self):
self.solution_should_be(
shelf1937_level2,
['right', 'up', 'right', 'down', 'up', 'left', 'down'],
)
def test_shelf1937_level3(self):
self.solution_should_be(
shelf1937_level3,
['up', 'down', 'left', 'up'],
)
def test_shelf1937_level4(self):
self.solution_should_be(
shelf1937_level4,
['right', 'down', 'right', 'left', 'up', 'right', 'down', 'right',
'up', 'right', 'down', 'left', 'up', 'right', 'down', 'left',
'up', 'left', 'up', 'right', 'down', 'right', 'down', 'right',
'down', 'right'],
)
def test_shelf1937_level5(self):
self.solution_should_be(
shelf1937_level5,
['up', 'right', 'left', 'down', 'up', 'right', 'left', 'down',
'left', 'right', 'up', 'right', 'down', 'right', 'up', 'right',
'up', 'left'],
)
def test_shelf1937_level6(self):
self.solution_should_be(
shelf1937_level6,
['left', 'down', 'left', 'right', 'up', 'left'],
)
def test_shelf1937_level7(self):
self.solution_should_be(
shelf1937_level7,
[],
)
del test_shelf1937_level7
if __name__ == '__main__':
unittest.main()