maze.filler
Class MazeFiller

java.lang.Object
  extended bymaze.filler.MazeFiller
Direct Known Subclasses:
MazeFillerRetry, MazeFillerSimple

public abstract class MazeFiller
extends java.lang.Object

A strategy for filling a maze's cells with walls. Subclasses have different approaches to dealing with edges, collisions, turns, etc.


Field Summary
protected  double branch
          The branching factor (between 0.0 and 1.0).
protected  PushPop theOpenEnds
          The PushPop used when filling the Maze.
protected  java.util.Random theRNG
          A Random Number Generator used when filling the Maze.
 
Constructor Summary
MazeFiller()
          Constructs a new MazeFiller.
MazeFiller(PushPop p)
          Constructs a new MazeFiller with the given PushPop; either a Stack or a Queue.
MazeFiller(PushPop p, double b)
          Constructs a new MazeFiller with the given PushPop (either a Stack or a Queue) and a given branching factor between 0.0 and 1.0.
 
Method Summary
protected  void branch(Maze m, Coordinate c, int d)
          Places a random branch in the path.
 void finish(Maze m)
          Finishes the maze filling process.
 boolean next(Maze m)
          Fills the next cell.
 void start(Maze m)
          Starts filling the maze with Cells.
protected  void straight(Maze m, Coordinate c, int d)
          Places a wall because this PathEnd crossed another path.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

theOpenEnds

protected PushPop theOpenEnds
The PushPop used when filling the Maze.


theRNG

protected java.util.Random theRNG
A Random Number Generator used when filling the Maze.


branch

protected double branch
The branching factor (between 0.0 and 1.0).

Constructor Detail

MazeFiller

public MazeFiller()
Constructs a new MazeFiller. Uses a LIFO and 0.50 branching factor.


MazeFiller

public MazeFiller(PushPop p)
Constructs a new MazeFiller with the given PushPop; either a Stack or a Queue. The branching factor is 0.50.

Parameters:
p - PushPop to use, either Stack or Queue.

MazeFiller

public MazeFiller(PushPop p,
                  double b)
Constructs a new MazeFiller with the given PushPop (either a Stack or a Queue) and a given branching factor between 0.0 and 1.0.

Parameters:
p - PushPop to use, either Stack or Queue.
b - double branching factor between 0.0 and 1.0.
Method Detail

start

public void start(Maze m)
Starts filling the maze with Cells.

Parameters:
m - The Maze to fill.

next

public boolean next(Maze m)
Fills the next cell.

Parameters:
m - PathEnd where we found the collision.
Returns:
true if there are more open ends to the path.

finish

public void finish(Maze m)
Finishes the maze filling process.

Parameters:
m - The Maze to fill.

straight

protected void straight(Maze m,
                        Coordinate c,
                        int d)
Places a wall because this PathEnd crossed another path.

Parameters:
m - The Maze to fill.
c - Coordinate for the Cell.
d - int direction for the straight-through path.

branch

protected void branch(Maze m,
                      Coordinate c,
                      int d)
Places a random branch in the path.

Parameters:
m - The Maze to fill.
c - Coordinate for the Cell.
d - int direction for the straight-through path.