Kaynağa Gözat

Print groups in debug output

Taddeus Kroes 5 yıl önce
ebeveyn
işleme
5d8c67cd1f
1 değiştirilmiş dosya ile 16 ekleme ve 0 silme
  1. 16 0
      strategy.py

+ 16 - 0
strategy.py

@@ -352,6 +352,14 @@ class State:
 
         return cls.points, cls.fragmentation, cls.holes, cls.nmoves
 
+    def print_groupsizes(self):
+        for start in range(len(self.groupsizes) - COLUMNS, -1, -COLUMNS):
+            print(' '.join('%-2d' % g for g in self.groupsizes[start:start + COLUMNS]))
+
+    def print_groups(self):
+        for start in range(len(self.groups) - COLUMNS, -1, -COLUMNS):
+            print(' '.join('%-2d' % g for g in self.groups[start:start + COLUMNS]))
+
     def print(self):
         print_board(self.blocks, self.exa, self.held)
 
@@ -458,6 +466,14 @@ if __name__ == '__main__':
     state.print()
     print()
 
+    print('groups:')
+    state.print_groups()
+    print()
+
+    print('groupsizes:')
+    state.print_groupsizes()
+    print()
+
     start = time.time()
     newstate = state.solve()
     end = time.time()