Tic Tac Toe
- 5 Devlogs
- 9 Total hours
A trained Tic Tac Toe agent that you can play against.
A trained Tic Tac Toe agent that you can play against.
Made the agent a little less predictable and gave the site an actual style pass.
The agent now plays a random move 7.5% of the time instead of always going for its best known move, so games don’t play out the same way every time.
Then did the styling I mentioned wanting to do: added a “your turn / agent’s turn” indicator, a short pause before the agent’s move shows up on the board (with a click guard so you can’t sneak in an extra move during that pause), and reworked the colors and spacing on the board, the reset button, and the title.
Starting to feel like a real little site instead of just a board with squares.
Moved the game into the browser.
Built a web version with HTML, CSS, and JS, it loads the trained Q-table straight from the JSON file and picks the agent’s move client side, no server needed. Click a cell to play as X, the agent answers as O.
Also retrained the table with a small tweak, new board states now start at -0.1 instead of 0, and wrapped the training code so importing train.py doesn’t kick off a training run by accident. The old CLI script is retired now that the browser version covers the same thing.
It works but looks plain right now, next up is actually styling it properly.
You can now actually play against the trained agent, from the terminal.
Added a CLI script where a human plays against the agent, the agent picks its moves greedily off the Q-table instead of exploring. Cleaned up the board printing with separators so it’s easier to read between turns while playing.
Right now it’s just a command line game. A full UI is the plan for later.
Swapped the random-move players for actual Q-learning.
Instead of both sides just picking randomly, moves now come from an epsilon-greedy policy: mostly pick the best known move for the current board state, occasionally pick a random one to keep exploring. Added state encoding (board from the current player’s perspective, so X and O see it the same way), a Q-value table, and updates after every move based on the reward (win, loss, or draw).
Also added saving and loading the trained table to q_table.json so training runs don’t have to start from zero, train.py now loads it in on startup.
Next step is actually building a playable UI.
Started a tic-tac-toe project with a random-move simulator.
Built the basic board logic first: a 9-cell board, printing it out, checking valid moves, and checking for a winner across all 8 win lines.
Then wired up two players who just pick random moves and play until someone wins or it’s a draw. Ran it for 10 games in a row and printed the result of each one.
Nothing fancy yet, just the scaffolding to build the real thing on top of.