public Collection<IGameMove> validMoves(IPlayer ip,IGameState state){
  Player player=(Player)ip;
  ArrayList<IGameMove> valids=new ArrayList<IGameMove>();
  if (state.isWin()) {
    return valids;
  }
  if (state.isDraw()) {
    return valids;
  }
  TicTacToeState gameState=(TicTacToeState)state;
  TicTacToeBoard board=gameState.board();
  for (int c=0; c < board.numColumns(); c++) {
    for (int r=0; r < board.numRows(); r++) {
      Move move=interpretMove(state,c,r,player);
      if (move != null) {
        valids.add(move);
      }
    }
  }
  return valids;
}

public Collection < IGameMove > validMoves ( IPlayer ip , IGameState state ) { Player player = ( Player ) ip ; ArrayList < IGameMove > valids = new ArrayList < IGameMove > ( ) ; if ( state . isWin ( ) ) { return valids ; } if ( state . isDraw ( ) ) { return valids ; } TicTacToeState gameState = ( TicTacToeState ) state ; TicTacToeBoard board = gameState . board ( ) ; for ( int c = 0 ; c < board . numColumns ( ) ; c ++ ) { for ( int r = 0 ; r < board . numRows ( ) ; r ++ ) { Move move = interpretMove ( state , c , r , player ) ; if ( move != null ) { valids . add ( move ) ; } } } return valids ; }
return the valid moves at this board state for the given player . note that this will return an empty collection if the game is over ( win , lose or draw ) .
