It is possible to create a computer_move method which plays a perfect game of tic tac toe. A perfect game of tic tac toe from the computer's perspective is that it always wins when there is an opportunity to win and it never loses (NEVER LOSES). Rewriting the computer_move method so that a perfect game of tic tac toe is always played by the computer is beyond the scope of this lesson, but we can play a pretty good game.
The only modifications to the applet to implement improved intelligence (in terms of move selection) need to be made in the computer_move method. We will not implement a perfect move algorithm here. If you are interested in a perfect move algorithm you can do a little research into the minimax algorithm and alpha-beta pruning.
Here is the altered computer_move method:
ASSIGNMENT:
Use the moves array to shorten the code for the winner method.