Version Four:
1. Maintains features of versions one and two
2. Unlike version 3, moves are pre-ordered
Talk about STUPID!
Changes to computer_move method:
public void computer_move() { int i=0; int j=0; if(position[1][1]==EMPTY) { j=1; i=1; } else if(position[0][2]==EMPTY) { j=0; i=2; } else if(position[2][0]==EMPTY) { j=2; i=0; } else if(position[2][2]==EMPTY) { j=2; i=2; } else if(position[1][2]==EMPTY) { j=1; i=2; } else if(position[2][1]==EMPTY) { j=2; i=1; } else if(position[0][1]==EMPTY) { j=0; i=1; } else if(position[0][0]==EMPTY) { j=0; i=0; } else if(position[1][0]==EMPTY) { j=1; i=0; } //could just be else... position[j][i]=COMPUTER; win(); TURN=HUMAN; }
Def.java - convenient way of making common variables available to t4 and TicTacToe without having to type them into each.
//All purpose integer values interface def{ public static final int YES=1; public static final int NO=0; public static final int EMPTY=0; public static final int COMPUTER=1; public static final int HUMAN=2; }