Game Development Reference
In-Depth Information
Summary: Creating Game-Playing Artificial
Intelligences
Creating a program that can play a game comes down to carefully considering all the
possible situations the AI can be in and how it should respond in each of those situations.
Our Tic Tac Toe AI is fairly simple because there are not many possible moves in Tic Tac
Toe compared to a game like chess or checkers.
Our AI simply blocks the players move if the player is about to win. If the player is not
about to win, it checks if any possible move can allow itself to win. Then the AI simply
chooses any available corner space, then the center space, then the side spaces. This is a
simple algorithm for the computer to follow.
The key to implementing our AI is by making copies of the board data and simulating
moves on the copy. That way, the AI code can see if a move will result in a win or loss.
Then the AI can make that move on the real board. This type of simulation is very effective
at predicting what is a good move or not.
Search WWH ::




Custom Search