Class GridAgent

java.lang.Object
com.eco.bio7.simulation.GridAgent

public class GridAgent extends Object
An agent on the grid of a GridModel, ValueGridModel or GeoGridModel (a turtle on the patches): the position in cells (x to the right, y down; the centre of the cell (i, j) is i + 0.5, j + 0.5), the heading (degrees, 0 up, clockwise) and its look: a color with a shape ("circle", "arrow" in the heading or "square"), or an image (loadImage, turned to the heading). The size is in cells. Extend it with own fields:
static class Ant extends GridAgent {
        boolean carrying;
}
The model moves the agents (forward, moveTo, face: on a torus or at the edge of the grid) and finds them (agentsAt, agentsNear); they are drawn on the grid in Bio7 and in the HTML page.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    The color of the shape (e.g., "#e53935").
    double
    The heading in degrees: 0 up, 90 to the right (clockwise).
    The name of an image (loadImage) instead of the shape (null: the shape).
    The shape: "circle", "arrow" (points in the heading) or "square".
    double
    The size in cells.
    double
    The position in cells (the centre of the cell (i, j): i + 0.5, j + 0.5).
    double
    The position in cells (the centre of the cell (i, j): i + 0.5, j + 0.5).
  • Constructor Summary

    Constructors
    Constructor
    Description
    An agent at the position 0, 0.
    GridAgent(double x, double y)
    An agent at the position (cells).
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    The column of the cell of the agent.
    int
    The row of the cell of the agent.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • x

      public double x
      The position in cells (the centre of the cell (i, j): i + 0.5, j + 0.5).
    • y

      public double y
      The position in cells (the centre of the cell (i, j): i + 0.5, j + 0.5).
    • heading

      public double heading
      The heading in degrees: 0 up, 90 to the right (clockwise).
    • color

      public String color
      The color of the shape (e.g., "#e53935").
    • image

      public String image
      The name of an image (loadImage) instead of the shape (null: the shape).
    • size

      public double size
      The size in cells.
    • shape

      public String shape
      The shape: "circle", "arrow" (points in the heading) or "square".
  • Constructor Details

    • GridAgent

      public GridAgent()
      An agent at the position 0, 0.
    • GridAgent

      public GridAgent(double x, double y)
      An agent at the position (cells).
  • Method Details

    • cellX

      public int cellX()
      The column of the cell of the agent.
    • cellY

      public int cellY()
      The row of the cell of the agent.