|
|
@@ -233,14 +233,18 @@ class State:
|
|
|
return -points
|
|
|
|
|
|
def gen_moves(self):
|
|
|
- yield self
|
|
|
+ if self.held == NOBLOCK:
|
|
|
+ yield self
|
|
|
|
|
|
- for src in self.gen_shift(True):
|
|
|
- yield from src.gen_stationary()
|
|
|
+ for src in self.gen_shift(True):
|
|
|
+ yield from src.gen_stationary()
|
|
|
|
|
|
- for get in src.gen_get():
|
|
|
- for dst in get.gen_shift(False):
|
|
|
- yield from dst.gen_put()
|
|
|
+ for get in src.gen_get():
|
|
|
+ for dst in get.gen_shift(False):
|
|
|
+ yield from dst.gen_put()
|
|
|
+ else:
|
|
|
+ for dst in self.gen_shift(True):
|
|
|
+ yield from dst.gen_put()
|
|
|
|
|
|
def gen_shift(self, allow_noshift):
|
|
|
if allow_noshift:
|
|
|
@@ -303,17 +307,9 @@ class State:
|
|
|
if avail >= 2:
|
|
|
yield swap.move(GRAB, SWAP, DROP)
|
|
|
|
|
|
- def force(self, *moves):
|
|
|
- state = self.move(*moves)
|
|
|
- state.score = ()
|
|
|
- return state
|
|
|
-
|
|
|
def solve(self):
|
|
|
assert self.exa is not None
|
|
|
|
|
|
- if self.held != NOBLOCK:
|
|
|
- return self.force(DROP)
|
|
|
-
|
|
|
pool = deque(self.gen_moves())
|
|
|
assert len(pool) > 0
|
|
|
|