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

For the Programmer

Introduction
The Programming Interface (API)
Custom data types
    Functions provided by the API
    Functions provided by the model
    Sequence of model function calls
Compilers

Introduction

R2DToo consists of three separate layers: the user interface, the programming interface (API) and the model. The user interface is a compiled executable while the other two layers are dynamic link libraries which are retrieved and used by the executable when it is run.

The advantage of this separation is that each layer can be modified and replaced without breaking the program. For the end user this means the ability to write one's own models and run them within R2DToo. To do this you write code that interacts with the API through function calls. Top of page


The Programming Interface (API)

The API provides functions that the model designer can use. In return, the model is expected to provide certain functions to the API. This section lists both sets of functions as well as some data types defined by the API.
Top of page
Custom data types

Functions provided by the API

For handling parameters

Neighbourhoods

Miscellaneous

Top of page

Functions provided by the model

Required

Optional

Top of page

Sequence of model function calls

The following represents the typical order of calls to model functions, from the loading of a model until it is unloaded or R2DToo is exited. (Bold functions are required.)
  1. getApiVersion - to check if model is valid
  2. onModelLoad - once model has been loaded
  3. getSimHeight/getSimWidth - to set-up a new simulation
  4. onSimCreate - once the simulation space has been allocated
  5. onAgentCreate - called once for each agent in space, after each agent has been created
  6. onAgentDraw - once for each agent
  7. onSimReady - once the simulation is ready to run
  8. onTick - repeated calls to onTick and onAgentDraw while simulation running/stepping
  9. onAgentDestroy - once for each agent, just before agent is deleted
  10. onSimDestroy - just before the simulation space is deleted
  11. onModelUnload - just before the model is unloaded
Top of page

Compilers

Although these functions are listed in the programming language C, the model may be written in any programming environment that can create a standard DLL (this excludes newer versions of MS Visual Basic which can apparently only create ActiveX DLLs).

If you don't have access to a compiler Borland has released a free version of its command-line compiler. The download link is:

For convenience, it is also available as a direct download:

 

freecommandLinetools.exe
freecommandLinetools.exe
8.52 MB
Apr 30, 2004
Borland C++ Compiler version 5.5
Freeware

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