public class MazeBuilder implements Runnable { // Given input information: protected int width, height ; // width and height of maze, private int rooms; // requested number of rooms in maze, a room is an area with no walls larger than a single cell private int expectedPartiters; // user given limit for partiters
// Produced output information to create the new maze
// root, cells, dists, startx, starty
protected int startx ; // starting position inside maze for entity to search for exit
protected int starty;
// conventional encoding of maze as a 2 dimensional integer array encapsulated in the Cells class
// a single integer entry can hold information on walls, borders/bounds
protected Cells cells; // the internal representation of a maze as a matrix of cells
protected Distance dists ; // distance matrix that stores how far each position is away from the exit position
// cells and dists internally operate 2d arrays with same dimension and same indexing, i.e., dists(i,j) gives
// the distance to exit for a position in cell(i,j)
// class internal local variables
protected SingleRandom random ; // random number stream, used to make randomized decisions, e.g for direction to go
Order order; // describes what is wanted, e.g. a perfect maze or not
/**
* Constructor for a randomized maze generation
*/
public MazeBuilder(){
random = SingleRandom.getRandom();
}
/**
* Constructor with option to make maze generation deterministic or random
*/
public MazeBuilder(boolean deterministic){
if (true == deterministic)
{
this.random = random ;
}
random = SingleRandom.getRandom();
}
The first constructor randomly generates a maze. I need to implement code so that if MazeBuilder.build is called for the same skill level twice, it will deliver the same results. I think "this.random = random ;" in the second constructor will do this, but I'm not sure this is correct.
Aucun commentaire:
Enregistrer un commentaire