public void copy(Maze maze) {
    this.start = this.cells[maze.getStart().getY()][maze.getStart().getX()];
    this.goal = this.cells[maze.getGoal().getY()][maze.getGoal().getX()];

    if (maze.w != this.w || maze.h != this.h) {
      throw new IllegalArgumentException();
    }

    for (int y = 0; y < this.h; y++) {
      for (int x = 0; x < this.w; x++) {
        this.cells[y][x].copyConfiguration(maze.getMazeCell(x, y));
      }
    }
  }
  @Override
  public Maze clone() {
    Maze maze = null;
    try {
      maze = (Maze) super.clone();
    } catch (CloneNotSupportedException e) {
    }

    maze.w = this.w;
    maze.h = this.h;

    maze.cells = new MazeCell[this.h][this.w];
    for (int y = 0; y < this.h; y++) {
      for (int x = 0; x < this.w; x++) {
        maze.cells[y][x] = this.cells[y][x].clone();
      }
    }

    maze.start = maze.cells[this.start.y][this.start.x];
    maze.goal = maze.cells[this.goal.y][this.goal.x];

    return maze;
  }