“Dots”: like the Go game, but on a grid sheet, and a neural network opponent

Hello! I’m making a digital version of “Dots” — it’s a paper game that’s popular in the CIS and Poland. When I was in school, I played quite a few games of it. I’m writing it in Godot, and the main feature is the opponent — a neural network that I trained from scratch.

I’ll warn you right away: “Dots” is not the same as Dots and Boxes. Although the names are similar, this is a completely different game. The closest relative of “Dots” is Go. “Dots” is played by two people on a grid sheet. Players take turns placing dots of their own color at the intersections of the cells and try to surround the opponent’s dots. Anything that ends up inside a closed chain of your dots, spaced one cell apart (diagonals also count), is considered surrounded. You can learn the rules in two minutes, but learning to play well is not that easy. Each player weaves their own network of dots, and the game turns into a race of traps that the opponents set for each other.

Why can’t a strong opponent be programmed

I’ve long wanted to have a strong AI opponent for “Dots”. At first, it seemed that it would be possible to program an algorithm similar to the one used in chess: iterating through moves plus evaluating the position. It turned out that it wasn’t possible, and the reason was the scale. The chessboard has 64 squares, and in an average position there are about 35 possible moves. To calculate a chain of 4 moves, you need to iterate through approximately 1.5 million options — a feasible task for a computer. The classic “Dots” board is 39×32, i.e., 1,248 cells, and a move can be almost any empty cell. The same 4 moves already yield about 2 trillion options — a million times more. Moreover, a chess position is easy to evaluate based on a simple criterion: who has the stronger pieces left. “Dots” has no such criterion.

How the neural network learned

Since it’s impossible to program the evaluation of a position, let’s try to train a neural network. I took the approach of AlphaZero — a program that was taught to play Go — as a basis. The idea is this: the neural network plays thousands of games against itself and then learns from this data. A new generation of the network enters the “arena” — it plays a series of games against the previous one. If the newcomer wins more often than it loses, it takes the place of the previous one and generates games for the next generation. Currently, the 20th generation is in the game, and while I’m writing this post, an arena is going on against the 21st. I’m training the network on PyTorch using my home graphics card, an RTX 5070 Ti — one generation takes approximately 15 hours.

How it works in Godot

The game itself is written in Godot 4.7 + C#/.NET 10. The rules and game logic are pure C# without external dependencies. The neural network is trained in Python and run in C#. To do this, it is exported to ONNX — a universal format for neural networks. In the game, the model runs on the player’s GPU: DirectML on Windows, CoreML on macOS, CUDA on Linux. A special bonus: the network is convolutional — it doesn’t look at the entire field; it moves a small window across it, like a blur filter over an image in a shader. Therefore, the size of the field doesn’t matter to it: the same model plays both on a 9×9 field and on a classic 39×32 field — the size is chosen before the match. If you have questions about training the network or about integrating ONNX into Godot, ask in the thread, and I’ll share the details.

What’s ready now

The game against the AI is ready, there’s a two‑player mode on one computer, saving and viewing games, two difficulty levels, and the option to choose the board size and starting arrangement. On a 15×15 board, the “Harder” level consistently beats me. On the classic 39×32 board, the network responds in less than a second, but it’s still doesn’t play well: the training hasn’t reached this size yet — I’m gradually expanding the board sizes.

Right now, I’m preparing the game for release on Steam (only Windows for now): Just Dots on Steam. If you like the game, add it to your wishlist. This will be very helpful to me: the more people have it on their wishlist, the higher the game will rank in the Steam ratings, and the more people will see it. I’m planning to release the game in December, but if you’re interested in battling the AI, I can give you access to the beta version — message me privately.

7 Likes

What a nice clean UI. Maybe too clean. And too off-center. Did you try putting score and buttons into a top or bottom row?

Is there anything that stops you from making this multi-player just to stand out from the crowd? A agar.io like friendslop game for people with turtle-neck pullovers :smiley:
If it get’s crowded, just zoom out every few moves like Mini Metro does (and MM shows on your steam page). Took me ages to notice that zoom…

I see quite a few dots and boxes games on Google Play, no harm in looking what those with success do do.
Actually, I’m feeling inspired branching my current Voronoi graph prototype into a Dots and Polygons game :smiley:

