Add java.util.random seed as initial parameter
- prepare for short save allowing to fully recreate initial lab having only seed and x,y,depth paramters
This commit is contained in:
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -16,7 +16,8 @@ public class Main
|
|||||||
|
|
||||||
public LabyMap generate2(MazeParamEditor params)
|
public LabyMap generate2(MazeParamEditor params)
|
||||||
{
|
{
|
||||||
LabyModel model = new LabyModel(params, new java.util.Random(1024L));
|
params.setSeed(1024L);
|
||||||
|
LabyModel model = new LabyModel(params);
|
||||||
model.generateWithEntry(0, 0);
|
model.generateWithEntry(0, 0);
|
||||||
|
|
||||||
final int width = params.getWidth();
|
final int width = params.getWidth();
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import java.util.Scanner;
|
|||||||
**/
|
**/
|
||||||
class MazeParamEditor implements MazeParams
|
class MazeParamEditor implements MazeParams
|
||||||
{
|
{
|
||||||
|
long seed;
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
int maxdepth;
|
int maxdepth;
|
||||||
@@ -27,6 +28,11 @@ class MazeParamEditor implements MazeParams
|
|||||||
maxdepth = console.nextInt();
|
maxdepth = console.nextInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long getSeed()
|
||||||
|
{
|
||||||
|
return seed;
|
||||||
|
}
|
||||||
|
|
||||||
public int getWidth()
|
public int getWidth()
|
||||||
{
|
{
|
||||||
return width;
|
return width;
|
||||||
@@ -51,6 +57,11 @@ class MazeParamEditor implements MazeParams
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setSeed(long seed)
|
||||||
|
{
|
||||||
|
this.seed = seed;
|
||||||
|
}
|
||||||
|
|
||||||
public File getSaveDir()
|
public File getSaveDir()
|
||||||
{
|
{
|
||||||
return labdir;
|
return labdir;
|
||||||
|
|||||||
@@ -7,6 +7,9 @@ import java.io.File;
|
|||||||
**/
|
**/
|
||||||
public interface MazeParams
|
public interface MazeParams
|
||||||
{
|
{
|
||||||
|
/** currently seed of java.util.random **/
|
||||||
|
public long getSeed();
|
||||||
|
|
||||||
public int getWidth();
|
public int getWidth();
|
||||||
|
|
||||||
public int getHeight();
|
public int getHeight();
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import java.io.File;
|
|||||||
|
|
||||||
public class MazeParamsFixed implements MazeParams
|
public class MazeParamsFixed implements MazeParams
|
||||||
{
|
{
|
||||||
|
long seed;
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
int maxdepth;
|
int maxdepth;
|
||||||
@@ -27,10 +28,16 @@ public class MazeParamsFixed implements MazeParams
|
|||||||
maxdepth=MD;
|
maxdepth=MD;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MazeParamsFixed(File saveDir, int W, int H, int MD)
|
public MazeParamsFixed(File saveDir, int W, int H, int MD, long seed)
|
||||||
{
|
{
|
||||||
name = null;
|
name = null;
|
||||||
setParams(saveDir,W,H,MD);
|
setParams(saveDir,W,H,MD);
|
||||||
|
this.seed=seed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getSeed()
|
||||||
|
{
|
||||||
|
return seed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getWidth()
|
public int getWidth()
|
||||||
|
|||||||
Reference in New Issue
Block a user