GridWorld class
A grid of dead or alive cells that accepts an Evolver.
Constructors
-
GridWorld(int numRows, List<
bool> cells) - Constructor accepting a pre-defined cell list. Fails if the world isn't rectangular.
- GridWorld.empty(int nR, int nC)
-
Return an nR x nC world with all cells dead.
factory
- GridWorld.fromString(String x)
-
fromString initializes a world from a multi-line string.
factory
- GridWorld.identity(int n)
-
Return a square world (side length n) with diagonal elements alive.
factory
Properties
Methods
-
appendBottom(
GridWorld other) → GridWorld - Append the other world to the bottom of this one.
-
appendRight(
GridWorld other) → GridWorld - Append the other world to the right of this one.
-
asString(
GridStringer p) → String - Return the world as a String using the given printer.
-
clockwise90(
) → GridWorld - Copy this as a clockwise 90 degree rotation.
-
copy(
) → GridWorld - Copy this.
-
counterClockwise90(
) → GridWorld - Copy this as a counter-clockwise 90 degree rotation.
-
customIsAlive(
int f(int, int), int i, int j) → bool - Is the cell at the mapped {i,j} location alive right now?
-
expandToFit(
int width, int height) → GridWorld - Copy this, expanding to fit. Throws exception if world is already too big to fit.
-
index(
int i, int j) → int - Return an index into cells using {row,column} notation.
-
isAlive(
int i, int j) → bool - Is the cell at {i,j} alive right now?
-
lrPadded(
int n) → GridWorld - Copy this, adding padding on sides.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
padBottom(
int n) → GridWorld - Copy this, adding padding on bottom.
-
padded(
int n) → GridWorld - Copy this, adding padding all around.
-
padLeft(
int n) → GridWorld - Copy this, adding padding on left.
-
padRight(
int n) → GridWorld - Copy this, adding padding on right.
-
padTop(
int n) → GridWorld - Copy this, adding padding on top.
-
paste(
int cI, int cJ, GridWorld other) → GridWorld - Copy this with the other world pasted in at the given location.
-
takeStep(
Evolver e) → void - Take one step in the life of the world.
-
takeSteps(
Evolver e, int n) → void - Take N life steps.
-
tbPadded(
int n) → GridWorld - Copy this, adding padding on top and bottom.
-
toString(
) → String -
Return the world as a string using a builtin printer.
override
-
transpose(
) → GridWorld - Copy this as a transpose.
Operators
-
operator ==(
dynamic other) → bool -
The equality operator.
override