Babylon JS Tic-Tac-Toe Challenge

Tic-Tac-Toe – one of the most ancient board games in human history. It is also the classic programming exercise, an instance of an m,n,k-game, where two players alternate taking turns on an m×n board until one of them gets k in a row.

With the help of Babylon JS it is now possible to visualize and play, for example, tic-tac-toe in 3x3x3 cube; or to put the board onto the surface of cylinder (or even torus knot), or use another numerous 3D variations of this game. It is real fun!

So the Tic-Tac-Toe challenge is open!

Meanwhile meet Babylon JS Tic-Tac-Toe #1 – classic version, rough and dirty, but with particles (and some animation too) :slight_smile:

https://playground.babylonjs.com/#2WR12Z#2

7 Likes

Love yours already!

3 Likes

OMG! Was this based on that other forum post? :heart_eyes: You beat me to it. Love it!

2 Likes

I can’t wait to post my cylinder one. :smiley: Thanks for doing this. So cool!

1 Like

One could think about 3x3x3 or 4x4x4 etc. game interface (how to make inner moves) - it is not the trivial task!

This is really nice but do you think you could make the AI player a bit more challenging. It seems to often pick the worst choice of option to counter my move and winning is just too easy.

1 Like

Currently AI moves are random; it is possible to make AI more “clever” (even unbeatable, if AI will move first, as we know from the game theory).
Here is very good article about JS minimax algorithm - https://alialaa.com/blog/tic-tac-toe-js-minimax
I didn’t implement it here since it is actually a quick draft and the game is too simple. But it definitely will be very interesting to use in more complex versions, for example in 3x3x3 board, as well as in other games where one needs a good and strong AI.
Still my version is good for very small kids - if they will think they will always win :slight_smile:

1 Like

Easy and cool!

1 Like

Here is the unbeatable version - https://yuka.babylonpress.org/examples/js/graph/tictactoe/ :slight_smile:

Thanks for sharing. It’s much better indeed. Now, the only problem is the game doesn’t offer enough possibilities. I couldn’t beat the AI out of 10 games… but then, it always ended up the same :stuck_out_tongue_winking_eye:


Edit: Forgot to mention that Yuka always begins the same (in the top left corner). It could at least alternate between corners to make it a bit more varied (at least, visually :wink: