In part 2, I used Gemini Canvas to add difficulty settings so the Omok prototype could actually be played.
Part 1: https://soonsoon.io/google-gemini-canvas-ai-prototyping-omok-game-making-part-1/
Part 2: https://soonsoon.io/https-soonsoon-io-google-gemini-canvas-ai-prototyping-omok-game-making-part-2/
This time I wanted to add a different algorithm and turn it into a simulation game where two AIs battle each other.
In this article, I add an extra layer of intelligence to the existing AI by combining the original score-based system with the widely used minimax algorithm from Omok, then make the two approaches compete.
< Image source: Google DeepMind >
Minimax is a decision rule used in artificial intelligence, decision theory, combinatorial game theory, statistics, and philosophy to minimize the possible loss in the worst-case scenario. When dealing with gains, it is sometimes called “maximin,” meaning maximizing the minimum gain. It was originally formalized for zero-sum multiplayer games, but has since been extended to more complex games and general decision-making under uncertainty. — Source: Wikipedia
First, I put together a basic version to confirm that an algorithm-versus-algorithm battle could actually be implemented.
The existing algorithm simply calculated a score for each open position and tried to place a stone where the score would be highest. This time, the goal was to add a minimax algorithm so the AI could look several moves ahead.
I also wanted to add a parameter called Luck, allowing the probability of the algorithm triggering to vary so that the AI could have something closer to character stats.
If you want to try this yourself, continue from the previous article and enter the following prompt.
✅ Prompt
Create a UI for AI settings and implement the basic flow where the AIs place stones one after another.
Requirements:
Create setting areas for “AI 1 (black)” and “AI 2 (white).” Each section should include the following two controls.
Intelligence selection: add buttons for “Score-Based” and “Minimax.”
Luck (accuracy) selection: add a slider adjustable from 0% to 100%.
Game flow: when the “Start AI Battle” button is pressed, the two AIs should begin by taking turns placing stones in random empty cells.
Game over: when either side places five stones in a row, the game should end and display a full-screen victory message with a “Play Again” button.
In practice, the UI may come out slightly differently in Gemini Canvas each time. That seems to be one of the limits of AI coding.
It was implemented right away, and I could confirm that the stones were being placed correctly. After that, I moved on to the next step.
✅ Prompt
Now implement the “intelligence” algorithms so the AI can make smarter moves.
Requirements:
When “Score-Based” is selected in the settings panel, the AI should calculate offensive and defensive scores for each empty cell and choose the best available position.
When “Minimax” is selected, the AI should look several moves ahead and, in particular, prioritize blocking any immediate winning move where the opponent already has four stones in a row.
For now, ignore the “Luck (accuracy)” slider and always choose the best computed move.
You can clearly see the two AIs taking turns attacking and defending while playing Omok.
Now that the algorithms were working, I decided to make the game feel a little more game-like by adding human-like mistakes to the AI.
Luck 100%
Luck 70%
Now you can see the AI stats change depending on the Luck setting, and it begins to feel at least somewhat like an actual game.
At 100%, the AIs traded only draws, but the moment Luck was lowered, black won immediately, which fits the natural first-move advantage of Omok.
After building out these AI patterns, I started thinking carefully about why that was happening.
The score-based AI always tries to take the most favorable immediate position on its turn, while minimax calculates the best answer after the opponent moves and therefore behaves more defensively. Because of that difference, the win rate shifts depending on whether the AI moves first or second.
The score-based AI is focused on immediate gain, so it quickly picks the best move available in the current board state. The minimax AI, by contrast, simulates what happens if it places a stone in a given position, predicts the opponent’s likely response, and then chooses a move that leads to a better result.
If you wanted something that thinks dozens of moves ahead like a professional player, the number of cases the AI must evaluate would explode exponentially, which becomes very difficult to implement smoothly in a web environment. The current minimax version only looks a few moves ahead, so the win-rate difference is probably a result of keeping the logic light enough to run comfortably in the browser.
You can watch the overall creation process in the video below.
This experiment helped me understand both the limits and the possibilities of AI prototyping at the same time.
Because the AI can code things so quickly, it becomes easy to rapidly implement an idea you want to test and use that process to identify what is not working and what needs more concrete thought.
Looking at this article, two issues stand out in particular:
- Black always has the advantage, and that imbalance needs to be addressed.
- If Omok is driven only by scores and move prediction, the game starts to feel repetitive.
In other words, if you want to build an AI core that feels more like something a person would actually play, you still have a lot more design thinking to do.
AI can absolutely help solve part of this, but at the same time I think humans still need to think more carefully, design the logic more deliberately, and give AI clearer direction.
To summarize: AI can think quickly, implement quickly, and present humans with many possibilities. But because it also has a tendency to drift away from the original goal, analyzing and judging things properly at the right moment still feels like a human responsibility for now.
In the next part, I want to push the simulation even further so it feels more like playing against an actual strong Omok player.