Chapter 13

AI for Games – Become the Master at Snake

This is the last practical chapter; congratulations on finishing the previous ones! I hope you really enjoyed them. Now, let's leave aside business problems and self-driving cars. Let's have some fun by playing a popular game called Snake and making an AI that teaches itself to play this game!

That's exactly what we'll do in this chapter. The model we'll implement is called deep convolutional Q-learning, using a Convolutional Neural Network (CNN).

Our AI won't be perfect, and it won't fill in the entire map, but after some training it will start playing at a level comparable with humans.

Let's start tackling this problem by looking at what the game looks like and what the target is.

Problem ...

Get AI Crash Course now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.