5 (4)

5 (4)

#### Overview of this book

Welcome to the Robot World … and start building intelligent software now! Through his best-selling video courses, Hadelin de Ponteves has taught hundreds of thousands of people to write AI software. Now, for the first time, his hands-on, energetic approach is available as a book. Starting with the basics before easing you into more complicated formulas and notation, AI Crash Course gives you everything you need to build AI systems with reinforcement learning and deep learning. Five full working projects put the ideas into action, showing step-by-step how to build intelligent software using the best and easiest tools for AI programming, including Python, TensorFlow, Keras, and PyTorch. AI Crash Course teaches everyone to build an AI to work in their applications. Once you've read this book, you're only limited by your imagination.
Preface
Free Chapter
Welcome to the Robot World
Python Fundamentals – Learn How to Code in Python
AI Foundation Techniques
Your First AI Model – Beware the Bandits!
AI for Sales and Advertising – Sell like the Wolf of AI Street
Welcome to Q-Learning
AI for Logistics – Robots in a Warehouse
Going Pro with Artificial Brains – Deep Q-Learning
AI for Autonomous Vehicles – Build a Self-Driving Car
AI for Business – Minimize Costs with Deep Q-Learning
Deep Convolutional Q-Learning
AI for Games – Become the Master at Snake
Recap and Conclusion
Other Books You May Enjoy
Index

# Building the environment

This time, as opposed to some of the other practical sections in this book, we don't have to specify any variables or make any assumptions. We can just go straight to the three crucial steps present in every deep Q-learning project:

1. Defining the states
2. Defining the actions
3. Defining the rewards

Let's begin!

## Defining the states

In every previous example, our states were a 1D vector that represented some values that define the environment. For example, for our self-driving car we had the information gathered from the three sensors around the car and the car's position. All of these were put into a single 1D array.

But what if we want to make something slightly more realistic? What if we want the AI to see and gather information from the same source as we do? Well, that's what we'll do in this chapter. Our AI will see exactly the same board as we see when playing Snake!

The state...