private void maxFlips() {
    if (this.currentPlayer == 0) {
      this.alert = "You must first start a game.";
    } else {
      Vector<Move> validMoves = new Vector();
      Vector<Move> bestMoves = new Vector();
      String tmpMessage = this.message;
      for (int i = 0; i < 8; i++) {
        for (int j = 0; j < 8; j++) {
          if (legalMove(i, j, this.currentPlayer, this.mainBoard)) {
            int[][] tmpBoard = copyBoard(this.mainBoard);
            if (this.currentPlayer == 1) {
              int currentScore = this.whiteScore;
              makeMove(i, j, false, this.mainBoard, this.currentPlayer);
              int scoreDiff = this.whiteScore - currentScore;
              validMoves.addElement(new Move(i, j, scoreDiff));
              this.whiteScore = currentScore;
            } else {
              int currentScore = this.blackScore;
              makeMove(i, j, false, this.mainBoard, this.currentPlayer);
              int scoreDiff = this.blackScore - currentScore;
              validMoves.addElement(new Move(i, j, scoreDiff));
              this.blackScore = currentScore;
            }
            this.mainBoard = tmpBoard;
          }
        }
      }
      this.message = tmpMessage;

      int mostFlips = 0;
      for (int i = 0; i < validMoves.size(); i++) {
        int flips = ((Move) validMoves.elementAt(i)).getNumFlips();
        if (flips > mostFlips) {
          mostFlips = flips;
        }
      }
      for (int i = 0; i < validMoves.size(); i++) {
        if (((Move) validMoves.elementAt(i)).getNumFlips() == mostFlips) {
          bestMoves.addElement((Move) validMoves.elementAt(i));
        }
      }
      int move = this.r.nextInt(bestMoves.size());
      this.currentPlayer = makeMove(((Move) bestMoves.elementAt(move)).getX(),
          ((Move) bestMoves.elementAt(move)).getY(), true, this.mainBoard,
          this.currentPlayer);
    }
  }