def get_engine_evaluations(board: Union[chess.Board, str], *args) -> Dict[str, str]: """ Given a board state and a list of engines, return list of each engine's recommended move Args: board (Union[chess.Board, str]): Board or FEN string of board position to analyze args (chessmate.engines.BaseEngine): engines used in evaluation Raises: TypeError: if incorrect type entered for board Returns: Dict[str, str]: name of engine, recommended move by engine """ if (not isinstance(board, chess.Board)) and (not is_valid_fen(board)): raise TypeError(f"Invalid type {type(board)}") if isinstance(board, str): board = chess.Board(fen=board) recommended_moves = {} for eng in args: move = str(eng.move(board)) recommended_moves[eng.name] = move return recommended_moves
def board(self, fen_str: str) -> None: """ Setter for setting board with new fen Args: fen_str (str): fen representation of board Raise: ValueError: if FEN is invalid given board setup """ if is_valid_fen(fen_str): try: self._board = chess.Board(fen=fen_str) except ValueError: print(f"Invalid FEN: {fen_str}")
def get_evaluation_from_fen(self, fen: str) -> int: """ Gets evaluation of position via. FEN string if position evaluation stored Args: fen (str): FEN of board state Returns: (int) """ if is_valid_fen(fen): hash_ = self.hash_current_board(chess.Board(fen=fen)) if hash_ in self.stored_values: return self.stored_values[hash_] return False