org.primordion.xholon.base
Interface IPatch

All Superinterfaces:
IGrid, IXholon
All Known Implementing Classes:
Patch

public interface IPatch
extends IXholon, IGrid

A patch is an agent in the turtle mechanism. The turtle mechanism is based on Logo and NetLogo.

Since:
0.5 (Created on February 28, 2007)
Author:
Ken Webb
See Also:
NetLogo website http://ccl.northwestern.edu/netlogo/

TODO add (May 15 2007): beep inRadius patch patchAt patchAtHeadingAndDistance sprout towards towardsxy turtlesAt turtlesHere turtlesOn with


Field Summary
static int COMMANDID_NONE
           
static int FILTERID_NONE
           
 
Fields inherited from interface org.primordion.xholon.base.IXholon
DEFAULT_SIZE_MSG_Q, NINCLUDE_PSC, NINCLUDE_PSx, NINCLUDE_PxC, NINCLUDE_Pxx, NINCLUDE_xSC, NINCLUDE_xSx, NINCLUDE_xxC, NINCLUDE_xxx
 
Fields inherited from interface org.primordion.xholon.base.IGrid
BOUNDARY_GRID, BOUNDARY_TORUS, NEIGHBORHOOD_1DCA, NEIGHBORHOOD_HEXAGONAL, NEIGHBORHOOD_MOORE, NEIGHBORHOOD_SIBLING, NEIGHBORHOOD_VON_NEUMANN, P_CAFUTURESELF, P_CALEFTNEIGHBOR, P_CARIGHTNEIGHBOR, P_EAST, P_HEX0, P_HEX1, P_HEX2, P_HEX3, P_HEX4, P_HEX5, P_NORTH, P_NORTHEAST, P_NORTHWEST, P_SOUTH, P_SOUTHEAST, P_SOUTHWEST, P_STAYHERE, P_WEST, REGULAR_COMPLETE, REGULAR_COMPLETE_SELF, REGULAR_CYCLE, REGULAR_WHEEL
 
Method Summary
 void aggregate(double amount)
          Aggregate by keeping a count of the number of individuals of a given type of Patch.
 void beep()
          Make a single short beep sound.
 double distance(IXholon turtleOrPatch)
          Return the distance between self and the specified turtle or patch.
 double distancexy(double x, double y)
          Return the distance between yourself and the specified x, y coordinates.
 int getPcolor()
          Get the patch's pcolor.
 java.lang.String getPlabel()
          Get the patch's label, a String that helps to identify it.
 int getPxcor()
          Get the patch's x coordinate.
 int getPycor()
          Get the patch's y coordinate.
 java.util.Vector inRadius(int radius)
          Return a list of all neighbors (patches) within the specified radius.
 java.util.Vector inRadius(int radius, int filterId)
          Return a list of all neighbors (patches) within the specified radius.
 java.util.Vector neighbors()
          Return the 8 surrounding neighbor patches.
 java.util.Vector neighbors4()
          Return the 4 surrounding neighbor patches.
 IPatch patch(int pxcor, int pycor)
          Return the patch with the specified absolute coordinates.
 IPatch patchAt(int dx, int dy)
          Return the single patch at the specified x and y relative distance.
 IPatch patchAtHeadingAndDistance(double heading, double distance)
          Return the single patch at the specified absolute heading and relative distance.
 void setPcolor(int pcolor)
          Set the patch's pcolor.
 void setPlabel(java.lang.String plabel)
          Set or change the patch's label.
 void setPxcor(int pxcor)
          Set the patch's x coordinate.
 void setPycor(int pycor)
          Set the patch's y coordinate.
 void sprout(IXholonClass xhClazz, int numTurtles, int commandId)
          Create a specified number of new turtles on the current patch.
 double towards(IXholon turtleOrPatch)
          Return the heading between self and the specified turtle or patch.
 double towardsxy(double x, double y)
          Return the heading between self and the specified x, y coordinates.
 java.util.Vector turtlesAt(int dx, int dy)
          Return the turtles located at the single patch at the specified x and y relative distance.
 java.util.Vector turtlesHere()
          Return the turtles located at the current patch.
 java.util.Vector turtlesOn()
          Return the turtles that are on the given patch or patches, or standing on the same patch as the given turtle or turtles.
 java.util.Vector with(java.util.Vector vIn, int filterId)
          Filters the input vector to produce an output vector.
 
