py/basic_bot_1_2.py
def _build_tree(self, halfmove_depth=0, halfmove_depth_limit=2):
        """Return a tree of positions to evaluate to find the best move"""

        # Make a leaf node if the game is over or we have reached the depth limit
        if self.board.is_game_over() or halfmove_depth == halfmove_depth_limit:
            return {'fen': self.board.fen(),
                    'moves': []
                    }
    
        # Make a branch
        else:
            new_root = {'fen': self.board.fen(),
                        'moves': list(self.board.legal_moves)
                        }
    
            if halfmove_depth == 0:
                new_root['board'] = self.board
    
            for move in new_root['moves']:
    
                # Make a legal move
                self.board.push(move)
    
                # Add the resulting state ("depth first")
                new_root[move] = self._build_tree(halfmove_depth=halfmove_depth+1,
                                                  halfmove_depth_limit=halfmove_depth_limit)
                                                  
                # Undo the move
                self.board.pop()
    
            return new_root
Return a tree of positions to evaluate to find the best move
Return a tree of positions to evaluate to find the best move
Return a tree of positions to evaluate to find the best move
def _build_tree(self, halfmove_depth=0, halfmove_depth_limit=2):
        if self.board.is_game_over() or halfmove_depth == halfmove_depth_limit:
            return {'fen': self.board.fen(),
                    'moves': []
                    }
        else:
            new_root = {'fen': self.board.fen(),
                        'moves': list(self.board.legal_moves)
                        }
            if halfmove_depth == 0:
                new_root['board'] = self.board
            for move in new_root['moves']:
                self.board.push(move)
                new_root[move] = self._build_tree(halfmove_depth=halfmove_depth+1,
                                                  halfmove_depth_limit=halfmove_depth_limit)
                self.board.pop()
            return new_root
def _build_tree ( self , halfmove_depth = 0 , halfmove_depth_limit = 2 ) : if self . board . is_game_over ( ) or halfmove_depth == halfmove_depth_limit : return { 'fen' : self . board . fen ( ) , 'moves' : [ ] } else : new_root = { 'fen' : self . board . fen ( ) , 'moves' : list ( self . board . legal_moves ) } if halfmove_depth == 0 : new_root [ 'board' ] = self . board for move in new_root [ 'moves' ] : self . board . push ( move ) new_root [ move ] = self . _build_tree ( halfmove_depth = halfmove_depth + 1 , halfmove_depth_limit = halfmove_depth_limit ) self . board . pop ( ) return new_root
Return a tree of positions to evaluate to find the best move
Return a tree of positions to evaluate to find the best move
"""Return a tree of positions to evaluate to find the best move""" # Make a leaf node if the game is over or we have reached the depth limit # Make a branch # Make a legal move # Add the resulting state ("depth first") # Undo the move
self
halfmove_depth
halfmove_depth_limit