Class GridLayerStep

java.lang.Object
org.baseagent.grid.GridLayerStep

public class GridLayerStep extends Object
  • Constructor Details

    • GridLayerStep

      public GridLayerStep(Grid parentGrid)
  • Method Details

    • fill

      public void fill(Object value)
    • fill

      public void fill(Object value, int x1, int y1, int x2, int y2)
    • laplacian_3x3

      public double laplacian_3x3(int x, int y, double centerWeight, double adjacentWeight, double diagonalWeight)
    • set

      public void set(int x, int y, Object value)
    • set

      public void set(GridPosition position, Object value)
    • clear

      public void clear(int x, int y)
    • clear

      public void clear(GridPosition position)
    • get

      public Object get(int x, int y)
    • get

      public Object get(GridPosition position)
    • setEachCell

      public void setEachCell(GridLayerStep conditionalLayer, Function<Object,Object> f)
    • setEachCell

      public void setEachCell(BiFunction<Integer,Integer,Object> f)
    • count8Neighbors

      public int count8Neighbors(int x, int y, Predicate<? super Object> predicate)
      Returns a count of the neighbors surrounding the given cell that match the predicate.
    • count4Neighbors

      public 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.
    • 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

      public long count(Predicate<Object> predicate)
      Returns a count of the number of times the predicate is true across the full layer.
    • getBooleanAsOneOrZero

      public int getBooleanAsOneOrZero(int x, int y, Predicate<Object> predicate)
      Test the give predicate. If the predicate is true, return 1, otherwise return 0.
    • scatter

      public void scatter(Object thing, int howMany)
      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

      public void scatter(List<?> things)
    • scatter

      public void scatter(List<?> things, int x1, int y1, int x2, int y2)
    • scatter

      public void scatter(Object thing, int howMany, int x1, int y1, int x2, int y2)
    • form

      public void form(Object thing, int x, int y, String... strings)
      Defines a visual arrangement for playing the given thing on the grid. Key: . = empty space, O = Thing
    • form

      public void form(String... strings)
    • getRandomUnoccupiedPosition

      public GridPosition getRandomUnoccupiedPosition()