Methods inherited from interface org.primordion.xholon.base.IXholon
act, appendChild, appendChild, appendChild, cleanup, configure, configure, createStructure, decVal, decVal, depth, draw, getChildNodes, getFirstChild, getFirstSibling, getId, getLastChild, getLastSibling, getName, getNeighbors, getNextSibling, getNthChild, getNthSibling, getNumChildren, getNumSiblings, getParentNode, getPort, getPreviousSibling, getRoleName, getRootNode, getSiblings, getUid, getVal_boolean, getVal_byte, getVal_char, getVal_double, getVal_float, getVal_int, getVal_long, getVal_Object, getVal_short, getVal_String, getVal, getXhc, getXhcId, getXhcName, getXhType, handleNodeSelection, hasAncestor, hasChildNodes, hasChildOrSiblingNodes, hasNextSibling, hasParentNode, height, incVal, incVal, initialize, initStatics, inOrderPrint, insertAfter, insertBefore, insertFirstChild, isActiveObject, isBound, isContainer, isExternal, isInternal, isLeaf, isPassiveObject, isRootNode, performActivity, performActivity, performBooleanActivity, performBooleanActivity, performDoubleActivity, performGuard, performVoidActivity, postAct, postConfigure, postOrderPrint, postReconfigure, preAct, preConfigure, preOrderPrint, preReconfigure, print, println, processMessageQ, processReceivedMessage, reconfigure, remove, removeChild, sendMessage, sendMessage, sendMessage, setAttributeVal, setFirstChild, setId, setNextSibling, setParentChildLinks, setParentNode, setParentSiblingLinks, setPorts, setRoleName, setUid, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVariableValue, setXhc, swapNode, terminate, treeSize, writeXml
 
Methods inherited from interface org.primordion.xholon.base.IGrid
getNeighType, getNumNeighbors, moveXholonsToGrid, setCaFuture, setCaLeft, setCaRight, setEast, setHex0, setHex1, setHex2, setHex3, setHex4, setHex5, setNorth, setNorthEast, setNorthWest, setSiblingsComplete, setSiblingsCompleteSelf, setSiblingsCycle, setSiblingsWheel, setSouth, setSouthEast, setSouthWest, setWest
 

Field Detail

COMMANDID_NONE

public static final int COMMANDID_NONE
See Also:
Constant Field Values

FILTERID_NONE

public static final int FILTERID_NONE
See Also:
Constant Field Values
Method Detail

beep

public void beep()
Make a single short beep sound.


distance

public double distance(IXholon turtleOrPatch)
Return the distance between self and the specified turtle or patch.

Parameters:
turtleOrPatch - A turtle or patch object.
Returns:
A distance in units.

distancexy

public double distancexy(double x,
                         double y)
Return the distance between yourself and the specified x, y coordinates.

Parameters:
x - A global x coordinate.
y - A global y coordinate.
Returns:
A distance in units.

inRadius

public java.util.Vector inRadius(int radius)
Return a list of all neighbors (patches) within the specified radius. This works for a torus where each cell has 8 neighbors.

Parameters:
radius - Distance from the current patch. The current patch is a radius of 0 from itself.
Returns:
A vector containing zero or more gridCells.

inRadius

public java.util.Vector inRadius(int radius,
                                 int filterId)
Return a list of all neighbors (patches) within the specified radius. This works for a torus where each cell has 8 neighbors.

Parameters:
radius - Distance from the current patch. The current patch is a radius of 0 from itself.
filterId - An ID that can be used by performBooleanActivity() to select a specific filter.
Returns:
A vector containing zero or more gridCells.

