Checking for a winning combination
It’s very easy for a human to tell if one player or the other has won a game
of tic-tac-toe: Just look for three in a row. The computer doesn’t understand
the concept of three in a row, and it needs to be taught. It’s possible to use a
complex series of if statements to check for all the possible winning combinations,
but it takes a lot of code to do this. With a little thought, you can simplify
the process tremendously. Take a look at the following code fragment: