Declaration Parameters Remarks Revisions Example See Also
| Declarationvoid __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

Exampledouble *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.
|