chipiron.players.boardevaluators.neural_networks.input_converters package
Submodules
chipiron.players.boardevaluators.neural_networks.input_converters.ModelInputRepresentationType module
- class chipiron.players.boardevaluators.neural_networks.input_converters.ModelInputRepresentationType.InternalTensorRepresentationType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
str,Enum- BUG364 = '364_bug'
- NO = 'no'
- NOBUG364 = '364_no_bug'
- class chipiron.players.boardevaluators.neural_networks.input_converters.ModelInputRepresentationType.ModelInputRepresentationType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
str,Enum- BOARD_PIECES_TWO_SIDES = 'board_pieces_two_sides'
- BUG364 = '364_bug'
- NOBUG364 = '364_no_bug'
- PIECE_DIFFERENCE = 'pieces_difference'
- PIECE_MAP = 'piece_map'
- chipiron.players.boardevaluators.neural_networks.input_converters.ModelInputRepresentationType.assert_compatibilities_representation_type(model_input_representation_type: ModelInputRepresentationType, internal_tensor_representation_type: InternalTensorRepresentationType) None[source]
- chipiron.players.boardevaluators.neural_networks.input_converters.ModelInputRepresentationType.get_default_internal_representation(model_input_representation_type: ModelInputRepresentationType) InternalTensorRepresentationType[source]
chipiron.players.boardevaluators.neural_networks.input_converters.board_representation module
Module defining the board representation interface and the 364 features board representation.
- class chipiron.players.boardevaluators.neural_networks.input_converters.board_representation.BoardRepresentation(*args, **kwargs)[source]
Bases:
ProtocolProtocol defining the interface for a board representation.
- class chipiron.players.boardevaluators.neural_networks.input_converters.board_representation.Representation364(tensor_white: Tensor, tensor_black: Tensor, tensor_castling_white: Tensor, tensor_castling_black: Tensor)[source]
Bases:
BoardRepresentationDataclass representing a board representation with 364 features.
- get_evaluator_input(color_to_play: bool) Tensor[source]
Returns the evaluator input tensor for the given color to play.
- Parameters:
color_to_play – The color to play, either chess.WHITE or chess.BLACK.
- Returns:
The evaluator input tensor.
- tensor_black: Tensor
- tensor_castling_black: Tensor
- tensor_castling_white: Tensor
- tensor_white: Tensor
- class chipiron.players.boardevaluators.neural_networks.input_converters.board_representation.Representation364_2(tensor: Tensor)[source]
Bases:
BoardRepresentationDataclass representing a board representation with 364 features.
- get_evaluator_input(color_to_play: bool) Tensor[source]
Returns the evaluator input tensor for the given color to play.
- Parameters:
color_to_play – The color to play, either chess.WHITE or chess.BLACK.
- Returns:
The evaluator input tensor.
- tensor: Tensor
chipiron.players.boardevaluators.neural_networks.input_converters.board_to_input module
Module for the BoardToInput protocol and BoardToInputFunction protocol.
- class chipiron.players.boardevaluators.neural_networks.input_converters.board_to_input.BoardToInput(*args, **kwargs)[source]
Bases:
ProtocolProtocol for converting a chess board to a tensor input for a neural network.
- class chipiron.players.boardevaluators.neural_networks.input_converters.board_to_input.BoardToInputFunction(*args, **kwargs)[source]
Bases:
ProtocolProtocol for a callable object that converts a chess board to a tensor input for a neural network.
- chipiron.players.boardevaluators.neural_networks.input_converters.board_to_input.create_board_to_input(model_input_representation_type: ModelInputRepresentationType) BoardToInputFunction[source]
- chipiron.players.boardevaluators.neural_networks.input_converters.board_to_input.create_board_to_input_from_representation(internal_tensor_representation_type: InternalTensorRepresentationType) BoardToInputFunction[source]
chipiron.players.boardevaluators.neural_networks.input_converters.board_to_transformer_input module
- chipiron.players.boardevaluators.neural_networks.input_converters.board_to_transformer_input.build_transformer_input(piece_map: dict[int, tuple[int, bool]], board_turn: bool, transformer_args: TransformerArgs) Tensor[source]
chipiron.players.boardevaluators.neural_networks.input_converters.factory module
This module provides functions and classes for creating board representations used in neural networks.
The main classes in this module are: - Representation364: Represents the board state using a tensor of size 364. - Representation364Factory: Factory class for creating Representation364 objects.
The module also includes helper functions for converting board states to tensors and vice versa.
Note: This module is part of the chipiron package.
- class chipiron.players.boardevaluators.neural_networks.input_converters.factory.CreateFromBoard(*args, **kwargs)[source]
Bases:
Protocol,Generic
- class chipiron.players.boardevaluators.neural_networks.input_converters.factory.CreateFromBoardAndFromParent(*args, **kwargs)[source]
Bases:
Protocol,Generic
- class chipiron.players.boardevaluators.neural_networks.input_converters.factory.RepresentationFactory(create_from_board: CreateFromBoard, create_from_board_and_from_parent: CreateFromBoardAndFromParent)[source]
Bases:
GenericFactory class for creating instances of BoardFactory
- create_from_board: CreateFromBoard
- create_from_board_and_from_parent: CreateFromBoardAndFromParent
- create_from_transition(tree_node: TreeNode[Any], parent_node_representation: T_BoardRepresentation | None, modifications: BoardModificationP | None) T_BoardRepresentation[source]
Create a Representation364 object from a transition.
- Parameters:
tree_node (TreeNode) – The current tree node.
parent_node (AlgorithmNode | None) – The parent node of the current tree node.
modifications (board_mod.BoardModification | None) – The board modifications.
- Returns:
The created Representation364 object.
- Return type:
chipiron.players.boardevaluators.neural_networks.input_converters.rep_364 module
- chipiron.players.boardevaluators.neural_networks.input_converters.rep_364.a(black: Tensor, white: Tensor, piece_map: dict[int, tuple[int, bool]]) None[source]
- chipiron.players.boardevaluators.neural_networks.input_converters.rep_364.b(board: IBoard, castling_black: Tensor, castling_white: Tensor) None[source]
- chipiron.players.boardevaluators.neural_networks.input_converters.rep_364.c(castling_black: Tensor, castling_white: Tensor, black: Tensor, white: Tensor) Representation364[source]
- chipiron.players.boardevaluators.neural_networks.input_converters.rep_364.create_from_board(board: IBoard) Representation364[source]
Create a Representation364 object from a board.
- Parameters:
board (BoardChi) – The chess board.
- Returns:
The created Representation364 object.
- Return type:
- chipiron.players.boardevaluators.neural_networks.input_converters.rep_364.create_from_board_and_from_parent(board: IBoard, board_modifications: BoardModificationP, parent_node_board_representation: Representation364) Representation364[source]
Converts the node, board modifications, and parent node into a tensor representation.
- Parameters:
board (IBoard) – The current board in the tree.
board_modifications (board_mod.BoardModification) – The modifications made to the board.
parent_node (AlgorithmNode) – The parent node of the current node.
- Returns:
The tensor representation of the node, board modifications, and parent node.
- Return type:
chipiron.players.boardevaluators.neural_networks.input_converters.rep_364_bug module
- chipiron.players.boardevaluators.neural_networks.input_converters.rep_364_bug.a(black: Tensor, white: Tensor, piece_map: dict[int, tuple[int, bool]]) None[source]
- chipiron.players.boardevaluators.neural_networks.input_converters.rep_364_bug.b(board: IBoard, castling_black: Tensor, castling_white: Tensor) None[source]
- chipiron.players.boardevaluators.neural_networks.input_converters.rep_364_bug.c(castling_black: Tensor, castling_white: Tensor, black: Tensor, white: Tensor) Representation364[source]
- chipiron.players.boardevaluators.neural_networks.input_converters.rep_364_bug.create_from_board(board: IBoard) Representation364[source]
Create a Representation364 object from a board.
- Parameters:
board (BoardChi) – The chess board.
- Returns:
The created Representation364 object.
- Return type:
- chipiron.players.boardevaluators.neural_networks.input_converters.rep_364_bug.create_from_board_and_from_parent(board: IBoard, board_modifications: BoardModificationP, parent_node_board_representation: Representation364) Representation364[source]
Converts the node, board modifications, and parent node into a tensor representation.
- Parameters:
board (IBoard) – The current board in the tree.
board_modifications (board_mod.BoardModification) – The modifications made to the board.
parent_node (AlgorithmNode) – The parent node of the current node.
- Returns:
The tensor representation of the node, board modifications, and parent node.
- Return type:
chipiron.players.boardevaluators.neural_networks.input_converters.representation_364_bti module
This module provides a class for converting a chess board into a tensor representation using a 364-dimensional input.
Classes: - Representation364BTI: Converts a chess board into a tensor representation.
- class chipiron.players.boardevaluators.neural_networks.input_converters.representation_364_bti.RepresentationBTI(representation_factory: RepresentationFactory[Any])[source]
Bases:
objectConverts a chess board into a tensor representation using a 364-dimensional input.
Methods: - __init__: Initializes the Representation364BTI object. - convert: Converts the chess board into a tensor representation.
chipiron.players.boardevaluators.neural_networks.input_converters.representation_factory_factory module
- chipiron.players.boardevaluators.neural_networks.input_converters.representation_factory_factory.create_board_representation_factory(internal_tensor_representation_type: InternalTensorRepresentationType) RepresentationFactory[Any] | None[source]
Create a board representation based on the given string.
- Parameters:
internal_tensor_representation_type (InternalTensorRepresentationType) – The string representing the board representation.
- Returns:
The created board representation object, or None if the string is ‘no’.
- Return type:
Representation364Factory | None
- Raises:
Exception – If the string is not ‘364’.