public class MixedGenerator extends java.lang.Object implements IDungeonGenerator
Modifier and Type | Field and Description |
---|---|
static int |
BOX |
static int |
BOX_WALLED |
protected double[] |
carvers |
protected WeightedTable |
carverTable |
static int |
CAVE |
static int |
CAVE_FLOOR
Constant for environment tiles that are floors for a cave.
|
static int |
CAVE_WALL
Constant for environment tiles that are walls near a cave.
|
static int |
CORRIDOR_FLOOR
Constant for environment tiles that are floors for a corridor.
|
static int |
CORRIDOR_WALL
Constant for environment tiles that are walls near a corridor.
|
protected char[][] |
dungeon |
protected int[][] |
environment |
protected boolean[][] |
fixedRooms |
protected boolean |
generated |
protected int |
height |
protected boolean[][] |
marked |
protected IntVLA |
points |
IRNG |
rng |
static int |
ROOM_FLOOR
Constant for environment tiles that are floors for a room.
|
static int |
ROOM_WALL
Constant for environment tiles that are walls near a room.
|
protected float |
roomHeight |
protected float |
roomWidth |
static int |
ROUND |
static int |
ROUND_WALLED |
protected int |
totalPoints |
static int |
UNTOUCHED
Constant for environment tiles that are not near a cave, room, or corridor.
|
protected boolean[][] |
walled |
protected int |
width |
Constructor and Description |
---|
MixedGenerator(int width,
int height,
IRNG rng)
This prepares a map generator that will generate a map with the given width and height, using the given RNG.
|
MixedGenerator(int width,
int height,
IRNG rng,
java.util.List<Coord> sequence)
This prepares a map generator that will generate a map with the given width and height, using the given RNG.
|
MixedGenerator(int width,
int height,
IRNG rng,
java.util.Map<Coord,java.util.List<Coord>> connections)
This prepares a map generator that will generate a map with the given width and height, using the given IRNG.
|
MixedGenerator(int width,
int height,
IRNG rng,
java.util.Map<Coord,java.util.List<Coord>> connections,
float roomSizeMultiplier)
This prepares a map generator that will generate a map with the given width and height, using the given IRNG.
|
Modifier and Type | Method and Description |
---|---|
static OrderedSet<Coord> |
basicPoints(int width,
int height,
IRNG rng)
Mainly for internal use; this is used by
MixedGenerator(int, int, IRNG) to get its room positions. |
static java.util.List<Coord> |
cleanPoints(int width,
int height,
IRNG rng)
Mainly for internal use; this was used by
MixedGenerator(int, int, IRNG) to get its room positions, and
you can choose to use it with new MixedGenerator(width, height, rng, cleanPoints(width, height, rng)) . |
char[][] |
generate()
Uses the added carvers (or just makes caves if none were added) to carve from point to point in sequence, if it
was provided by the constructor, or evenly-spaced randomized points if it was not.
|
char[][] |
getDungeon()
Gets the most recently-produced dungeon as a 2D char array, usually produced by calling
IDungeonGenerator.generate() or
some similar method present in a specific implementation. |
int[][] |
getEnvironment() |
boolean[][] |
getFixedRooms() |
boolean |
hasGenerated() |
protected boolean |
mark(Coord pos)
Internal use.
|
protected boolean |
mark(int x,
int y)
Internal use.
|
protected void |
markEnvironment(int x,
int y,
int kind)
Internal use.
|
protected void |
markEnvironmentCave(int x,
int y)
Internal use.
|
protected void |
markEnvironmentCorridor(int x,
int y)
Internal use.
|
protected void |
markEnvironmentRoom(int x,
int y)
Internal use.
|
protected void |
markEnvironmentWalls()
Internal use.
|
protected void |
markPiercing(Coord pos)
Internal use.
|
protected void |
markPiercing(int x,
int y)
Internal use.
|
protected void |
markPiercingCave(Coord pos)
Internal use.
|
protected void |
markPiercingRoom(int x,
int y)
Internal use.
|
void |
putBoxRoomCarvers(int count)
Changes the number of "carvers" that will create right-angle corridors from one room to the next, create rooms
with a random size in a box shape at the start and end, and a small room at the corner if there is one.
|
void |
putCaveCarvers(int count)
Changes the number of "carvers" that will create caves from one room to the next.
|
void |
putRoundRoomCarvers(int count)
Changes the number of "carvers" that will create right-angle corridors from one room to the next, create rooms
with a random size in a circle shape at the start and end, and a small circular room at the corner if there is
one.
|
void |
putWalledBoxRoomCarvers(int count)
Changes the number of "carvers" that will create right-angle corridors from one room to the next, create rooms
with a random size in a box shape at the start and end, and a small room at the corner if there is one, enforcing
the presence of walls around the rooms even if another room is already there or would be placed there.
|
void |
putWalledRoundRoomCarvers(int count)
Changes the number of "carvers" that will create right-angle corridors from one room to the next, create rooms
with a random size in a circle shape at the start and end, and a small circular room at the corner if there is
one, enforcing the presence of walls around the rooms even if another room is already there or would be placed
there.
|
void |
setFixedRooms(boolean[][] fixedRooms) |
protected void |
store()
Internal use.
|
protected void |
wallOff(int x,
int y)
Internal use.
|
public static final int CAVE
public static final int BOX
public static final int ROUND
public static final int BOX_WALLED
public static final int ROUND_WALLED
public static final int UNTOUCHED
SectionDungeonGenerator
.
Present here for compatibility; you should prefer DungeonUtility.UNTOUCHED
.public static final int ROOM_FLOOR
SectionDungeonGenerator
.
Present here for compatibility; you should prefer DungeonUtility.ROOM_FLOOR
.public static final int ROOM_WALL
SectionDungeonGenerator
.
Present here for compatibility; you should prefer DungeonUtility.ROOM_WALL
.public static final int CAVE_FLOOR
SectionDungeonGenerator
.
Present here for compatibility; you should prefer DungeonUtility.CAVE_FLOOR
.public static final int CAVE_WALL
SectionDungeonGenerator
.
Present here for compatibility; you should prefer DungeonUtility.CAVE_WALL
.public static final int CORRIDOR_FLOOR
SectionDungeonGenerator
.
Present here for compatibility; you should prefer DungeonUtility.CORRIDOR_FLOOR
.public static final int CORRIDOR_WALL
SectionDungeonGenerator
.
Present here for compatibility; you should prefer DungeonUtility.CORRIDOR_WALL
.protected double[] carvers
protected WeightedTable carverTable
protected int width
protected int height
protected float roomWidth
protected float roomHeight
public IRNG rng
protected char[][] dungeon
protected boolean generated
protected int[][] environment
protected boolean[][] marked
protected boolean[][] walled
protected boolean[][] fixedRooms
protected IntVLA points
protected int totalPoints
public MixedGenerator(int width, int height, IRNG rng)
width
- the width of the final map in cellsheight
- the height of the final map in cellsrng
- an RNG object to use for random choices; this make a lot of random choices.used to ensure spacing for the points.
public MixedGenerator(int width, int height, IRNG rng, java.util.List<Coord> sequence)
width
- the width of the final map in cellsheight
- the height of the final map in cellsrng
- an RNG object to use for random choices; this make a lot of random choices.sequence
- a List of Coord to connect in order; index 0 is the start, index size() - 1 is the end.a class that uses this technique
public MixedGenerator(int width, int height, IRNG rng, java.util.Map<Coord,java.util.List<Coord>> connections)
width
- the width of the final map in cellsheight
- the height of the final map in cellsrng
- an IRNG object to use for random choices; this make a lot of random choices.connections
- a Map of Coord keys to arrays of Coord to connect to next; shouldn't connect both waysa class that uses this technique
public MixedGenerator(int width, int height, IRNG rng, java.util.Map<Coord,java.util.List<Coord>> connections, float roomSizeMultiplier)
width
- the width of the final map in cellsheight
- the height of the final map in cellsrng
- an IRNG object to use for random choices; this make a lot of random choices.connections
- a Map of Coord keys to arrays of Coord to connect to next; shouldn't connect both waysroomSizeMultiplier
- a float multiplier that will be applied to each room's width and heighta class that uses this technique
public static OrderedSet<Coord> basicPoints(int width, int height, IRNG rng)
MixedGenerator(int, int, IRNG)
to get its room positions.
This is (and was) the default for generating a List of Coord if no other collection of Coord was supplied to the
constructor. For some time this was not the default, and cleanPoints(int, int, IRNG)
was used instead.
Both are still options, but this technique seems to keep corridors shorter and makes connections between rooms
more relevant to the current area.
width
- dungeon width in cellsheight
- dungeon height in cellsrng
- rng to useused to make the list
public static java.util.List<Coord> cleanPoints(int width, int height, IRNG rng)
MixedGenerator(int, int, IRNG)
to get its room positions, and
you can choose to use it with new MixedGenerator(width, height, rng, cleanPoints(width, height, rng))
.
It produces a fairly rigid layout of rooms that should have less overlap between rooms and corridors; the
downside to this is that corridors can become extremely long. The exact technique used here is to get points from
a Halton-like sequence, formed using VanDerCorputQRNG
to get a van der Corput sequence, for the x axis
and a scrambled van der Corput sequence for the y axis. MixedGenerator will connect these points in pairs. The
current method is much better at avoiding "clumps" of closely-positioned rooms in the center of the map.
DungeonGenerator
with no
arguments (using DEFAULT_DUNGEON as the dungeon style), because the map this method produced in one case had too
few floor cells to be used.width
- dungeon width in cells; must be at least 3 because the edges will be wallsheight
- dungeon height in cells; must be at least 3 because the edges will be wallsrng
- IRNG to use, such as an RNG, StatefulRNG, or GWTRNGused to get separated positions
public void putCaveCarvers(int count)
count
- the number of carvers making caves between rooms; only matters in relation to other carverspublic void putBoxRoomCarvers(int count)
count
- the number of carvers making box-shaped rooms and corridors between them; only matters in relation
to other carverspublic void putRoundRoomCarvers(int count)
count
- the number of carvers making circular rooms and corridors between them; only matters in relation
to other carverspublic void putWalledBoxRoomCarvers(int count)
count
- the number of carvers making box-shaped rooms and corridors between them; only matters in relation
to other carverspublic void putWalledRoundRoomCarvers(int count)
count
- the number of carvers making circular rooms and corridors between them; only matters in relation
to other carverspublic char[][] generate()
generate
in interface IDungeonGenerator
public char[][] getDungeon()
IDungeonGenerator
IDungeonGenerator.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 int[][] getEnvironment()
public boolean hasGenerated()
public boolean[][] getFixedRooms()
public void setFixedRooms(boolean[][] fixedRooms)
protected void store()
protected void markEnvironmentWalls()
protected boolean mark(int x, int y)
x
- x position to marky
- y position to markprotected void markPiercing(int x, int y)
x
- x position to marky
- y position to markprotected void markEnvironment(int x, int y, int kind)
x
- x position to marky
- y position to markkind
- an int that should be one of the constants in MixedGenerator for environment types.protected void markEnvironmentCorridor(int x, int y)
x
- x position to marky
- y position to markprotected void markEnvironmentRoom(int x, int y)
x
- x position to marky
- y position to markprotected void markEnvironmentCave(int x, int y)
x
- x position to marky
- y position to markprotected void wallOff(int x, int y)
x
- x position to marky
- y position to markprotected boolean mark(Coord pos)
pos
- position to markprotected void markPiercing(Coord pos)
pos
- position to markprotected void markPiercingCave(Coord pos)
pos
- position to markprotected void markPiercingRoom(int x, int y)
x
- x coordinate of position to marky
- y coordinate of position to markCopyright © Eben Howard 2012–2022. All rights reserved.