wyvern.kernel.dungeon
Class MazeGenerator

java.lang.Object
  extended bywyvern.kernel.dungeon.AbstractLevelGenerator
      extended bywyvern.kernel.dungeon.MazeGenerator

public class MazeGenerator
extends AbstractLevelGenerator

This program creates a traditional maze to specs. There is only one path which leads from the entrance to the exit. A possible add-on for later: a "damage chance" which determines the likelihood that there are missing walls. These would allow for multiple correct paths and otherwise make navigating the maze easier. If we program it to draw rubble there, it'll even be obvious that it wasn't part of the original design. The symbols used are: # A wall. If blue, an illusionary wall. + A secret door. . Open square. Part of a tunnel. < The stairwell up to the previous level. > The stairwell down to the next level.

Version:
1.0, Oct 07, 1999
Author:
Kiz, stevey

Field Summary
static int DEFAULT_DEVIATION
           
static int DEFAULT_DIFFICULTY
           
static java.lang.String DEFAULT_MAZE_FLOOR
           
static int DEFAULT_MAZE_HEIGHT
           
static java.lang.String DEFAULT_MAZE_WALL
           
static int DEFAULT_MAZE_WIDTH
           
static int DEFAULT_PHASE_CHANCE
           
static int DEFAULT_SECRET_CHANCE
           
protected  java.lang.String wall_
           
 
Fields inherited from class wyvern.kernel.dungeon.AbstractLevelGenerator
DEFAULT_HEIGHT, DEFAULT_WIDTH, floor_, height_, oobTerrain_, stairsDown_, stairsUp_, terrain_, width_
 
Constructor Summary
MazeGenerator()
           
 
Method Summary
 GameMap generate(java.lang.Class mapclass)
          Generates a new maze.
 int getDeviation()
           
 int getDifficulty()
           
 int getPhaseChance()
           
 int getSecretChance()
           
 java.lang.String getWallArchetype()
           
static void main(java.lang.String[] argv)
           
 void setDeviation(int deviation)
          The percent chance that the tunnel will choose a random direction instead of continuing in the same direction.
 void setDifficulty(int difficulty)
          This value determines how far away from the entrance the exit will lie.
 void setHeight(int height)
          Sets the height to use next time a maze is generated.
 void setPhaseChance(int chance)
          The odds (of 1000) that a given corridor ends in a "phase wall"- a barrier that appears and disappears at random but which otherwise appears to be a normal wall.
 void setSecretChance(int chance)
          The odds (of 1000) that a given corridor ends in a "false wall" (a secret door).
 void setWallArchetype(java.lang.String arch)
          Archetype to use for the walls between corridors.
 void setWidth(int width)
          Sets the width to use next time a maze is generated.
 
Methods inherited from class wyvern.kernel.dungeon.AbstractLevelGenerator
getDefaultTerrain, getDownstairArchetype, getFloorArchetype, getHeight, getOOBTerrain, getUpstairArchetype, getWidth, instantiateFloor, instantiateObject, rand, setDefaultTerrain, setDownstairArchetype, setFloorArchetype, setOOBTerrain, setUpstairArchetype
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_MAZE_WIDTH

public static final int DEFAULT_MAZE_WIDTH
See Also:
Constant Field Values

DEFAULT_MAZE_HEIGHT

public static final int DEFAULT_MAZE_HEIGHT
See Also:
Constant Field Values

DEFAULT_MAZE_FLOOR

public static final java.lang.String DEFAULT_MAZE_FLOOR
See Also:
Constant Field Values

DEFAULT_MAZE_WALL

public static final java.lang.String DEFAULT_MAZE_WALL
See Also:
Constant Field Values

DEFAULT_DIFFICULTY

public static final int DEFAULT_DIFFICULTY
See Also:
Constant Field Values

DEFAULT_DEVIATION

public static final int DEFAULT_DEVIATION
See Also:
Constant Field Values

DEFAULT_SECRET_CHANCE

public static final int DEFAULT_SECRET_CHANCE
See Also:
Constant Field Values

DEFAULT_PHASE_CHANCE

public static final int DEFAULT_PHASE_CHANCE
See Also:
Constant Field Values

wall_

protected java.lang.String wall_
Constructor Detail

MazeGenerator

public MazeGenerator()
Method Detail

setDifficulty

public void setDifficulty(int difficulty)
This value determines how far away from the entrance the exit will lie. At 100, it lies at the end of the furthest PATH from the entrance. At 50, it lies halfway along, etc. Note that PATH != real distance. It's how long it would take to get there, following the maze. Generally, you'll want difficulty to be 100, unless there is scattered treasure to encourage further exploration once the exit is found.

Parameters:
difficulty - 1-100

getDifficulty

public int getDifficulty()

setDeviation

public void setDeviation(int deviation)
The percent chance that the tunnel will choose a random direction instead of continuing in the same direction. The larger this value, the more regular the maze will be and the fewer turns.

Parameters:
deviation - 0-100

getDeviation

public int getDeviation()

setPhaseChance

public void setPhaseChance(int chance)
The odds (of 1000) that a given corridor ends in a "phase wall"- a barrier that appears and disappears at random but which otherwise appears to be a normal wall. Or perhaps these could be coded as illusionary walls. Regardless, there shouldn't be many of them- they make the maze terribly hard.

Parameters:
chance - 0-1000

getPhaseChance

public int getPhaseChance()

setSecretChance

public void setSecretChance(int chance)
The odds (of 1000) that a given corridor ends in a "false wall" (a secret door). Once discovered and opened, these stay open- but they do make solving the maze a major pain.

Parameters:
chance - 0-1000

getSecretChance

public int getSecretChance()

setWallArchetype

public void setWallArchetype(java.lang.String arch)
Archetype to use for the walls between corridors.

Parameters:
arch - the arch local path, e.g "walls/house_wall".

getWallArchetype

public java.lang.String getWallArchetype()

setWidth

public void setWidth(int width)
Sets the width to use next time a maze is generated.

Overrides:
setWidth in class AbstractLevelGenerator
Parameters:
width - the new width; must be ODD.
Throws:
java.lang.IllegalArgumentException - if width is even or negative

setHeight

public void setHeight(int height)
Sets the height to use next time a maze is generated.

Overrides:
setHeight in class AbstractLevelGenerator
Parameters:
height - the new height; must be ODD.
Throws:
java.lang.IllegalArgumentException - if height is even or negative

generate

public GameMap generate(java.lang.Class mapclass)
                 throws java.lang.Exception
Generates a new maze.

Specified by:
generate in class AbstractLevelGenerator
Parameters:
mapclass - the class to instantiate
Throws:
java.lang.Exception

main

public static void main(java.lang.String[] argv)