1 Like

Hello! Thanks for the ideas!

I see quite a few dots and boxes games on Google Play, no harm in looking what those with success do.

It seems to me that you’re viewing this game as a variation of Dots and Boxes, but it’s a different game with completely different rules. Its closest relative is Go. The rules are simply, but the gameplay that grows out of them is surprisingly deep.

If you’re curious, I’d be happy to send you beta access — just DM me. Maybe you’ll discover a game you’ll really enjoy :slight_smile:

This looks really cool :fire:
The UI is so clean well done!
Keep it up

1 Like

There appear to be strategic similarities to Hex. You might want to look at approaches that have been profitable in Hex programs, for example, the use of Monte Carlo tree search. I mention this because your neural network work would give you a head start on a MCTS guided by a neural network.

I suspect virtual connections might also be a useful Hex concept.

Disclaimer: I have never played Dots, but I spent too much time working on Hex back in the early 1990’s :smiley:

More information at www.hexwiki.net/index.php/Computer_Hex

1 Like

I have published a demo version of the game. Now you can download it and play.

If you try and write a feedback, I will be very grateful.

Good evening…

Yes, I tried it, and lost (heavily..! 0-36) on the ‘Beginner’ setting. I’ll try again (yes, I can be stubborn…). One detail, please, which I deem to be of some importance : please allow the ‘Settings’ to be available from the outset, before the music etc, as it (like many other games…) starts off horrendously loud, and can’t be adjusted until one either starts to play or launches the tutorial. Please give priority to the Settings at first launch; thanks in advance. OK, I should have learnt by now to turn the sound off before opening demos of the sort, but…

Other than that, a very good game, which will provide hours of enjoyment, once I get the hang of getting at least one Blue capture..! Well done; added to my very short Steam ‘Wish List’.

1 Like

Thank you so much for trying and sharing your feedback!

can you check what value the volume slider was set to when the sound seemed very loud? according to my intention, the initial volume of the music should be 25%. I want to understand if there is a mistake in setting the volume, or if 25% is too loud.

Thanks for the reply. Keeping in mind that I’m old (very old…) and hard of hearing, to me, 25% is far too loud as an opening volume. It’s currently set at (5%..? The figure is not displayed, so…), along with the Fx. Disclaimer : I’m not playing on a laptop, but a PC, plugged into my audio interface and bookshelf monitors, so I can hear everything..!
On other news, I played again, and won, this time (36-6…)..! Not easy at all, some head scratching was required. Would it be against some sort of ‘rules’ to have captures possible at the edges of the board..? The ‘out of bounds dot’ could be considered as a sort of ‘joker’, allowing a capture from only three connections. Just an idea; I found out the hard way that it doesn’t play like that presently..!
Another detail, whilst I’m here : could the cursor either take on a colour, or have a contour, to render it more visible..? White-on-white is not, for me, the best contrast on my screen. Again, just a tiny detail, it’s still a splendid game you’ve made. Thanks again. 140 - 3p9T3qx

1 Like

U might wanna add an online multiplayer if u have time left- the idea sounds great gonna try it out as soon as i’ve time

1 Like

I found an error in the logic of setting the initial volume: the volume was set to 40% instead of 25%, as it was intended. I have made corrections and published a new version.

I also made a non-blocking message about getting to know the rules instead of a modal window. In addition, when starting the game, the music volume now increases smoothly for 1 second.

Thank you again so much for your feedback!

1 Like

Playing online is on the list of tasks that I plan to do, but right now I’m focused on increasing the power of the bot’s game on large fields.

I’m planning to release the game in December. I will try to make the game online for release or in a short time after it.

Wow! Dots is not an easy game and your perseverance commands respect!

Thanks for the idea. I will keep this option in mind, but first I would like to finish implementing the game according to the classical rules.

I understand your inconvenience. It is very easy to change the cursor. I don’t have a ready-made option in my head yet, but I promise that I will make the cursor more contrasting in the near future.

1 Like

Congrats on the trophy(s)!

1 Like

I made a trailer for the demo version. What do you think?

3 Likes

It might be a bit too chill: In the end it would be cool to show lots of games fast forward to give a better overview of the game! Also u might wanna redesign the Logo! Might be a bit too boring…