chessai.tour.piece

 1import chessai.core.coordinate
 2import chessai.core.piece
 3import chessai.core.types
 4
 5UNICODE_PIECE_SYMBOLS: dict[str, str] = {
 6    "O": "●", "o": "○",
 7    "T": "🞋", "t": "◎",
 8}
 9
10class Rock(chessai.core.piece.Piece, symbols = ('O', 'o')):
11    """ The rock piece in tour, which cannot move or be captured. """
12
13    _move_vectors: list[chessai.core.piece.MoveVector] = []
14
15    def symbol(self) -> str:
16        if (self.color == chessai.core.types.Color.WHITE):
17            return 'O'
18
19        return 'o'
20
21    def unicode_symbol(self) -> str:
22        return UNICODE_PIECE_SYMBOLS[self.symbol()]
23
24    def move_vectors(self) -> list[chessai.core.piece.MoveVector]:
25        return self._move_vectors
26
27class Target(chessai.core.piece.Piece, symbols = ('T', 't')):
28    """ The target piece in tour, which cannot move. """
29
30    _move_vectors: list[chessai.core.piece.MoveVector] = []
31
32    def symbol(self) -> str:
33        if (self.color == chessai.core.types.Color.WHITE):
34            return 'T'
35
36        return 't'
37
38    def unicode_symbol(self) -> str:
39        return UNICODE_PIECE_SYMBOLS[self.symbol()]
40
41    def move_vectors(self) -> list[chessai.core.piece.MoveVector]:
42        return self._move_vectors
UNICODE_PIECE_SYMBOLS: dict[str, str] = {'O': '●', 'o': '○', 'T': '🞋', 't': '◎'}
class Rock(chessai.core.piece.Piece):
11class Rock(chessai.core.piece.Piece, symbols = ('O', 'o')):
12    """ The rock piece in tour, which cannot move or be captured. """
13
14    _move_vectors: list[chessai.core.piece.MoveVector] = []
15
16    def symbol(self) -> str:
17        if (self.color == chessai.core.types.Color.WHITE):
18            return 'O'
19
20        return 'o'
21
22    def unicode_symbol(self) -> str:
23        return UNICODE_PIECE_SYMBOLS[self.symbol()]
24
25    def move_vectors(self) -> list[chessai.core.piece.MoveVector]:
26        return self._move_vectors

The rock piece in tour, which cannot move or be captured.

def symbol(self) -> str:
16    def symbol(self) -> str:
17        if (self.color == chessai.core.types.Color.WHITE):
18            return 'O'
19
20        return 'o'

Gets the symbol for the piece. Upper-case symbols are white pieces and lower-case symbols are black pieces.

def unicode_symbol(self) -> str:
22    def unicode_symbol(self) -> str:
23        return UNICODE_PIECE_SYMBOLS[self.symbol()]

Gets the Unicode character for the piece.

def move_vectors(self) -> list[chessai.core.piece.MoveVector]:
25    def move_vectors(self) -> list[chessai.core.piece.MoveVector]:
26        return self._move_vectors

Returns the movement vectors for this piece.

class Target(chessai.core.piece.Piece):
28class Target(chessai.core.piece.Piece, symbols = ('T', 't')):
29    """ The target piece in tour, which cannot move. """
30
31    _move_vectors: list[chessai.core.piece.MoveVector] = []
32
33    def symbol(self) -> str:
34        if (self.color == chessai.core.types.Color.WHITE):
35            return 'T'
36
37        return 't'
38
39    def unicode_symbol(self) -> str:
40        return UNICODE_PIECE_SYMBOLS[self.symbol()]
41
42    def move_vectors(self) -> list[chessai.core.piece.MoveVector]:
43        return self._move_vectors

The target piece in tour, which cannot move.

def symbol(self) -> str:
33    def symbol(self) -> str:
34        if (self.color == chessai.core.types.Color.WHITE):
35            return 'T'
36
37        return 't'

Gets the symbol for the piece. Upper-case symbols are white pieces and lower-case symbols are black pieces.

def unicode_symbol(self) -> str:
39    def unicode_symbol(self) -> str:
40        return UNICODE_PIECE_SYMBOLS[self.symbol()]

Gets the Unicode character for the piece.

def move_vectors(self) -> list[chessai.core.piece.MoveVector]:
42    def move_vectors(self) -> list[chessai.core.piece.MoveVector]:
43        return self._move_vectors

Returns the movement vectors for this piece.