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
);
Top of page

Parameters

x
X-coordinate of agent (zero based).
y
Y-coordinate of agent (zero based).
Top of page

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. Top of page

Revisions

API v1.5
  • new! Replaces initAgent.
Top of page

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]; } //--------------------------------------------------------------------------- Top of page

See Also

setStateCount, assignState, onAgentDestroy.
Top of page
[Rik's Office Hours] [Contact Rik]
Last updated: Fri Apr 30 2004, 1:42pm