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

onSimCreate

Declaration
Remarks
Revisions
Example
See Also

Declaration

void __stdcall onSimCreate(void);
Top of page

Remarks

This optional function may be provided by the model. It is called just after a new simulation has been created (but before the agents have been created). You can use this function to set global variables (shortcuts) to the model parameters. Also, set local neighbourhoods in this function with the
nbrhd* functions, as demonstrated in the example below. Top of page

Revisions

API v1.5
  • new! Replaces simBegin and setNbrhd.
Top of page

Example

unsigned short fadeRate; double *workspace = NULL; //--------------------------------------------------------------------------- void __stdcall onSimCreate(void) { // shortcuts fadeRate = (unsigned short)(*getParamRef("Fade Rate")); // allocate workspace workspace = new double[100]; // set nbr shortcuts for each agent. Much faster than calling agentAtXY(). int range = int(*getParamRef("Neighbourhood Range")); // truncated switch (int(*getParamRef("Neighbourhood Type"))) { case 0: /* mean-field, ignore */ break; case 1: nbrhd1D(range,btPeriodic); break; case 2: nbrhdMoore(range,btPeriodic); break; case 3: // use floating point "Neighbourhood Range" nbrhdRandomER(*getParamRef("Neighbourhood Range"),true); break; case 4: // demonstrates how multiple neighbourhoods can be overlapped nbrhdBlocks(range,range); nbrhdFractal(range,range,true,true); break; } } //--------------------------------------------------------------------------- void __stdcall onSimDestroy(void); { // free workspace delete [] workspace; workspace = NULL; } //--------------------------------------------------------------------------- Top of page

See Also

onSimReady, onSimDestroy, nbrhd1D, nbrhdBlocks, nbrhdCCDM, nbrhdFractal, nbrhdMoore, nbrhdRandom, nbrhdRandomER, nbrhdVonNeumann.
Top of page
[Rik's Office Hours] [Contact Rik]
Last updated: Fri Apr 30 2004, 1:43pm