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

anyAgent

Declaration
Parameters
Return Value
Remarks
Example
See Also

Declaration

pState __stdcall anyAgent(
	pState state,  	// return any agent except this one
	int &x,      	// x-coordinate of returned agent
	int &y,      	// y-coordinate of returned agent
	pState* &nbr,  	// neighbours of returned agent
	int &nbrCount	// number of neighbours
);
Top of page

Parameters

state
The function will never return the agent with this state. Set state=NULL in order not to exclude any agent.
x
X-coordinate of returned agent. Passed by reference.
y
Y-coordinate of returned agent. Passed by reference.
nbr
On exit nbr[0..nbrCount-1] are the neighbours of returned agent. Passed by reference.
nbrCount
On exit holds the number of agents of returned agent. Passed by reference.
Top of page

Return Value

Returns a random agent except the one with state variable state (if state not NULL).

On fail, returns NULL. Top of page


Remarks

This function is available through the API. It can be used in the model-supplied routine
onTick to pick a random agent or to randomly choose a second agent for the first to interact with. Top of page

Example

pState a, b; int ax, ay, bx, by; pState *aNbr, *bNbr; int aNbrCount, bNbrCount; a = anyAgent(NULL, ax, ay, aNbr, aNbrCount); // any agent anywhere do { b = anyAgent(a, bx, by, bNbr, bNbrCount); // any agent except a bool bIsNbrOfA = false; for (int i=0; i<aNbrCount; i++) bIsNbrOfA |= (b==aNbr[i]); } while (bIsNbrOfA); // now b != a and b not in neighbourhood of a Top of page

See Also

onTick, xyAgent.
Top of page
[Rik's Office Hours] [Contact Rik]
Last updated: Fri Apr 30 2004, 2:35pm