deepCopy method

ChessBoardInterface deepCopy()

Returns a deep copy of the current ChessBoardInterface instance.

Implementation

ChessBoardInterface deepCopy() {
  ChessBoardInterface newBoard = ChessBoardInterface(fen: fen);
  for (int row = 0; row < 8; row++) {
    for (int col = 0; col < 8; col++) {
      newBoard.board[row][col] = board[row][col];
    }
  }
  newBoard.turn = turn;
  newBoard.enPassantTarget = enPassantTarget;
  newBoard.history = List.from(history);
  newBoard.redoHistory = List.from(redoHistory);
  return newBoard;
}