Files
artloglaby/java/org/artisanlogiciel/games/Main.java
philippe lhardy afeafc1ec8 honor run option with a default maze of 30x30
default_args in project
Display.main()
  if argument is empty ignore it
  if file read fails, exit
add a WHEREWHAT file
extract MazeParamEditor to share it, prepare for having a GUI instead of console
2016-06-23 22:07:50 +02:00

60 lines
1.9 KiB
Java

package org.artisanlogiciel.games;
import java.util.LinkedList;
import java.util.Scanner;
public class Main
{
public MazeParamEditor editor()
{
MazeParamEditor editor = new MazeParamEditor(null);
System.out.println("enter width height and maxdepth");
Scanner console = new Scanner(System.in);
editor.read(console);
return editor;
}
public WallsProvider generate(int width, int height, int maxdepth, MazeResolutionListener listener)
{
LabyModel model = new LabyModel(width, height, maxdepth, new java.util.Random());
model.generateWithEntry(0, 0);
LinkedList<Position> exits = new LinkedList<Position>();
model.addEntryOrExit(-1, 0);
model.addEntryOrExit(width, height - 1);
if (!model.check())
{
System.out.println("Check failed");
}
model.resolve(width - 1, height - 1, listener);
return model;
}
public LabyMap generate2(int width, int height, int maxdepth)
{
LabyModel model = new LabyModel(width, height, maxdepth, new java.util.Random(1024L));
model.generateWithEntry(0, 0);
LinkedList<Position> exits = new LinkedList<Position>();
model.addEntryOrExit(-1, 0);
model.addEntryOrExit(width, height - 1);
System.out.println(model.toLabyMap().toString());
if (!model.check())
{
System.out.println("Check failed");
}
model.debugOut();
model.resolve(width - 1, height - 1, null);
LabyMap labyMap = model.toLabyMap();
return labyMap;
}
public static void main(String pArgs[])
{
Main m = new Main();
MazeParamEditor editor = m.editor();
LabyMap map = m.generate2(editor.width, editor.height, editor.maxdepth);
System.out.println(map.toShortString());
System.out.println(map.toString());
System.out.println(Brick.getDirLine());
}
}