Portfolio
All projects

PythonBeta

CogniMax

A chess engine that plays to beat a specific opponent quickly. It predicts how a player at a given rating is likely to reply and picks the move with the best expected result, instead of assuming the opponent plays perfectly.

Result

Across 4,120 games against a human-like opponent at 11 ratings from 600 to 2600, CogniMax won in a median of 22 moves, versus 27 for Stockfish searching to the same depth. It won faster at every rating (up to 31% fewer moves at 2400) and lost no games.

Bar chart of median moves to win in Run 4: CogniMax wins in fewer moves than the Stockfish control at every Elo band from 600 to 2000.

Built with

  • Python
  • PyTorch
  • python-chess
  • Stockfish
  • maia3
  • pandas
  • SciPy
  • statsmodels

The problem

Engines like Stockfish assume the opponent always finds the best reply. Against a real 1200-rated player that wastes chances, so games drag on. Training bots and game AI that play at a person's level need an engine that takes the opponent's likely mistakes into account. Put simply, the best move in general is not always the most effective one. When your opponent has a weak spot, going after it usually works better (like punching someone where they're already hurt, or a better example lol).

What I built

Research intern at the IC2 Lab, KMUTT, June to July 2026. I built the engine, designed and ran the experiments, and wrote the statistics and the scripts that recompute every number in the report from the raw games.

How it works

  • Stockfish at depth 8 proposes CogniMax's candidate moves and scores the positions.
  • maia3, a neural network trained on human games, predicts how likely the opponent is to play each reply at the target rating.
  • A 3-move-deep expectimax search combines the two and picks the move with the best expected result. A setting controls how much risk it takes.
  • In every game the opponent is maia3 at the target rating, picking moves the way a person at that level would.

Key decisions

  1. 01

    Win speed as the main measure

    Both engines won nearly every game, so the useful question was how fast each one wins.

  2. 02

    Statistics that hold up

    Bootstrap A/B tests, Holm-corrected paired tests, power analysis, and survival models, plus scripts that check every claim in the report against the raw data.

By the numbers

  • CogniMax: 2,056 wins, 4 draws, 0 losses. Stockfish: 2,030 wins, 30 draws, 0 losses.
  • Its chance of winning by any given move was 1.5 times Stockfish's at rating 600 and 2.9 times at 2400.
  • About 30,500 lines of Python for the engine, experiments, analysis, and report.

What I learned

How important it is to document everything and make sure everything can be reproduced. And to write a clear hypothesis and main goal before running anything.

Limits

The gain is for engines limited to a shallow search. CogniMax thinks about 4.4 seconds a move against Stockfish's 30 ms, and a Stockfish given the same time wins at least as fast. A reply predictor built from Stockfish alone also did as well as maia3, which the report treats as its main finding.

Gallery

Effect size at all 11 tested Elo bands, 600 to 2600, pooled across every run. The advantage holds at every band and is largest from 2200 to 2600.
Win rate by Elo band, Run 4. Both engines win nearly every game, which is why moves to win is the main measure.