/////// RandomMove.java /////// public class RandomMove extends TicStrategy { // strategy used here: // a random multiplier (mult) relatively prime to 9 // is used to go through the moves and find the first // open position public int move(int self, int opponent) { int amove=TicGame.NOMOVE; int mult = 0; while ( mult % 9 == 0 ) mult = (int) (100.0*Math.random()); for (int i = 0 ; i < 9 ; i++) { int m = moves[(i*mult)%3], mv = (1 << m); if ( ((self|opponent) & mv) == 0) // open square return m; } return amove; // no move found } }