How can I create AI for tic tac toe in Python using ANN and the genetic algorithm?

I am very interested in machine learning and I recently got an idea for a project over the next few weeks.
Basically, I want to create an AI that can defeat every person in Tic Tac Toe. The algorithm should be scalable for each size n * n of the board and, possibly, even for other dimensions (for example, for a 3D analogue of the game).
Also, I do not want the algorithm to know anything about the game in advance: it must learn by itself. So there are no hard-coded ifs and training is not controlled.
My idea is to use an artificial neural network for the most important algorithm and train it using a genetic algorithm. Therefore, I should only encode the rules of the game, and then every population fighting with itself should learn from scratch.
This is a big project, and I am not an expert in this field, but I hope, with such a goal, to learn a lot of things.

  • First, is it possible ? I mean, is it possible to achieve a good result in a reasonable amount of time?
  • Are there any good libraries in Python that I can use for this project? And is Python a suitable language for such a project?
+6
source share
1 answer

Yes it is possible. But you have to tell your AI the rules of the game in advance (well, that’s debatable, but it’s supposedly better if you do this - it will determine your search space a little better).

Now playing with a vanilla tick-wheelbarrow is too simple - a minmax search will be more than enough. Scaling the dimension or the size of the board makes the case of more advanced algorithms, but even in this case, the search space is quite simple (the algebraic nature of the increase in dimension leads to a small transformation of the search space, which should be amenable to simpler methods).

If you really want to throw heavy machine learning into a problem, take a second look at chess (Deep Blue really just rudely forced a suction cup). Arimaa is also interesting for this application. You can also consider searching (maybe start with some work done on AlphaGo)

What are my two cents worth

+2
source

All Articles