Plans for a chess/taikyoku shogi/what have you engine |
Links | RSS | |
| Author | ArgentumCation | Posts | Notes |
|---|---|---|---|
| License | CC-BY-NC-SA 4.0+ | Updated | |
3. Move Validation System
Separate move generation into layers:
Layer 1: Basic Move Patterns
getPseudoLegalMoves(piece, position)
- Returns all squares the piece could move to
- Ignores check/pin considerations
- Each piece type has its own logic
Layer 2: Board-Aware Filtering
getLegalMoves(piece, position, gameState)
- Filters pseudoLegal moves
- Checks if king would be in check after move
- Handles special moves (castling, en passant)
En Passant
enPassantTarget to the square it passed throughCastling
hasMoved flag on kings and rooksPawn Promotion
isSquareAttacked(x, y, byColor, gameState)
- Critical for check detection
- Generate all opponent moves, see if any target this square
isKingInCheck(color, gameState)
- Find king position
- Use isSquareAttacked
makeMove(from, to, gameState)
- Validate move is legal
- Update board
- Handle captures
- Update en passant state
- Toggle current player
- Add to move history (for undo)
getGameStatus()
- Returns: 'playing', 'check', 'checkmate', 'stalemate', 'draw'