2Implementations of Player, and Exceptions for notifying specific Player types
3of illegal proposed Move.
5Human Player does not have an associated Exception - just prompt for new entry.
10from typing
import List, Tuple
17from xiangqi_bindings
import (
22 MinimaxMoveEvaluator64,
23 MinimaxMoveEvaluator128,
31 Uses terminal UI to propose moves.
34 def __init__(self, color: PieceColor, player_type: PlayerType) ->
None:
35 super().
__init__(color=color, player_type=player_type)
39 self, game_board: GameBoard, cur_moves: List[Move]
43 while not valid_input:
44 user_input = input(self.
_input_req.input_prompt)
45 parsed_input = mt.parse_input(user_input)
46 if mt.is_valid_algebraic_pair(parsed_input):
47 valid_input = parsed_input
51 proposed_move = mt.convert_parsed_input_to_move(
52 parsed_input=valid_input
57 self, illegal_move: Move, game_board: GameBoard, cur_moves: List[Move]
65 Proposes moves sequentially from a list of algebraic notation moves.
68 def __init__(self, color: PieceColor, move_list: List[str]):
69 super().
__init__(color=color, player_type=PlayerType.SCRIPTED)
74 self, game_board: GameBoard, cur_moves: List[Move]
78 if not mt.is_valid_algebraic_pair(parsed_input):
81 move = mt.convert_parsed_input_to_move(parsed_input=parsed_input)
86 illegal_move: Tuple[str],
87 game_board: GameBoard,
88 cur_moves: List[Move],
95 Has intentionally illegal move in list, followed by legal move (
for tests).
98 def __init__(self, color: PieceColor, move_list: List[str]):
99 super().
__init__(color=color, player_type=PlayerType.SCRIPTED)
105 self, game_board: GameBoard, cur_moves: List[Move]
109 if not mt.is_valid_algebraic_pair(parsed_input):
112 move = mt.convert_parsed_input_to_move(parsed_input=parsed_input)
116 self, illegal_move: Move, game_board: GameBoard, cur_moves: List[Move]
124 Proposed moves selected using an implementation of core MoveEvaluator.
130 player_type: PlayerType,
131 evaluator_type: EvaluatorType,
133 MinimaxMoveEvaluator64
134 | MinimaxMoveEvaluator128
135 | RandomMoveEvaluator
139 color=color, player_type=player_type, evaluator_type=evaluator_type
146 "MinimaxMoveEvaluator64",
147 "MinimaxMoveEvaluator128",
152 self, game_board: GameBoard, cur_moves: MoveCollection
155 allowed_moves=cur_moves
160 self, illegal_move: Move, game_board: GameBoard, cur_moves: List[Move]
167 Raised when scripted player proposed move has invalid syntax.
172 algebraic_move_input: str,
173 message=
"Invalid value for proposed move ",
179 return f
"{self._algebraic_move_input} -> {self._msg}"
184 Raised when scripted player proposes an illegal move.
191 message=
"Illegal move in list provided by scripted player",
198 return f
"{self._move} -> {self._msg}\n{self._board_map}"
203 Raised when AI player proposed illegal move.
207 self, move: Move, message=
"AI player proposed an illegal move"
213 return f
"From: {self._move.start.rank}, {self._move.end.file}; To: {self._move.end.rank}, {self._move.end.file}"
Can take a turn in a Game.
Proposed moves selected using an implementation of core MoveEvaluator.
def illegal_move_notice_response(self, Move illegal_move, GameBoard game_board, List[Move] cur_moves)
def __init__(self, PieceColor color, PlayerType player_type, EvaluatorType evaluator_type,(MinimaxMoveEvaluator64|MinimaxMoveEvaluator128|RandomMoveEvaluator) move_evaluator)
SearchSummaries|None move_selection_summary(self)
Move propose_move(self, GameBoard game_board, MoveCollection cur_moves)
Uses terminal UI to propose moves.
None __init__(self, PieceColor color, PlayerType player_type)
def illegal_move_notice_response(self, Move illegal_move, GameBoard game_board, List[Move] cur_moves)
Move propose_move(self, GameBoard game_board, List[Move] cur_moves)
Raised when AI player proposed illegal move.
def __init__(self, Move move, message="AI player proposed an illegal move")
Raised when scripted player proposes an illegal move.
def __init__(self, np.array board_map, Tuple[str] move, message="Illegal move in list provided by scripted player")
Raised when scripted player proposed move has invalid syntax.
def __init__(self, str algebraic_move_input, message="Invalid value for proposed move ")
Has intentionally illegal move in list, followed by legal move (for tests).
Move propose_move(self, GameBoard game_board, List[Move] cur_moves)
def illegal_move_notice_response(self, Move illegal_move, GameBoard game_board, List[Move] cur_moves)
def __init__(self, PieceColor color, List[str] move_list)
Proposes moves sequentially from a list of algebraic notation moves.
def illegal_move_notice_response(self, Tuple[str] illegal_move, GameBoard game_board, List[Move] cur_moves)
Move propose_move(self, GameBoard game_board, List[Move] cur_moves)
def __init__(self, PieceColor color, List[str] move_list)
Enums that are only used on the Python side of the app.
Python abstract classes used by a Game.
Contains functions used to convert algebraic board notation into integer indices array notation.
Classes for terminal UI output including board representation and, messages requesting info,...