I know the most basic rudimentary theory on AI, and I want to delve into actual practical coding with AI and machine learning. I already know a decent bit of coding in C++ and I'm learning Python syntax now.

I think I want to start implementing artificial intelligence techniques for simple games (like snake or maybe chess, which isn't really a simple game, but I know a lot about it), and then move on to more complex methods and algorithms.

So, what are some resources (e.g. tutorials, guides, books, etc.) for coding some artificial intelligence techniques in the context of games?

  • 3
    $\begingroup$ I don't know if it's enough for an answer, but if you're not already aware of it, Gym is probably the best introductory tool out there to train intelligent agents for games. $\endgroup$ Apr 10, 2020 at 13:51
  • 1
    $\begingroup$ You can check out Sutton and Bartos book on RL, it has a chapter on games (prior knowledge about RL is required) and also this video youtu.be/N1LKLc6ufGY $\endgroup$
    – user9947
    Apr 10, 2020 at 16:41

1 Answer 1


One of the simplest games you could solve with an AI technique is tic-tac-toe, which is a very simple game. To solve it, you could use minimax or alpha-beta pruning (an extension of minimax), which are very basic but fundamental search techniques for two-player games, so minimax can be applied not only to tic-tac-toe but any two-player game.

The notes CS 161 Recitation Notes - Minimax with Alpha-Beta Pruning provide a decent overview (with a concrete example) of alpha-beta pruning, which may be a little bit confusing at the beginning, but it is a relatively simple search technique that you can grasp with a few reading iterations (but take this with a grain of salt because the time and effort that it takes to learn something strongly depends on your knowledge and experience). There are several tutorials online that show how to implement minimax and alpha-beta pruning for tic-tac-toe. I could list them all, but I think it's better you look for them and choose your favorite. Maybe have a look at this implementation.

Of course, when it comes to games, one cannot forget about reinforcement learning. I cannot currently list any good tutorials, but there are many resources online. You can even apply RL to tic-tac-toe, so this may be your next step. As someone mentioned in the comments, OpenAI's gym is an RL library for implementing RL agents, which can be used to solve many games, so you should definitely have a look at it. OpenAI's gym comes with a nice introduciton, especially if you are already familiar with RL, which, of course, you probably should before trying to use it. In principle, you can apply RL to many games, including chess, snake, etc.

There's also a book entitled Clever Algorithms: Nature-Inspired Programming Recipes by Jason Brownlee that describes numerous AI techniques, some of them could, in principle, be applied to games too. The book is concise and relatively clear. It also comes with the implementation (in Ruby, which is a language similar to Python) of all of the algorithms presented in it.

To conclude, although this site is not appropriate for recommendations, I recommend you first get familiar with fundamental search techniques, such as minimax and alpha-beta pruning, then you could start learning RL, which can be applied to many games. There are many resources online for both of them.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .