org.primordion.xholon.base
Class PatchOwner

java.lang.Object
  extended byorg.primordion.xholon.base.Xholon
      extended byorg.primordion.xholon.base.XholonWithPorts
          extended byorg.primordion.xholon.base.AbstractGrid
              extended byorg.primordion.xholon.base.PatchOwner
All Implemented Interfaces:
IGrid, IXholon

public class PatchOwner
extends AbstractGrid
implements IXholon

PatchOwner owns a collection of Logo Patches. It's the parent of the first row in the grid. It knows how to create turtles within the patches it owns, and can also clear its patches and turtles back to their default values.

Since:
0.5 (Created on March 1, 2007)

TODO add May 15, 2007): diffuse diffuse4 patch

Author:
Ken Webb

Field Summary
 
Fields inherited from class org.primordion.xholon.base.AbstractGrid
P_BEHAVIOR, P_NEXT, P_PREVIOUS
 
Fields inherited from class org.primordion.xholon.base.XholonWithPorts
port
 
Fields inherited from class org.primordion.xholon.base.Xholon
DEFAULT_LEVEL, interaction, interactionsEnabled
 
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
 
Constructor Summary
PatchOwner()
           
 
Method Summary
 void ca()
          Clear patches, turtles, etc.
 void cd()
          Clear the drawing surface.
 void clearAll()
          Clear patches, turtles, etc.
 void clearDrawing()
          Clear the drawing surface.
 void clearPatches()
          Set all patch variables to their initial values.
 void clearTurtles()
          Kill all turtles within the scope of this PatchOwner.
 void cp()
          Set all patch variables to their initial values.
 void createTurtles(int numTurtles)
          Create a given number of new turtles in the center of the grid.
 void createTurtles(int numTurtles, java.lang.String breed)
          Create a given number of new turtles in the center of the grid, of a given breed.
 void crt(int numTurtles)
          Create a given number of new turtles in the center of the grid.
 void crt(int numTurtles, java.lang.String breed)
          Create a given number of new turtles in the center of the grid, of a given breed.
 void ct()
          Kill all turtles within the scope of this PatchOwner.
 void diffuse(java.lang.String patchVariable, double number)
          Asks each patch to share the current value of a specified variable with all of its neighbors.
 void diffuse4(java.lang.String patchVariable, double number)
          Asks each patch to share the current value of a specified variable with all of its neighbors.
 IAttribute getAggregator(IXholon turtleOrPatch)
          Return the aggregator for the specified turtle or patch.
 int getMaxPxcor()
          Return the maximum Patch x coordinate.
 int getMaxPycor()
          Return the maximum Patch y coordinate.
 int getMinPxcor()
          Return the minimum Patch x coordinate.
 int getMinPycor()
          Return the minimum Patch y coordinate.
 int getWorldHeight()
          Return the height of the world (the grid height).
 int getWorldWidth()
          Return the width of the world (the grid width).
 IPatch patch(int pxcor, int pycor)
          Return the patch with the specified absolute coordinates.
 
Methods inherited from class org.primordion.xholon.base.AbstractGrid
configure, getNeighType, getNumNeighbors, initialize, moveXholonsToGrid, postConfigure, postReconfigure, preReconfigure, reconfigure, setCaFuture, setCaLeft, setCaRight, setEast, setHex0, setHex1, setHex2, setHex3, setHex4, setHex5, setNorth, setNorthEast, setNorthWest, setSiblingsComplete, setSiblingsCompleteSelf, setSiblingsCycle, setSiblingsWheel, setSouth, setSouthEast, setSouthWest, setWest
 
Methods inherited from class org.primordion.xholon.base.XholonWithPorts
configure, getMaxPorts, getPort, isActiveObject, isBound, isContainer, isPassiveObject, setMaxPorts, setPorts, terminate
 
Methods inherited from class org.primordion.xholon.base.Xholon
act, appendChild, appendChild, appendChild, cleanup, createStructure, decVal, decVal, depth, draw, getChildNodes, getFirstChild, getFirstSibling, getId, getLastChild, getLastSibling, getName, getNeighbors, getNextId, getNextSibling, getNthChild, getNthSibling, getNumChildren, getNumSiblings, getParentNode, getPreviousSibling, getRoleName, getRootNode, getSiblings, getSizeMessageQ, 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, initStatics, inOrderPrint, insertAfter, insertBefore, insertFirstChild, isExternal, isInternal, isLeaf, isRootNode, performActivity, performActivity, performBooleanActivity, performBooleanActivity, performDoubleActivity, performGuard, performVoidActivity, postAct, postOrderPrint, preAct, preConfigure, preOrderPrint, print, println, processMessageQ, processReceivedMessage, remove, removeChild, resetNextId, sendMessage, sendMessage, sendMessage, setAttributeVal, setFactory, setFirstChild, setId, setNextSibling, setParentChildLinks, setParentNode, setParentSiblingLinks, setRoleName, setSizeMessageQ, setUid, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVal, setVariableValue, setXhc, swapNode, toString, treeSize, writeXml
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
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
 

Constructor Detail

PatchOwner

public PatchOwner()
Method Detail

clearAll

public void clearAll()
Clear patches, turtles, etc.


ca

public void ca()
Clear patches, turtles, etc. This method implements the same functionality as clearAll().


clearDrawing

public void clearDrawing()
Clear the drawing surface.


cd

public void cd()
Clear the drawing surface. This method implements the same functionality as clearDrawing().


clearPatches

public void clearPatches()
Set all patch variables to their initial values.


cp

public void cp()
Set all patch variables to their initial values. This method implements the same functionality as clearPatches().


clearTurtles

public void clearTurtles()
Kill all turtles within the scope of this PatchOwner.


ct

public void ct()
Kill all turtles within the scope of this PatchOwner. This method implements the same functionality as clearTurtles().


createTurtles

public void createTurtles(int numTurtles)
Create a given number of new turtles in the center of the grid.

Parameters:
numTurtles - The number of new turtles to create.

crt

public void crt(int numTurtles)
Create a given number of new turtles in the center of the grid. This method implements the same functionality as createTurtles().

Parameters:
numTurtles - The number of new turtles to create.

createTurtles

public void createTurtles(int numTurtles,
                          java.lang.String breed)
Create a given number of new turtles in the center of the grid, of a given breed.

Parameters:
numTurtles - The number of new turtles to create.
breed - The breed of turtle to create.

crt

public void crt(int numTurtles,
                java.lang.String breed)
Create a given number of new turtles in the center of the grid, of a given breed. This method implements the same functionality as createTurtles(numTurtles, breed).

Parameters:
numTurtles - The number of new turtles to create.
breed - The breed of turtle to create.

diffuse

public void diffuse(java.lang.String patchVariable,
                    double number)
Asks each patch to share the current value of a specified variable with all of its neighbors.

Parameters:
patchVariable -
number -

diffuse4

public void diffuse4(java.lang.String patchVariable,
                     double number)
Asks each patch to share the current value of a specified variable with all of its neighbors.

Parameters:
patchVariable -
number -

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.

getMaxPxcor

public int getMaxPxcor()
Return the maximum Patch x coordinate.

Returns:
A Patch coordinate.

getMaxPycor

public int getMaxPycor()
Return the maximum Patch y coordinate.

Returns:
A Patch coordinate.

getMinPxcor

public int getMinPxcor()
Return the minimum Patch x coordinate.

Returns:
A Patch coordinate.

getMinPycor

public int getMinPycor()
Return the minimum Patch y coordinate.

Returns:
A Patch coordinate.

getWorldWidth

public int getWorldWidth()
Return the width of the world (the grid width).

Returns:
The width in Patch units.

getWorldHeight

public int getWorldHeight()
Return the height of the world (the grid height).

Returns:
The height in Patch units.

getAggregator

public IAttribute getAggregator(IXholon turtleOrPatch)
Return the aggregator for the specified turtle or patch.

Parameters:
turtleOrPatch - A turtle or patch instance.
Returns:
An Attribute node, or null. TODO this is slow