chess_ai.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:Chess-AI 作者: lamesjim 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号