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

xyAgent

Declaration
Parameters
Return Value
Remarks
Revisions
Example
See Also

Declaration

pState __stdcall xyAgent(
	int x,      	// x-coordinate of desired agent
	int y,      	// y-coordinate of desired agent
	pState* &nbr,  	// neighbours of returned agent
	int &nbrCount	// number of neighbours
);
Top of page

Parameters

x
X-coordinate of desired agent.
y
Y-coordinate of desired agent.
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 agent at coordinates (x,y). If x or y out of bounds 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 an agent at specific coordinates. Top of page

Revisions

v1.1
  • new
Top of page

Example

void __stdcall onTick(double &time) { int ax,ay; int nbrCount; pState *nbr; pState a = anyAgent(NULL,ax,ay,nbr,nbrCount); // pick a neighbour int nbrIndex = random(aNbrCount); // 0..aNbrCount-1 // get second neighbour int bx = getNbrX(ax,ay,nbrIndex); int by = getNbrY(ax,ay,nbrIndex); pState b = xyAgent(bx,by,nbr,nbrCount); // now nbr[0..nbrCount-1] are second neighbours of a. // process second neighbours... } Top of page

See Also

anyAgent, onTick, getNbrX, getNbrY.
Top of page
[Rik's Office Hours] [Contact Rik]
Last updated: Fri Apr 30 2004, 1:46pm