public void reverseMove( Move moveToUndo ) {
      int x1 = moveToUndo.x1;
      int y1 = moveToUndo.y1;
      int x2 = moveToUndo.x2;
      int y2 = moveToUndo.y2;
      nextPlayerToMove = opponent(nextPlayerToMove);
      // move piece back
      moveToUndo.piece.x = x1;
      moveToUndo.piece.y = y1;
      //revert board to previous state
      mBoard[x1][y1] = mBoard[x2][y2];
      mBoard[x2][y2] = moveToUndo.captured;
      
      int playerID = mBoard[x1][y1];
      addToLinesOfAction(moveToUndo.x1, moveToUndo.y1);
      // If we are only moving one mBoard up, down or left, right need to ensure
      // that the quadcounts do not get off.
      Piece quad_list = null;
      if (Math.abs(x1 - x2) == 1 && (y1 - y2) == 0) {
        int max_row = Math.max(x1, x2);
        quad_list = new Piece(max_row, y1, playerID);
        quad_list.next = new Piece(max_row, y1 + 1, playerID);
      } else if ((x1 - x2) == 0 && Math.abs(y1 - y2) == 1) {
        int max_col = Math.max(y1, y2);
        quad_list = new Piece(x1, max_col, playerID);
        quad_list.next = new Piece(x1 + 1, max_col, playerID);
      }
      for (Piece p = quad_list; p != null; p = p.next)
        quadcount[playerID][quad[playerID][p.x][p.y]]++;

      // QUAD
      subtractQuad_numbers(x1, y1, playerID);
      subtractQuad_numbers(x2, y2, playerID);

      // Now update the quad information, will update through the methods
      // instead of expending memory
      removeQuad(x2, y2, playerID);
      addQuad(x1, y1, playerID);

      if (moveToUndo.captured != EMPTY_SQUARE) {
        piece_list[moveToUndo.captured] = addPiece(piece_list[moveToUndo.captured], moveToUndo.captured_piece);
        subtractQuad_numbers(x2, y2, moveToUndo.captured);
        addQuad(x2, y2, moveToUndo.captured);
        addQuad_numbers(x2, y2, moveToUndo.captured);
      } else
        subtractLines(x2, y2);

      addQuad_numbers(x2, y2, playerID);
      addQuad_numbers(x1, y1, playerID);
      for (Piece p = quad_list; p != null; p = p.next)
        quadcount[playerID][quad[playerID][p.x][p.y]]--;
     // System.out.println("Move reversed");
    }