def dijkstraEval(self, board_state, maximizer): h = HexBoard(board_state.shape[0]) h.board = board_state red_shortestPath = self.dijkstra(hexboard=h, color=h.RED) blue_shortestPath = self.dijkstra(hexboard=h, color=h.BLUE) freeReds = self.getFreeHexes(hexboard=h, path=red_shortestPath) freeBlues = self.getFreeHexes(hexboard=h, path=blue_shortestPath) heuristic_score = 0 if maximizer == h.RED: heuristic_score = freeBlues - freeReds else: heuristic_score = freeReds - freeBlues return heuristic_score # def iterativeDeepening(self, node, maximizer): # depth = 1 # end_time = datetime.now() + timedelta(seconds=3) # For windows os # while datetime.now() < end_time and not msvcrt.kbhit(): # bestScore = self.alphaBetaSearch(node, depth, -9999999, 9999999, isMaximizer=maximizer) # depth = depth + 1 # return bestScore
def dijkstraEval(self, board_state, maximizer): h = HexBoard(board_state.shape[0]) h.board = board_state red_shortestPath = self.dijkstra(hexboard=h, color=h.RED) blue_shortestPath = self.dijkstra(hexboard=h, color=h.BLUE) freeReds = self.getFreeHexes(hexboard=h, path=red_shortestPath) freeBlues = self.getFreeHexes(hexboard=h, path=blue_shortestPath) if maximizer == h.RED: heuristic_score = freeBlues - freeReds else: heuristic_score = freeReds - freeBlues return heuristic_score