neighbors

public java.util.Vector neighbors()
Return the 8 surrounding neighbor patches.

Returns:
A collection of IPatch instances.

neighbors4

public java.util.Vector neighbors4()
Return the 4 surrounding neighbor patches.

Returns:
A collection of IPatch instances.

patch

public IPatch patch(int pxcor,
                    int pycor)
Return the patch with the specified absolute coordinates.

Parameters:
pxcor - An x coordinate.
pycor - A y coordinate.
Returns:
A patch instance, or null.

patchAt

public IPatch patchAt(int dx,
                      int dy)
Return the single patch at the specified x and y relative distance.

Parameters:
dx - A relative distance in the x direction, in patches.
dy - A relative distance in the y direction, in patches.
Returns:
A patch, or null.

patchAtHeadingAndDistance

public IPatch patchAtHeadingAndDistance(double heading,
                                        double distance)
Return the single patch at the specified absolute heading and relative distance.

Parameters:
heading - An absolute angle measured in degrees.
distance - A distance measured in units.
Returns:
A patch, or null.

sprout

public void sprout(IXholonClass xhClazz,
                   int numTurtles,
                   int commandId)
Create a specified number of new turtles on the current patch.

Parameters:
xhClazz - The XholonClass that the new turtles should be members of.
numTurtles - The number of new turtles to hatch.
commandId - The ID of a set of turtle commands that can be executed by calling performActivity(int commandId) on each new turtle.

towards

public double towards(IXholon turtleOrPatch)
Return the heading between self and the specified turtle or patch.

Parameters:
turtleOrPatch - A turtle or patch object.
Returns:
A A heading angle in degrees.

towardsxy

public double towardsxy(double x,
                        double y)
Return the heading between self and the specified x, y coordinates.

Parameters:
x - A global x coordinate.
y - A global y coordinate.
Returns:
A heading angle in degrees.

turtlesAt

public java.util.Vector turtlesAt(int dx,
                                  int dy)
Return the turtles located at the single patch at the specified x and y relative distance.

Parameters:
dx - A relative distance in the x direction, in patches.
dy - A relative distance in the y direction, in patches.
Returns:
A collection of ITurtle instances.

turtlesHere

public java.util.Vector turtlesHere()
Return the turtles located at the current patch.

Returns:
A collection of ITurtle instances.

turtlesOn

public java.util.Vector turtlesOn()
Return the turtles that are on the given patch or patches, or standing on the same patch as the given turtle or turtles.

Returns:
A collection of ITurtle instances.

with

public java.util.Vector with(java.util.Vector vIn,
                             int filterId)
Filters the input vector to produce an output vector.

Parameters:
vIn - A collection of ITurtle instances.
filterId - The ID of a turtle filter.
Returns:
A filtered collection of ITurtle instances.

getPcolor

public int getPcolor()
Get the patch's pcolor.

Returns:
A pcolor value, as defined in ITurtlePatchColor.

setPcolor

public void setPcolor(int pcolor)
Set the patch's pcolor. NetLogo: set pcolor value

Parameters:
pcolor - A pcolor value, as defined in ITurtlePatchColor.

getPlabel

public java.lang.String getPlabel()
Get the patch's label, a String that helps to identify it.

Returns:
A label.

setPlabel

public void setPlabel(java.lang.String plabel)
Set or change the patch's label. Warning: Use caution when changing the label.


getPxcor

public int getPxcor()
Get the patch's x coordinate.

Returns:
The pxcor value.

setPxcor

public void setPxcor(int pxcor)
Set the patch's x coordinate.


getPycor

public int getPycor()
Get the patch's y coordinate.

Returns:
The pycor value.

setPycor

public void setPycor(int pycor)
Set the patch's y coordinate.


aggregate

public void aggregate(double amount)
Aggregate by keeping a count of the number of individuals of a given type of Patch.

Parameters:
amount - The amount to increment or decrement the current population count. The amount can be a positive (increment) or negative (decrement) number.