public void undoMove(PGNMove move) {
    if (move.isQueenSideCastle()) {
      switch (move.getColor()) {
      case Color.WHITE:
        move("d1", "a1");
        move("c1", "e1");
        break;
      case Color.BLACK:
        move("d8", "a8");
        move("c8", "e8");
        break;
      }
    } else if (move.isKingSideCastle()) {
      switch(move.getColor()) {
      case Color.WHITE:
        move("f1", "h1");
        move("g1", "e1");
        break;
      case Color.BLACK:
        move("f8", "h8");
        move("g8", "e8");
        break;
      }
    } else if (move.isEndGameMarked()) {
      // Do nothing
    } else {
      // Just a regular move
      int fromSquareColor = getPieceColor(move.getToSquare()) == WHITE ? BLACK : WHITE;
      move(move.getToSquare(), move.getFromSquare());
      if (move.isCaptured()) {
        byte capturedPiece =
            ((Integer) ChessConstants.pieceTextMap.get(move.getCapturedPiece())).byteValue();
        capturedPiece += fromSquareColor;
        int[] toSquareCoords = convertAlgebraicToCoordinate(move.getToSquare());
        board[toSquareCoords[0]][toSquareCoords[1]] = capturedPiece;
      }
    }
    
  }