Example #1
0
 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)
     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)
     return total_points
Example #2
0
 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
Example #3
0
    def get_heuristic(self, board_state=None):
        global cache
        global found_in_cache

        cache_parse = board_state.split(" ")[0] + " " + board_state.split(" ")[1]
        if board_state == None:
            board_state = str(self.game)
        if cache_parse in cache:
            found_in_cache += 1
            return cache[cache_parse]
        clone = Game(board_state)
        total_points = 0
        # total piece count
        total_points += heuristics.material(board_state, 0.6)
        total_points += heuristics.piece_moves(clone, 0.15)
        total_points += heuristics.in_check(clone, 0.1)
        # total_points += heuristics.center_squares(clone, 0.2)
        total_points += heuristics.pawn_structure(board_state, 0.15)
        cache[cache_parse] = total_points
        return total_points
Example #4
0
    def get_heuristic(self, board_state=None):
        global cache
        global found_in_cache

        cache_parse = board_state.split(" ")[0] + " " + board_state.split(
            " ")[1]
        if board_state == None:
            board_state = str(self.game)
        if cache_parse in cache:
            found_in_cache += 1
            return cache[cache_parse]
        clone = Game(board_state)
        total_points = 0
        # total piece count
        total_points += heuristics.material(board_state, 0.6)
        total_points += heuristics.piece_moves(clone, 0.15)
        total_points += heuristics.in_check(clone, 0.1)
        # total_points += heuristics.center_squares(clone, 0.2)
        total_points += heuristics.pawn_structure(board_state, 0.15)
        cache[cache_parse] = total_points
        return total_points