Package org.baseagent.grid
Class GridLayerStep
java.lang.Object
org.baseagent.grid.GridLayerStep
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiondouble
average4Neighbors
(int x, int y) double
average8Neighbors
(int x, int y) double
average9Neighbors
(int x, int y) void
clear
(int x, int y) void
clear
(GridPosition position) long
Returns a count of the number of times the predicate is true across the full layer.int
count4Neighbors
(int x, int y, Predicate<? super Object> predicate) Returns a count of the neighbors to the north, south, east, and west of the given cell that match the predicate.int
count8Neighbors
(int x, int y, Predicate<? super Object> predicate) Returns a count of the neighbors surrounding the given cell that match the predicate.void
void
void
Defines a visual arrangement for playing the given thing on the grid.void
get
(int x, int y) get
(GridPosition position) int
getBooleanAsOneOrZero
(int x, int y, Predicate<Object> predicate) Test the give predicate.double
laplacian_3x3
(int x, int y, double centerWeight, double adjacentWeight, double diagonalWeight) void
Randomly places the given thing throughout the GridLayerStep, making sure to not place a thing on a space that already has the same thing.void
void
void
void
void
set
(GridPosition position, Object value) void
void
setEachCell
(GridLayerStep conditionalLayer, Function<Object, Object> f)
-
Constructor Details
-
GridLayerStep
-
-
Method Details
-
fill
-
fill
-
laplacian_3x3
public double laplacian_3x3(int x, int y, double centerWeight, double adjacentWeight, double diagonalWeight) -
set
-
set
-
clear
public void clear(int x, int y) -
clear
-
get
-
get
-
setEachCell
-
setEachCell
-
count8Neighbors
Returns a count of the neighbors surrounding the given cell that match the predicate. -
count4Neighbors
Returns a count of the neighbors to the north, south, east, and west of the given cell that match the predicate. -
average9Neighbors
public double average9Neighbors(int x, int y) -
average8Neighbors
public double average8Neighbors(int x, int y) -
average4Neighbors
public double average4Neighbors(int x, int y) -
count
Returns a count of the number of times the predicate is true across the full layer. -
getBooleanAsOneOrZero
Test the give predicate. If the predicate is true, return 1, otherwise return 0. -
scatter
Randomly places the given thing throughout the GridLayerStep, making sure to not place a thing on a space that already has the same thing. -
scatter
-
scatter
-
scatter
-
form
Defines a visual arrangement for playing the given thing on the grid. Key: . = empty space, O = Thing -
form
-
getRandomUnoccupiedPosition
-