Class GridAgent
java.lang.Object
com.eco.bio7.simulation.GridAgent
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
FieldsModifier and TypeFieldDescriptionThe color of the shape (e.g., "#e53935").doubleThe 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".doubleThe size in cells.doubleThe position in cells (the centre of the cell (i, j): i + 0.5, j + 0.5).doubleThe position in cells (the centre of the cell (i, j): i + 0.5, j + 0.5). -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
x
public double xThe position in cells (the centre of the cell (i, j): i + 0.5, j + 0.5). -
y
public double yThe position in cells (the centre of the cell (i, j): i + 0.5, j + 0.5). -
heading
public double headingThe heading in degrees: 0 up, 90 to the right (clockwise). -
color
The color of the shape (e.g., "#e53935"). -
image
The name of an image (loadImage) instead of the shape (null: the shape). -
size
public double sizeThe size in cells. -
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.
-