Pawn (model.pieces.pawn)¶
model.pieces.pawn
¶
Pawn chess piece implementation with forward steps and diagonal capture vectors.
Pawn
¶
Bases: Piece
Pawn piece with forward movement, diagonal capture, and 2-step first advance.
Attributes:
| Name | Type | Description |
|---|---|---|
_initial_vectors |
Move vectors for the two-square initial pawn push. |
|
_has_moved |
Boolean tracking if the pawn has left its starting rank. |
Source code in src/model/pieces/pawn.py
__init__(color, piece_type='pawn')
¶
Initialize a Pawn piece.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
color
|
Any
|
Color identifier (1 for White, -1 for Black). |
required |
piece_type
|
str
|
Piece descriptor (default: "pawn"). |
'pawn'
|
Source code in src/model/pieces/pawn.py
getInitialVectors()
¶
Return the vectors available on the pawn's first move.
Returns:
| Type | Description |
|---|---|
List[Tuple[int, int]]
|
List[Tuple[int, int]]: List containing the 2-square advance vector. |
hasMoved()
¶
Check whether the pawn has moved from its initial square.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the pawn has moved, False otherwise. |
setMoved(moved=True)
¶
Set whether the pawn has moved.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
moved
|
bool
|
New moved state boolean (default: True). |
True
|