Home Projects Research Contact Resume

Chess Bot: WuKong

A chess engine I made with a bit of personality, I'd say he's rated around 1400 on a good day.

WuKong, the chess Wukong
WuKong
Thinking...
Choose a side to begin
You capturedWukong captured
Move history

    How WuKong thinks

    Personality

    Wukong will always play the King's gambit as white and Sicilian as black if position allows, as these are his favourite openings. He will always capture en passent if possible as he likes the move very much.

    Finding legal moves

    On every turn, WuKong generates every legal move available on the board, including special moves such as castling, en passant, and promotion. This is also how checkmate and stalemate are detected. For simplicity, WuKong always promotes pawns to a queen.

    Choosing a move

    WuKong searches several moves ahead using the minimax algorithm, assuming both players make the strongest moves available. It evaluates each possible continuation and chooses the move that leads to the best overall position.

    Searching efficiently

    Looking ahead becomes increasingly expensive as the number of possible moves grows. Wukong uses alpha-beta pruning to speed things up by ignoring move sequences that don't influence the final decision. This allows him to finish his search faster. (PS: The search depth is fixed at five moves, find a tactic beyond that and you'll likely gain an advantage.)

    Evaluating positions

    WuKong judges positions using a combination of material and positional evaluation. Stronger pieces are worth more, while additional bonuses reward well-placed pieces. These values are based on classical chess principles rather than machine learning.

    Piece style

    The chess pieces are standard Unicode characters provided by your browser's fonts rather than image files, so their appearance may vary slightly between devices.

    Possible improvements

    I built WuKong as a fun project, and while he plays decent, I can still beat him fairly consistently. I'm not sure whether I should be proud that my chess skills still hold up, or disappointed that my own creation hasn't managed to beat me yet. If I ever decide to make WuKong stronger, these are some possible improvements:

    • Transposition table: Cache positions already searched, keyed by board state. Different move orders often reach the same position, and right now WuKong re-searches it from scratch every time.
    • Quiescence search: instead of stopping dead at the depth limit, keep searching capture sequences a bit further until the position settles down. Fixes the "horizon effect," where a mid-trade snapshot gets misjudged just because the cutoff landed at a bad moment.
    • Iterative deepening: search depth 1, then 2, then 3, reusing each pass to search the next one more efficiently, stopping whenever the time budget runs out. Turns a fixed search depth into an adaptive time budget.
    • Richer evaluation: Such as mobility (reward having more legal moves), pawn structure (penalize doubled/isolated pawns, reward passed pawns), would give WuKong a noticeably better long-term positional sense.
    • A different runtime entirely: compiling a C/Rust engine to WebAssembly would raw-search faster than any algorithmic tweak above (this is how browser versions of Stockfish work), at the cost of rewriting the whole engine in a different language.