Introduction
In the previous lesson, we understood the significance of an intelligent agent. We also examined the game states for a game AI. In this lesson, we will focus on how to create and introduce intelligence into an agent.
We will look at reducing the number of states in the state space and analyze the stages that a game board can undergo and make the environment work in such a way that we win. By the end of this lesson, we will have a Tic-Tac-Toe player who never loses a match.
Exercise 4: Teaching the Agent to Win
In this exercise, we will see how the steps needed to win can be reduced. We will be making the agent that we developed in the previous lesson detect situations where it can win a game. Compare the number of possible states to the random play as an example.
We will be defining two functions, ai_move and all_moves_from_board. We will create ai_move so that it returns a move that will consider its own previous moves. If the game can be won in that move, ai_move will select...