Taddeus Kroes 5 سال پیش
والد
کامیت
087df0264f
2فایلهای تغییر یافته به همراه6 افزوده شده و 6 حذف شده
  1. 4 5
      analyze.py
  2. 2 1
      strategy.py

+ 4 - 5
analyze.py

@@ -2,9 +2,9 @@
 import os
 import numpy as np
 from PIL import Image
-from parser import BLOCK_SIZE, COLUMN_VSHIFT, MIN_COLUMN_VAL, MIN_COLUMN_SAT, \
-                   detect_blocks, detect_exa, detect_held, print_board, \
-                   detect_columns
+from parse import BLOCK_SIZE, COLUMN_VSHIFT, MIN_COLUMN_VAL, MIN_COLUMN_SAT, \
+                  detect_blocks, detect_exa, detect_held, print_board, \
+                  detect_columns
 from strategy import State
 
 
@@ -33,11 +33,10 @@ def make_bitmap(board):
 if __name__ == '__main__':
     import sys
     ident = int(sys.argv[1])
-    extensive = sys.argv[2] == 'y' if len(sys.argv) > 2 else False
+    extensive = len(sys.argv) > 2 and sys.argv[2] == 'y'
 
     board = Image.open('screens/board%d.png' % ident).convert('HSV')
     #board.crop((0, 0, board.width, detect_columns(board))).show()
-    state = State.detect(board)
     blocks = list(detect_blocks(board))
     exa = detect_exa(board)
     held = detect_held(board, exa)

+ 2 - 1
strategy.py

@@ -24,7 +24,6 @@ MAX_SPEED_ROWS = 3
 
 class State:
     def __init__(self, blocks, exa, held):
-        assert exa is not None
         self.blocks = blocks
         self.exa = exa
         self.held = held
@@ -295,6 +294,8 @@ class State:
                             yield mov1 + get + mov2 + put
 
     def solve(self):
+        assert self.exa is not None
+
         if self.held != NOBLOCK:
             return (DROP,)