def do_step(self): solutions = [] for strategy in self.strategies: solution = strategy.solve(self.board) solutions.append(solution) print "Solutia data de strategia {0} are scorul {1} este Start ({2},{3}) End {4} ".\ format(strategy.name, solution[0], solution[1], solution[2], solution[3]) solutions = sorted(solutions, reverse=True) best_move = solutions[0] print "Solutia finala cu scorul {0} si mutarea Start ({1},{2}) End {3}".\ format(best_move[0], best_move[1], best_move[2], best_move[3]) MouseUtils.doMove(best_move, (len(self.board[best_move[3]])))
def run(self): prev_img = ImageGrab.grab(self.box) while True: MouseUtils.random_idle_mouse_movement() time.sleep(0.5) MouseUtils.random_idle_mouse_movement() img = ImageGrab.grab() img = img.crop(self.box) self.do_recognition() if self.can_start_move(img, prev_img): if self.can_start_move(img, self.im_end): break self.do_step() prev_img = img