Rik's Treehouse
>
Babbling in Binary
>
My Software
>
Orphanware
>
R2DToo
>
R2DToo Help
>
For the Programmer
> onAgentCreate
onAgentCreate
Declaration
Parameters
Remarks
Revisions
Example
See Also
Declaration
void __stdcall onAgentCreate( int x, // x-coordinate of agent int y // y-coordinate of agent );
Parameters
x
X-coordinate of agent (zero based).
y
Y-coordinate of agent (zero based).
Remarks
This function must be provided by the model. It is called by the simulation at the start of a new simulation to set the number of state variables for each agent, along with their names and default values. Make calls to
setStateCount
and
assignState
from within this function.
Revisions
API v1.5
new! Replaces
initAgent
.
Example
double *extraData[256][256]; //--------------------------------------------------------------------------- void __stdcall
onAgentCreate
(int x, int y) { setStateCount(x,y, 2); // pos index name initial value assignState(x,y, 0, "alive", flip(*
getParamRef
("Initial Population")); assignState(x,y, 1, "alive nbrs", 0); // allocate some extra storage for agent (x,y) extraData[x][y] = new double[10]; } //--------------------------------------------------------------------------- void __stdcall
onAgentDestroy
(int x, int y) { delete [] extraData[x][y]; } //---------------------------------------------------------------------------
See Also
setStateCount
,
assignState
,
onAgentDestroy
.
[Rik's Office Hours]
[Contact Rik]
Last updated: Fri Apr 30 2004, 1:42pm