Chess
Play Chess against an AI opponent powered by a rule-based engine. Choose from three CPU strategies — Random, Smart, or Best — and sharpen your game.
How to Play Chess
- Select a side to play as (White, Black, PvP, or CPU). In CPU mode the AI controls both sides.
- Choose a CPU strategy for each AI side: Smart plays principled chess with variety, Best always picks the strongest move, Random picks any legal move.
- Click a piece to select it; valid moves highlight on the board. Click a highlighted square to move.
- The game detects check, checkmate, and stalemate automatically — a banner announces the result.
- Click Reset at any time to start a new game with the same settings.
Frequently Asked Questions
- What CPU strategies are available?
- Smart follows the rule-based AI priority order and picks randomly among moves with similar positional scores — strong but varied. Best always picks the single highest-scored move for the top-priority rule — the strongest and most consistent play. Random picks any legal move with no rules or scoring — completely unpredictable.
- Can two humans play on the same device?
- Yes — select PvP mode and pass the device between turns.
- Does the game support castling and en passant?
- Yes. All standard chess rules are implemented including castling, en passant, and automatic pawn promotion to Queen.
- How does the rule-based AI work?
- The AI scores every legal move using piece-square tables, then evaluates a priority-ordered rule list — checkmate, escaping a mate threat, promoting to Queen, safe captures ordered by piece value, castling, giving check, centre control, and development. The highest-priority rule that matches any move decides the choice, and the position score picks the strongest move within that rule.
- Why does the AI refuse a free-looking capture?
- Captures are ranked by what they win and what they risk. Taking a pawn with a piece that can then be captured is a losing trade, so those moves sit near the bottom of the rule list — below simply making a safe move. The AI would rather decline material than hand back more than it wins.
- Does the AI repeat moves or shuffle pieces?
- It actively avoids it. Every candidate move is checked for repetition and for oscillation — a piece bouncing between the same two squares — and those moves are filtered out of the ordinary rules, so the CPU keeps making progress instead of stalling.