public class MimicFill
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static boolean[][] |
boulders
Predefined sample; many small separate squares.
|
static boolean[][] |
cave
Predefined sample; a large, enclosed, organic space that usually makes large cave-like rooms,
|
static boolean[][] |
caves
Predefined sample; several medium-sized organic spaces that usually make tight, chaotic tunnels.
|
static boolean[][] |
chess
Predefined sample; a checkerboard pattern that typically loses recognition as such after generation.
|
static boolean[][] |
lessRooms
Predefined sample; produces rectangular rooms with small corridors between them.
|
static boolean[][] |
maze
Predefined sample; produces a suitable filler for a maze (but it is unlikely to connect both ends like a maze).
|
static boolean[][] |
openRooms |
static boolean[][] |
quarterBlack
Predefined sample; produces weird, large areas of "true" and "false" that suddenly change to the other.
|
static boolean[][] |
river
Predefined sample; produces multiple directions of flowing, river-like shapes made of "false".
|
static boolean[][] |
rooms
Predefined sample; produces rectangular rooms with a dense packing.
|
static boolean[][] |
ruins |
static boolean[][][] |
samples |
static boolean[][] |
simpleMaze
Predefined sample; produces an uncanny imitation of a maze with a tiny sample size.
|
static boolean[][] |
simpleRooms
Predefined sample; produces mostly rectangular rooms with very few corridor-like areas.
|
static boolean[][] |
thickWalls
Predefined sample; produces largely rectangular rooms with a good amount of thin corridors.
|
Modifier and Type | Method and Description |
---|---|
static boolean[][] |
andSamples(boolean[][] left,
boolean[][] right)
Runs a logical AND on each pair of booleans at the same position in left and right, and returns the result of all
the AND operations as a 2D boolean array (using the minimum dimensions shared between left and right).
|
static boolean[][] |
fill(boolean[][] sample,
int size,
double temperature,
int iterations,
IRNG random)
The main part of MimicFill; generates a 2D boolean array that mimics the patterns present in the 2D boolean array
sample, but can produce a larger or smaller output 2D array than the sample.
|
static boolean[] |
fillSolo(boolean[][] sample,
int size,
double temperature,
int iterations,
IRNG random)
The main part of MimicFill; generates a 1D boolean array that, when used correctly, mimics the patterns present
in the 2D boolean array sample, but can produce a larger or smaller output 1D array than the sample.
|
static boolean[][] |
mapToSample(char[][] map,
char... yes)
Converts a 2D char array map to a 2D boolean array, where any chars in the array or vararg yes will result in
true in the returned array at that position and any other chars will result in false.
|
static boolean[][] |
markSample(boolean[][] sample,
java.lang.Iterable<Coord> points)
Given a 2D boolean array sample (usually a final product of this class' fill() method) and an Iterable of Coord
(such as a List or Set of Coord, but a Region can also work), copies sample, then marks every Coord in points as
true if it is in-bounds, and returns the modified copy of sample.
|
static boolean[][] |
orSamples(boolean[][] left,
boolean[][] right)
Runs a logical OR on each pair of booleans at the same position in left and right, and returns the result of all
the OR operations as a 2D boolean array (using the minimum dimensions shared between left and right).
|
static char[][] |
sampleToMap(boolean[][] sample,
char yes,
char no)
Converts a 2D boolean array to a 2D char array, where false means the parameter no and true the parameter yes.
|
static char[][] |
sampleToMap(boolean[] sample,
int width,
int height,
char yes,
char no)
Converts a 1D boolean array to a 2D char array, where false means the parameter no and true the parameter yes.
|
public static final boolean[][] boulders
public static final boolean[][] cave
public static final boolean[][] caves
public static final boolean[][] chess
public static final boolean[][] lessRooms
public static final boolean[][] maze
public static final boolean[][] quarterBlack
public static final boolean[][] river
public static final boolean[][] rooms
public static final boolean[][] simpleMaze
public static final boolean[][] simpleRooms
public static final boolean[][] thickWalls
public static final boolean[][] ruins
public static final boolean[][] openRooms
public static final boolean[][][] samples
public static boolean[][] mapToSample(char[][] map, char... yes)
map
- a 2D char array that you want converted to a 2D boolean arrayyes
- an array or vararg of the chars to consider true in mappublic static char[][] sampleToMap(boolean[][] sample, char yes, char no)
sample
- a 2D boolean array that you want converted to a 2D char arrayyes
- true in sample will be mapped to this char; usually '.'no
- false in sample will be mapped to this char; usually '#'public static char[][] sampleToMap(boolean[] sample, int width, int height, char yes, char no)
sample
- a 1D boolean array that you want converted to a 2D char arraywidth
- the desired width of the 2D char arrayheight
- the desired height of the 2D char arrayyes
- true in sample will be mapped to this char; usually '.'no
- false in sample will be mapped to this char; usually '#'public static boolean[][] orSamples(boolean[][] left, boolean[][] right)
left
- a 2D boolean arrayright
- another 2D boolean arraypublic static boolean[][] andSamples(boolean[][] left, boolean[][] right)
left
- a 2D boolean arrayright
- another 2D boolean arraypublic static boolean[][] markSample(boolean[][] sample, java.lang.Iterable<Coord> points)
sample
- a 2D boolean array; will be copied, not modified directlypoints
- an Iterable (such as a List or Set) of Coord that will be marked as true if in-boundspublic static boolean[][] fill(boolean[][] sample, int size, double temperature, int iterations, IRNG random)
DiverRNG
) is fine, and in most cases MiniMover64RNG
will
be reasonably good for quality while probably being slightly faster. On GWT, GWTRNG
is a good choice due to how few operations on long
values it needs to do, and GWT has a hard time with
longs; the algorithm used by GWTRNG can also produce all but one possible long value.sample
- a 2D boolean array to mimic visually; you can use mapToSample() if you have a 2D char arraysize
- the side length of the square boolean array to generatetemperature
- typically 0.2 works well for this, but other numbers between 0 and 1 may workiterations
- typically 3-5 works well for this; lower numbers may have slight problems with quality,
and higher numbers make this slightly slowerrandom
- an RNG to use for the random components of this techniquepublic static boolean[] fillSolo(boolean[][] sample, int size, double temperature, int iterations, IRNG random)
sampleToMap(boolean[], int, int, char, char)
to get a 2D char array or producing a GreasedRegion with it
using GreasedRegion(boolean[], int, int)
. Both the width and height
used to interpret the 1D array as a 2D array should be equal to the size parameter passed here. The main reason
you would prefer this method over fill(boolean[][], int, double, int, IRNG)
is that this overload is
somewhat faster due to slightly less-frequent RNG calls and a lot less nested array reading and writing.
DiverRNG
) is fine, and in most cases MiniMover64RNG
will
be reasonably good for quality while probably being slightly faster. On GWT, GWTRNG
is a good choice due to how few operations on long
values it needs to do, and GWT has a hard time with
longs; the algorithm used by GWTRNG can also produce all but one possible long value.sample
- a 2D boolean array to mimic visually; you can use mapToSample() if you have a 2D char arraysize
- the side length of the square boolean array to generatetemperature
- typically 0.2 works well for this, but other numbers between 0 and 1 may workiterations
- typically 3-5 works well for this; lower numbers may have slight problems with quality,
and higher numbers make this slightly slowerrandom
- an RNG to use for the random components of this techniqueCopyright © Eben Howard 2012–2022. All rights reserved.