Wednesday, 9 July 2025

Noughts and Crosses - simple JavaScript game created with AI

Your turn (X)





Development Notes


Gotta start small, right? So I started with the smallest game project I could think of - noughts and crosses, or "Tic-Tac-Toe", if you prefer. Since the visuals are extremely basic and the game logic is about as simple as it gets, not to mention that AI knew the rules without me having to tell it, getting an initial mockup was ridiculously easy. What took a little more effort was fine-tuning the AI opponent - even though (apart from the "unbeatable" level - draw on that to see a quote from War Games, an 80s movie I love) , it was basically a case of combining randomn placement and probability weighting to make the best moves (obviously, the easier the opponent, the lower the probability of it choosing the best move).

Then things like adding choices (difficulty level, who goes first) and how the game responds to game-ending events. It's very simple, but quite playable. I was glad I started with this as it was easy but also very informative as to how to structure the next, more ambitious project.

This game took 8 prompt iterations to reach the final stage. With prompting, testing and thinking time, I guess it took about an hour to put together. There is scope to expand it but I'm not really planning to (although I may possible get it updated to work better on mobile devices) as this was absolutely just a learning project and the real fun will be trying to create a game with a unique ruleset. 

No comments:

Post a Comment