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)
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.
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
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
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