def get_heuristic(self, board_state=None):
cache_parse = board_state.split(" ")[0] + " " + board_state.split(" ")[1]
if board_state == None:
board_state = str(self.game)
if cache_parse in self.cache:
self.found_in_cache += 1
return self.cache[cache_parse]
clone = Game(board_state)
total_points = 0
# total piece count
total_points += heuristics.material(board_state, 100)
total_points += heuristics.piece_moves(clone, 50)
total_points += heuristics.in_check(clone, 1)
total_points += heuristics.pawn_structure(board_state, 1)
self.cache[cache_parse] = total_points
return total_points
评论列表
文章目录