lczerolens.play.sampling#
Classes for playing.
Classes#
Helper class that provides a standard way to create an ABC using |
|
Helper class that provides a standard way to create an ABC using |
|
Helper class that provides a standard way to create an ABC using |
|
Helper class that provides a standard way to create an ABC using |
|
A class for generating games. |
Module Contents#
- class lczerolens.play.sampling.Sampler[source]#
Bases:
abc.ABCHelper class that provides a standard way to create an ABC using inheritance.
- abstract get_utilities(boards, **kwargs)[source]#
Get the utility of the board.
- Parameters:
boards (Iterable[LczeroBoard]) – The boards to evaluate.
- Returns:
The iterable over utilities, legal indices, and log dictionaries.
- Return type:
Iterable[Tuple[torch.Tensor, torch.Tensor, Dict[str, float]]]
- choose_move(board, utility, legal_indices)[source]#
Choose the next moves.
- Parameters:
board (LczeroBoard) – The board.
utility (torch.Tensor) – The utility of the board.
legal_indices (torch.Tensor) – The legal indices.
- Returns:
The iterable over the moves.
- Return type:
Iterable[chess.Move]
- get_next_moves(boards, **kwargs)[source]#
Get the next move.
- Parameters:
boards (Iterable[LczeroBoard]) – The boards to evaluate.
- Returns:
The iterable over the moves and log dictionaries.
- Return type:
Iterable[Tuple[chess.Move, Dict[str, float]]]
- class lczerolens.play.sampling.RandomSampler[source]#
Bases:
SamplerHelper class that provides a standard way to create an ABC using inheritance.
- get_utilities(boards, **kwargs)[source]#
Get the utility of the board.
- Parameters:
boards (Iterable[LczeroBoard]) – The boards to evaluate.
- Returns:
The iterable over utilities, legal indices, and log dictionaries.
- Return type:
Iterable[Tuple[torch.Tensor, torch.Tensor, Dict[str, float]]]
- class lczerolens.play.sampling.ModelSampler[source]#
Bases:
SamplerHelper class that provides a standard way to create an ABC using inheritance.
- choose_move(board, utility, legal_indices)[source]#
Choose the next moves.
- Parameters:
board (LczeroBoard) – The board.
utility (torch.Tensor) – The utility of the board.
legal_indices (torch.Tensor) – The legal indices.
- Returns:
The iterable over the moves.
- Return type:
Iterable[chess.Move]
- get_utilities(boards, **kwargs)[source]#
Get the utility of the board.
- Parameters:
boards (Iterable[LczeroBoard]) – The boards to evaluate.
- Returns:
The iterable over utilities, legal indices, and log dictionaries.
- Return type:
Iterable[Tuple[torch.Tensor, torch.Tensor, Dict[str, float]]]
- class lczerolens.play.sampling.PolicySampler[source]#
Bases:
ModelSamplerHelper class that provides a standard way to create an ABC using inheritance.
- get_utilities(boards, **kwargs)[source]#
Get the utility of the board.
- Parameters:
boards (Iterable[LczeroBoard]) – The boards to evaluate.
- Returns:
The iterable over utilities, legal indices, and log dictionaries.
- Return type:
Iterable[Tuple[torch.Tensor, torch.Tensor, Dict[str, float]]]
- class lczerolens.play.sampling.SelfPlay[source]#
A class for generating games.
- play(board=None, max_moves=100, to_play=chess.WHITE, report_fn=None, white_kwargs=None, black_kwargs=None)[source]#
Plays a game.
- Parameters:
board (Optional[lczerolens.board.LczeroBoard])
max_moves (int)
to_play (chess.Color)
report_fn (Optional[Callable[[dict, chess.Color], None]])
white_kwargs (Optional[Dict])
black_kwargs (Optional[Dict])