public class MultiSpill
extends java.lang.Object
implements java.io.Serializable
start(List, int, Collection)
, which returns an ArrayList of the
different separate spills, with each spill as its own ArrayList of Coord, or may want the all-at-once final result
of all cells that received a spill and which point spilled out onto each given area, which is filled into
spillMap
when start(List, int, Collection)
is called.
PoliticalMapper
to assign claims to territory by nations or other factions, and
helps ensure that the edges of territories are naturally-shaped.
Modifier and Type | Field and Description |
---|---|
protected GreasedRegion |
anyFreshMap
The cells that are filled by the any spiller will be true, others will be false.
|
protected GreasedRegion |
anySpillMap
The cells that are filled by the any spiller will be true, others will be false.
|
int |
filled
The amount of cells filled by this Spill, which may be less than the volume passed to start() if the boundaries
are reached on all sides and the Spill has no more room to fill.
|
int |
height
Height of the map.
|
Measurement |
measurement
This affects how distance is measured on diagonal directions vs.
|
boolean[][] |
physicalMap
Stores which parts of the map are accessible (with a value of true) and which are not (with a value of false,
including both walls and unreachable sections of the map).
|
IRNG |
rng
The IRNG used to decide how to randomly fill a space; can have its state set and read.
|
short[][] |
spillMap
The cells that are filled by the a spiller with index n when it reaches its volume or limits will be equal to n;
others will be -1.
|
java.util.ArrayList<java.util.ArrayList<Coord>> |
spreadPattern
Each key here is an initial point for a spiller passed to start(), and each value corresponds to a list of points
that the spiller will randomly fill, starting with the key, in order of when they are reached.
|
int |
width
Width of the map.
|
Constructor and Description |
---|
MultiSpill()
Construct a Spill without a level to actually scan.
|
MultiSpill(char[][] level)
Constructor meant to take a char[][] returned by DungeonBoneGen.generate(), or any other
char[][] where '#' means a wall and anything else is a walkable tile.
|
MultiSpill(char[][] level,
char alternateWall)
Constructor meant to take a char[][] returned by DungeonBoneGen.generate(), or any other
char[][] where one char means a wall and anything else is a walkable tile.
|
MultiSpill(char[][] level,
Measurement measurement)
Constructor meant to take a char[][] returned by DungeonBoneGen.generate(), or any other
char[][] where '#' means a wall and anything else is a walkable tile.
|
MultiSpill(char[][] level,
Measurement measurement,
IRNG random)
Constructor meant to take a char[][] returned by DungeonBoneGen.generate(), or any other
char[][] where '#' means a wall and anything else is a walkable tile.
|
MultiSpill(IRNG random)
Construct a Spill without a level to actually scan.
|
MultiSpill(IStatefulRNG random)
Construct a Spill without a level to actually scan.
|
MultiSpill(long state)
Construct a Spill without a level to actually scan.
|
MultiSpill(short[][] level)
Used to construct a Spill from the output of another.
|
MultiSpill(short[][] level,
Measurement measurement)
Used to construct a Spill from the output of another, specifying a distance calculation.
|
MultiSpill(short[][] level,
Measurement measurement,
IRNG random)
Used to construct a Spill from the output of another, specifying a distance calculation and RNG.
|
Modifier and Type | Method and Description |
---|---|
MultiSpill |
initialize(char[][] level)
Used to initialize or re-initialize a Spill that needs a new PhysicalMap because it either wasn't given
one when it was constructed, or because the contents of the terrain have changed permanently (not if a
creature moved; for that you pass the positions of creatures that block paths to scan() or findPath() ).
|
MultiSpill |
initialize(char[][] level,
char alternateWall)
Used to initialize or re-initialize a Spill that needs a new PhysicalMap because it either wasn't given
one when it was constructed, or because the contents of the terrain have changed permanently (not if a
creature moved; for that you pass the positions of creatures that block paths to scan() or findPath() ).
|
MultiSpill |
initialize(short[][] level)
Used to initialize or re-initialize a Spill that needs a new PhysicalMap because it either wasn't given
one when it was constructed, or because the contents of the terrain have changed permanently.
|
void |
reset()
Resets this Spill to a state with an empty spillMap and an empty spreadPattern.
|
void |
resetCell(Coord pt)
Reverts a cell to an unfilled state (false in spillMap).
|
void |
resetCell(int x,
int y)
Reverts a cell to an unfilled state (false in spillMap).
|
void |
resetMap()
Resets the spillMap to being empty.
|
protected void |
setFresh(int idx,
Coord pt) |
protected void |
setFresh(int idx,
int x,
int y) |
java.util.ArrayList<java.util.ArrayList<Coord>> |
start(java.util.List<Coord> entries,
int volume,
java.util.Collection<Coord> impassable)
Recalculate the spillMap and return the spreadPattern.
|
java.util.ArrayList<java.util.ArrayList<Coord>> |
start(OrderedMap<Coord,java.lang.Double> entries,
int volume,
java.util.Collection<Coord> impassable)
Recalculate the spillMap and return the spreadPattern.
|
public Measurement measurement
public boolean[][] physicalMap
public short[][] spillMap
protected GreasedRegion anySpillMap
protected GreasedRegion anyFreshMap
public java.util.ArrayList<java.util.ArrayList<Coord>> spreadPattern
public int height
public int width
public int filled
public IRNG rng
public MultiSpill()
public MultiSpill(IRNG random)
random
- an RNG that will be converted to a StatefulRNG if it is not one alreadypublic MultiSpill(long state)
state
- the state to use for this class' random number generatorpublic MultiSpill(IStatefulRNG random)
GWTRNG
instead of the default
StatefulRNG
if optimal performance on GWT is desirable at the expense of some performance on desktop.
If you use this constructor, you must call an initialize() method before using this class.random
- an IStatefulRNG that will be used exactly, without copyingpublic MultiSpill(short[][] level)
level
- a short[][] that should have been the spillMap of another MultiSpillpublic MultiSpill(short[][] level, Measurement measurement)
level
- a short[][] that should have been the spillMap of another MultiSpillmeasurement
- a Spill.Measurement that should usually be MANHATTANpublic MultiSpill(short[][] level, Measurement measurement, IRNG random)
level
- a short[][] that should have been the spillMap of another MultiSpillmeasurement
- a Spill.Measurement that should usually be MANHATTANpublic MultiSpill(char[][] level)
level
- a char[][] that should use '#' for walls and '.' for floorspublic MultiSpill(char[][] level, char alternateWall)
level
- a char[][] that should use alternateWall for walls and '.' for floorsalternateWall
- the char to use for wallspublic MultiSpill(char[][] level, Measurement measurement)
level
- a char[][] that should use '#' for walls and '.' for floorsmeasurement
- a Spill.Measurement that should usually be MANHATTANpublic MultiSpill(char[][] level, Measurement measurement, IRNG random)
level
- a char[][] that should use '#' for walls and '.' for floorsmeasurement
- a Spill.Measurement that should usually be MANHATTANrandom
- an RNG that will be converted to a StatefulRNG if it is not one alreadypublic MultiSpill initialize(short[][] level)
level
- a short[][] that should have been the spillMap of another MultiSpillpublic MultiSpill initialize(char[][] level)
level
- a char[][] that should use '#' for walls and '.' for floorspublic MultiSpill initialize(char[][] level, char alternateWall)
level
- a char[][] that should use alternateWall for walls and '.' for floorsalternateWall
- the char to use for wallspublic void resetMap()
public void reset()
public void resetCell(int x, int y)
x
- the x-component of the Coord to revert to an unfilled statey
- the y-component of the Coord to revert to an unfilled statepublic void resetCell(Coord pt)
pt
- the Coord to revert to an unfilled stateprotected void setFresh(int idx, int x, int y)
protected void setFresh(int idx, Coord pt)
public java.util.ArrayList<java.util.ArrayList<Coord>> start(java.util.List<Coord> entries, int volume, java.util.Collection<Coord> impassable)
entries
- the first cell for each spiller to spread from, which should really be passable.volume
- the total number of cells to attempt to fill; if negative will fill the whole map.impassable
- a Collection, ideally a Set or GreasedRegion, holding Coord items representing the locations of
moving obstacles to a fill that cannot be moved through; null means no obstacles exist.public java.util.ArrayList<java.util.ArrayList<Coord>> start(OrderedMap<Coord,java.lang.Double> entries, int volume, java.util.Collection<Coord> impassable)
entries
- key: the first cell for each spiller to spread from. value: the bias toward advancing this key;
1.0 will always advance, 0.0 will never advance beyond the key, in between will randomly choosevolume
- the total number of cells to attempt to fill; if negative will fill the whole map.impassable
- a Collection, ideally a Set or GreasedRegion, holding Coord items representing the locations of
moving obstacles to a fill that cannot be moved through; null means no obstacles exist.Copyright © Eben Howard 2012–2022. All rights reserved.