Game Utils
Utility functions for chess game logic, including move application, check detection, attack detection, and insufficient material checks.
Overview
Provides methods for applying moves, detecting checks, evaluating attacks, and determining insufficient material.
Designed to work with the chessboard and game state objects.
Move Application
makeMove: Applies a move to the board and updates the game state.
Check Detection
isKingInCheck: Determines if the king of a given color is in check.
Attack Detection
isSquareAttackedBy: Checks if a square is attacked by pieces of a specific color.
Material Evaluation
hasInsufficientMaterial: Determines if the board position has insufficient material for checkmate.
Example Usage
val newState = GameUtils.makeMove(board, gameState, move)
val isCheck = GameUtils.isKingInCheck(PieceColor.WHITE, board)
val isAttacked = GameUtils.isSquareAttackedBy(square, PieceColor.BLACK, board)
val insufficientMaterial = GameUtils.hasInsufficientMaterial(board)Functions
Checks if the given board position has insufficient material for either player to checkmate.
Determines if a square is attacked by any piece of attackerColor on the board.