Rik's Treehouse > Babbling in Binary > My Software > Orphanware > R2DToo > R2DToo Help > For the Programmer > setStateCount

setStateCount

Declaration
Parameters
Return Value
Remarks
Example
See Also

Declaration

pState __stdcall setStateCount(
	int x,   	// x-coordinate of agent
	int y,   	// y-coordinate of agent
	int count	// number of state variables
);
Top of page

Parameters

x
X-coordinate of agent (base zero).
y
Y-coordinate of agent (base zero).
count
Number of state variables to allocate space for.
Top of page

Return Value

A pointer to the allocated state array for the agent at (x,y) (array of tState). Top of page

Remarks

This function is available through the API. Use it only from within
onAgentCreate to set the size of the agent state array. Use the same value for all agents. After calling this function you may assign state variables (assignState) for state indices 0..count-1. 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

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