Simulations in breve are written using a language called "steve". steve is a simple language which aims to allow rapid construction of advanced simulations while avoiding a great deal of the programming overhead associated with constructing simulations in other languages.
![]() | Don't Be Overwhelmed! |
---|---|
Writing simulations in steve is ultimately quite simple. Due to the number of features provided by the simulation engine, however, this documentation may seem at times overwhelming. Don't panic—make liberal use of the demo simulations provided with the environment and don't be put off if some of the features discussed here are difficult to understand. |
"steve" is an object-oriented language. This means that programming in "steve" involves working with components called objects which contain data (variables) and behaviors (methods). In breve, objects can be either real, meaning they have a presence in the simulated world; or abstract meaning that they are used to store data or to perform computations, but do not appear in the simulated world. In order to define agents and their behaviors, one needs to construct these objects and behaviors using the "steve" language. The language is described in this chapter.
First, the classic "Hello, World" program is constructed in steve (the section called “Hello, World”). Then, a simple multiagent 3D simulation written in steve is presented (the section called “A Simple Example”). This sample should give the basic idea of what a breve simulation looks like.
As discussed above, all agents in the simulated world are represented by programming objects. These objects are defined in terms of object templates called classes. The most important object, called the Controller is described in the section The Controller Object (the section called “The Controller Object”). The section Building Classes (the section called “Building Classes”) describes how to construct basic classes in steve.
In order to define the data and behaviors of your classes, you'll need to be familiar with types (the section called “Types in "steve"”) and expressions (the section called “Expressions”). The section Program Control Structures (the section called “Program Control Structures”) discusses loops and conditional statements.
The traditional introduction to any programming language is a program which repeatedly prints out the text "Hello, World!". Here it is written in steve:
@include "Control.tz" Controller HelloWorld. Control : HelloWorld { + to iterate: print "Hello, world!". }
The specifics will be discussed in more detail through the rest of this
chapter. Briefly, we first declare the simulation's controller object
to be a class called HelloWorld
(line 3).
Then we construct the HelloWorld
class
(lines 5-8), and as part of that class, we define a method called
iterate
(line 6) which will print out the
text "Hello, world!". The "include" line (line 1) simply tells breve to
load in a file called "Control.tz", which is included with the breve
distribution. This built-in class file contains the class control,
which is the parent class for our
"HelloWorld" controller.
When this simulation is run, the controller object is created, and the
method named iterate
gets run
automatically at every step of the simulation. Thus, "Hello, World!".
Ad nauseum.