Move Types
NormalMove
A standard move from one square to another:DropMove
A piece drop for variants like Crazyhouse:Move Union Type
TheMove type represents either a normal move or a drop:
Type Guards
Use type guards to distinguish between move types:UCI Notation
parseUci
Parse a move from UCI notation:- Normal moves:
e2e4,g1f3 - Promotions:
e7e8q,a7a8n - Drops (Crazyhouse):
Q@f7,N@e5 - Castling:
e1g1(kingside),e1c1(queenside)
makeUci
Convert a move to UCI notation:Square Utilities
parseSquare
Parse a square from algebraic notation:makeSquare
Convert a square number to algebraic notation:squareFile and squareRank
Get the file or rank of a square:Move Comparison
moveEquals
Compare two moves for equality:Making Moves
play
Execute a move on a position (mutates the position):Move Effects
Theplay() method handles:
- Moving pieces on the board
- Capturing pieces
- Pawn promotions
- Castling (moving both king and rook)
- En passant captures
- Updating castling rights
- Updating the en passant square
- Incrementing halfmove and fullmove clocks
- Switching the turn
- Updating pockets (Crazyhouse)
- Updating remaining checks (3check)