public class GrowingTreeMazeGenerator extends java.lang.Object implements IDungeonGenerator
GrowingTreeMazeGenerator.ChoosingMethod
, which can be customized for the app.
Based in part on code from
Jamis Buck's blog.
This defaults to newest
for its ChoosingMethod, but random
is also good to try; you can specify a
ChoosingMethod with generate(ChoosingMethod)
.Modifier and Type | Class and Description |
---|---|
static interface |
GrowingTreeMazeGenerator.ChoosingMethod
A way to configure how
generate(ChoosingMethod) places paths through the maze. |
Modifier and Type | Field and Description |
---|---|
char[][] |
dungeon |
GrowingTreeMazeGenerator.ChoosingMethod |
newest
Produces high-quality mazes that are very similar to those produced by a recursive back-tracking algorithm.
|
GrowingTreeMazeGenerator.ChoosingMethod |
oldest
Produces mostly straight corridors that dead-end at the map's edge; probably only useful with
mix(ChoosingMethod, double, ChoosingMethod, double) . |
GrowingTreeMazeGenerator.ChoosingMethod |
random
Produces chaotic, jumbled spans of corridors, often with dead-ends, that are similar to those produced by Prim's
algorithm.
|
Constructor and Description |
---|
GrowingTreeMazeGenerator(int width,
int height) |
GrowingTreeMazeGenerator(int width,
int height,
IRNG rng) |
Modifier and Type | Method and Description |
---|---|
char[][] |
generate()
Builds and returns a 2D char array maze by using
newest with generate(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 calling
generate() or
some similar method present in a specific implementation. |
GrowingTreeMazeGenerator.ChoosingMethod |
mix(GrowingTreeMazeGenerator.ChoosingMethod methodA,
double chanceA,
GrowingTreeMazeGenerator.ChoosingMethod methodB,
double chanceB)
|
public char[][] dungeon
public final GrowingTreeMazeGenerator.ChoosingMethod newest
┌─────┬───────┬───┬─────────┬─────┬───┐ │.....│.......│...│.........│.....│...│ │.────┘.┌──.│.│.│.└───┐.┌──.│.──┐.│.│.│ │.......│...│.│.│.....│.│...│...│.│.│.│ │.──────┤.──┤.│.└─┬──.│.└─┐.└─┐.│.│.│.│ │.......│...│.│...│...│...│...│.│.│.│.│ ├─────┐.├──.│.└─┐.└─┐.├──.├─┐.│.│.│.│.│ │.....│.│...│...│...│.│...│.│...│...│.│ │.│.──┘.│.──┼───┼──.│.│.──┤.└───┼───┘.│ │.│.....│...│...│...│.│...│.....│.....│ │.└─┬───┴─┐.└─┐.│.┌─┘.│.│.└───┐.│.──┬─┤ │...│.....│...│...│...│.│.....│.│...│.│ ├──.│.┌──.│.──┴───┤.──┴─┤.──┐.│.└─┐.│.│ │...│.│...│.......│.....│...│.│...│.│.│ │.┌─┴─┘.│.├─┐.│.┌─┴───┐.├───┘.│.│.│.│.│ │.│.....│.│.│.│.│.....│.│.....│.│.│.│.│ │.│.┌───┘.│.│.└─┘.──┐.│.│.┌───┘.│.│.│.│ │...│.......│.......│.....│.....│.....│ └───┴───────┴───────┴─────┴─────┴─────┘
public final GrowingTreeMazeGenerator.ChoosingMethod oldest
mix(ChoosingMethod, double, ChoosingMethod, double)
.
┌─┬─┬─┬─┬─┬─┬─┬───────────────────────┐ │.│.│.│.│.│.│.│.......................│ │.│.│.│.│.│.│.│.──────────────────────┤ │.│.│.│.│.│.│.│.......................│ │.│.│.│.│.│.│.│.──────────────────────┤ │.│.│.│.│.│.│.│.......................│ │.│.│.│.│.│.│.│.──────────────────────┤ │.........│.│.│.......................│ ├────────.│.│.│.──────────────────────┤ │.....................................│ ├────────────.│.──────────────────────┤ │.............│.......................│ ├────────────.│.──────────────────────┤ │.............│.......................│ ├────────────.│.│.────────────────────┤ │.............│.│.....................│ ├────────.│.│.│.│.────────────────────┤ │.........│.│.│.│.....................│ └─────────┴─┴─┴─┴─────────────────────┘
public final GrowingTreeMazeGenerator.ChoosingMethod random
newest
using
mix(ChoosingMethod, double, ChoosingMethod, double)
, and not as well when mixed with oldest
.
┌─────────────┬───────────┬───────────┐ │.............│...........│...........│ ├─┬─┬─┬────.┌─┘.┌─┐.──┐.──┤.──┐.──┐.│.│ │.│.│.│.....│...│.│...│...│...│...│.│.│ │.│.│.└─┬──.│.┌─┘.└─┐.└─┬─┘.──┴───┤.│.│ │.│.│...│...│.│.....│...│.........│.│.│ │.│.└─┐.└─┐.│.│.┌─┬─┤.┌─┤.──┐.────┴─┼─┤ │.....│...│.....│.│.│.│.│...│.......│.│ ├────.├──.└──.──┘.│.└─┘.│.──┴─┐.│.──┘.│ │.....│...........│...........│.│.....│ ├────.└──.│.│.│.──┘.──────────┴─┴─┐.──┤ │.........│.│.│...................│...│ ├──────.│.│.│.│.────────────────┐.└─┬─┤ │.......│.│.│.│.................│...│.│ ├────.│.│.│.│.├─┬─┐.│.│.│.──┐.──┴───┘.│ │.....│.│.│.│.│.│.│.│.│.│...│.........│ │.┌──.├─┴─┴─┘.│.│.└─┴─┴─┴─┐.└─┐.│.│.│.│ │.│...│...................│...│.│.│.│.│ └─┴───┴───────────────────┴───┴─┴─┴─┴─┘
public GrowingTreeMazeGenerator(int width, int height)
public GrowingTreeMazeGenerator(int width, int height, IRNG rng)
public char[][] getDungeon()
generate()
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.getDungeon
in interface IDungeonGenerator
public char[][] generate()
newest
with generate(ChoosingMethod)
.generate
in interface IDungeonGenerator
dungeon
, after filling it with a mazepublic char[][] generate(GrowingTreeMazeGenerator.ChoosingMethod choosing)
newest
, the least maze-like use oldest
, and the most jumbled use random
or a
mix of others using mix(ChoosingMethod, double, ChoosingMethod, double)
.choosing
- the callback object for making the split decisiondungeon
, after filling it with a mazepublic GrowingTreeMazeGenerator.ChoosingMethod mix(GrowingTreeMazeGenerator.ChoosingMethod methodA, double chanceA, GrowingTreeMazeGenerator.ChoosingMethod methodB, double chanceB)
newest
and random
, given a weight for each, and produces
a new ChoosingMethod that randomly (respecting weight) picks one of those ChoosingMethods each time it is used.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 methodBmethodA
and methodB
each time it is usedCopyright © Eben Howard 2012–2022. All rights reserved.