Game Development Reference
In-Depth Information
10 - Tic Tac Toe
Figure 10-4: The five steps of the "Get computer's move" algorithm.
The arrows leaving go to the "Check if computer won" box.
We will implement this algorithm as code in our
getComputerMove()
function, and
the other functions that
getComputerMove()
calls.
How the Code Works: Lines 1 to 81
Now that we know about how we want the program to work, let's look at what each line
does.
The Start of the Program
1. # Tic Tac Toe
2.
3. import random
The first couple of lines are a comment and importing the
random
module so we can
use the
randint()
function in our game.