King (model.pieces.king)¶
model.pieces.king
¶
King chess piece implementation with 8-direction step movement and castling state.
King
¶
Bases: Piece
King chess piece with 1-square movement in any of 8 directions and moved-state tracking.
Source code in src/model/pieces/king.py
__init__(color, piece_type='king')
¶
Initialize a King piece.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
color
|
int
|
Color identifier (1 for White, -1 for Black). |
required |
piece_type
|
str
|
Piece type descriptor (default: "king"). |
'king'
|
Source code in src/model/pieces/king.py
hasMoved()
¶
Check whether the King has moved from its starting position.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the King has moved, False otherwise. |
setMoved(moved=True)
¶
Update the King's moved state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
moved
|
bool
|
Movement flag value (default: True). |
True
|