Home > chess.ts > isAttacked
Checks if a square is attacked. If an attacking color is not provided, the opposite color of the piece on the square or the current turn is used. This function does not check if the attacking piece is pinned.
Signature:
export declare function isAttacked(state: Readonly<BoardState>, square: number, color?: Color): boolean;
Parameter | Type | Description |
---|---|---|
state | Readonly<BoardState> | Board state |
square | number | Square to check |
color | Color | (Optional) Color of the attacking side |
Returns:
boolean