Package squidpony.squidgrid.mapping
Class GrowingTreeMazeGenerator
java.lang.Object
squidpony.squidgrid.mapping.GrowingTreeMazeGenerator
- All Implemented Interfaces:
IDungeonGenerator
public class GrowingTreeMazeGenerator extends Object implements IDungeonGenerator
A maze generator that can be configured using a
GrowingTreeMazeGenerator.ChoosingMethod, which can be customized for the app.
Based in part on code from Jamis Buck's blog.- Author:
- Eben Howard - http://squidpony.com - howard@squidpony.com
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceGrowingTreeMazeGenerator.ChoosingMethodA way to configure howgenerate(ChoosingMethod)places paths through the maze. -
Field Summary
Fields Modifier and Type Field Description char[][]dungeonGrowingTreeMazeGenerator.ChoosingMethodnewestProduces high-quality mazes that are very similar to those produced by a recursive back-tracking algorithm.GrowingTreeMazeGenerator.ChoosingMethodoldestProduces mostly straight corridors that dead-end at the map's edge; probably only useful withmix(ChoosingMethod, double, ChoosingMethod, double).GrowingTreeMazeGenerator.ChoosingMethodrandomProduces chaotic, jumbled spans of corridors that are similar to those produced by Prim's algorithm. -
Constructor Summary
Constructors Constructor Description GrowingTreeMazeGenerator(int width, int height)GrowingTreeMazeGenerator(int width, int height, IRNG rng) -
Method Summary
Modifier and Type Method Description char[][]generate()Builds and returns a 2D char array maze by usingnewestwithgenerate(ChoosingMethod).char[][]generate(GrowingTreeMazeGenerator.ChoosingMethod choosing)Builds and returns a 2D char array maze using the provided chooser method object.char[][]getDungeon()Gets the most recently-produced dungeon as a 2D char array, usually produced by callinggenerate()or some similar method present in a specific implementation.GrowingTreeMazeGenerator.ChoosingMethodmix(GrowingTreeMazeGenerator.ChoosingMethod methodA, double chanceA, GrowingTreeMazeGenerator.ChoosingMethod methodB, double chanceB)
-
Field Details
-
dungeon
-
newest
Produces high-quality mazes that are very similar to those produced by a recursive back-tracking algorithm. -
oldest
Produces mostly straight corridors that dead-end at the map's edge; probably only useful withmix(ChoosingMethod, double, ChoosingMethod, double). -
random
Produces chaotic, jumbled spans of corridors that are similar to those produced by Prim's algorithm.
-
-
Constructor Details
-
Method Details
-
getDungeon
Gets the most recently-produced dungeon as a 2D char array, usually produced by callinggenerate()or some similar method present in a specific implementation. This normally passes a direct reference and not a copy, so you can normally modify the returned array to propagate changes back into this IDungeonGenerator.- Specified by:
getDungeonin interfaceIDungeonGenerator- Returns:
- the most recently-produced dungeon/map as a 2D char array
-
generate
Builds and returns a 2D char array maze by usingnewestwithgenerate(ChoosingMethod).- Specified by:
generatein interfaceIDungeonGenerator- Returns:
dungeon, after filling it with a maze
-
generate
Builds and returns a 2D char array maze using the provided chooser method object. The most maze-like dungeons usenewest, the least maze-like useoldest, and the most jumbled userandomor a mix of others usingmix(ChoosingMethod, double, ChoosingMethod, double).- Parameters:
choosing- the callback object for making the split decision- Returns:
dungeon, after filling it with a maze
-
mix
public GrowingTreeMazeGenerator.ChoosingMethod mix(GrowingTreeMazeGenerator.ChoosingMethod methodA, double chanceA, GrowingTreeMazeGenerator.ChoosingMethod methodB, double chanceB)Mixes two ChoosingMethod values, likenewestandrandom, given a weight for each, and produces a new ChoosingMethod that randomly (respecting weight) picks one of those ChoosingMethods each time it is used.- Parameters:
methodA- the first ChoosingMethod to mix; must not be nullchanceA- the weight to favor choosing methodAmethodB- the second ChoosingMethod to mix; must not be nullchanceB- the weight to favor choosing methodB- Returns:
- a ChoosingMethod that randomly picks between
methodAandmethodBeach time it is used
-