Преглед на файлове

Don't drop held blocks blindly but score all destinations liek with regular moves

Taddeus Kroes преди 6 години
родител
ревизия
8776c3a951
променени са 1 файла, в които са добавени 10 реда и са изтрити 14 реда
  1. 10 14
      strategy.py

+ 10 - 14
strategy.py

@@ -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