def board(self, _cache=False): """ Gets the starting position of the game. Unless the ``FEN`` header tag is set, this is the default starting position (for the ``Variant``). """ chess960 = self.headers.get("Variant", "").lower() in [ "chess960", "fischerandom", # Cute Chess "fischerrandom" ] # http://www.freechess.org/Help/HelpFiles/wild.html wild = self.headers.get("Variant", "").lower() in [ "wild/0", "wild/1", "wild/2", "wild/3", "wild/4", "wild/5", "wild/6", "wild/7", "wild/8", "wild/8a" ] if chess960 or wild or "Variant" not in self.headers: VariantBoard = chess.Board else: from chess.variant import find_variant VariantBoard = find_variant(self.headers["Variant"]) fen = self.headers.get("FEN", VariantBoard.starting_fen) board = VariantBoard(fen, chess960=chess960) board.chess960 = board.chess960 or board.has_chess960_castling_rights() return board
def board(self, _cache=False): """ Gets the starting position of the game. Unless the ``FEN`` header tag is set, this is the default starting position (for the ``Variant``). """ chess960 = self.headers.get("Variant", "").lower() in [ "chess960", "fischerandom", # Cute Chess "fischerrandom"] # http://www.freechess.org/Help/HelpFiles/wild.html wild = self.headers.get("Variant", "").lower() in [ "wild/0", "wild/1", "wild/2", "wild/3", "wild/4", "wild/5", "wild/6", "wild/7", "wild/8", "wild/8a"] if chess960 or wild or "Variant" not in self.headers: VariantBoard = chess.Board else: from chess.variant import find_variant VariantBoard = find_variant(self.headers["Variant"]) fen = self.headers.get("FEN", VariantBoard.starting_fen) board = VariantBoard(fen, chess960=chess960) board.chess960 = board.chess960 or board.has_chess960_castling_rights() return board
def board(self, _cache=False): """ Gets the starting position of the game. Unless the `SetUp` and `FEN` header tags are set this is the default starting position. """ chess960 = self.headers.get("Variant", "").lower() in [ "chess960", "fischerandom", # Cutechess "fischerrandom" ] if chess960 or "Variant" not in self.headers: VariantBoard = chess.Board else: from chess.variant import find_variant VariantBoard = find_variant(self.headers["Variant"]) fen = self.headers.get("FEN") if self.headers.get("SetUp", "1") == "1" else None board = VariantBoard(fen or VariantBoard.starting_fen, chess960=chess960) board.chess960 = board.chess960 or board.has_chess960_castling_rights() return board
def getvariantboard(variantkey="standard"): if variantkey == "standard": return chess.Board() elif variantkey == "chess960": return chess.Board(chess960=True) elif variantkey == "fromPosition": return chess.Board() else: VariantBoard = find_variant(variantkey) return VariantBoard()
def setup_board(game): if game.variant_name.lower() == "chess960": board = chess.Board(game.initial_fen, chess960=True) else: VariantBoard = find_variant(game.variant_name) board = VariantBoard() moves = game.state["moves"].split() for move in moves: board = update_board(board, move) return board
def setup_board(game): if game.variant_name.lower() == "chess960": board = chess.Board(game.initial_fen, chess960=True) elif game.variant_name == "From Position": board = chess.Board(game.initial_fen) else: VariantBoard = find_variant(game.variant_name) board = VariantBoard() for move in game.state["moves"].split(): try: board.push_uci(move) except ValueError as e: logger.debug("Ignoring illegal move {} on board {} ({})".format(move, board.fen(), e)) return board
def board(self, _cache=False): """ Gets the starting position of the game. Unless the `SetUp` and `FEN` header tags are set this is the default starting position. """ chess960 = self.headers.get("Variant", "").lower() == "chess960" if chess960 or "Variant" not in self.headers: VariantBoard = chess.Board else: from chess.variant import find_variant VariantBoard = find_variant(self.headers["Variant"]) fen = self.headers.get("FEN") if self.headers.get("SetUp", "1") == "1" else None board = VariantBoard(fen or VariantBoard.starting_fen, chess960) board.chess960 = board.chess960 or board.has_chess960_castling_rights() return board
def board(self, _cache=False): """ Gets the starting position of the game. Unless the `SetUp` and `FEN` header tags are set this is the default starting position. """ if "Variant" not in self.headers: VariantBoard = chess.Board elif self.headers["Variant"].lower() == "chess960": VariantBoard = lambda fen: chess.Board(fen, chess960=True) else: from chess.variant import find_variant VariantBoard = find_variant(self.headers["Variant"]) fen = self.headers.get("FEN") if self.headers.get("SetUp", "1") == "1" else None board = VariantBoard(fen or VariantBoard.starting_fen) board.chess960 = board.chess960 or board.has_chess960_castling_rights() return board
def board(self, _cache=False): """ Gets the starting position of the game. Unless the ``FEN`` header tag is set, this is the default starting position (for the ``Variant``). """ chess960 = self.headers.get("Variant", "").lower() in [ "chess960", "fischerandom", # Cute Chess "fischerrandom" ] if chess960 or "Variant" not in self.headers: VariantBoard = chess.Board else: from chess.variant import find_variant VariantBoard = find_variant(self.headers["Variant"]) fen = self.headers.get("FEN", VariantBoard.starting_fen) board = VariantBoard(fen, chess960=chess960) board.chess960 = board.chess960 or board.has_chess960_castling_rights() return board
def variant(self) -> Type[chess.Board]: if "Variant" not in self or self.is_chess960() or self.is_wild(): return chess.Board else: from chess.variant import find_variant return find_variant(self["Variant"])