public class MazeBuilder implements Runnable {
// 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();
}
第一个构造函数随机产生一个迷宫。我需要实现代码,以便如果两次调用MazeBuilder.build相同的技能级别,它将提供相同的结果。我认为“this.random = random”在第二个构造函数中会这样做,但我不确定这是否正确。如何在java中生成两次相同的随机序列?
什么是SingleRandom? –
你的意思是使用相同的**随机种子**吗? –
通常你使用相同的种子。 –