breve Documentation: version 1.9 | ||
---|---|---|
<< previous | next >> |
To create a simple agent in breve, you'll need to subclass one of the basic agent classes, all subclasses of Real:
Stationary, an immobile object in the simulated world.
Mobile, an object which moves around the simulated world.
MultiBody, a physically simulated mobile object.
This chapter describes the basics of implementing agents in breve, with a focus on Mobile agents. Stationary objects are even easier to use than Mobile objects, and Physically simulated MultiBody objects are described in the chapter on physical simulation (Chapter 5).
The section A Simple Mobile agent (Section 3.1) shows a very basic mobile agent template which can be used to any mobile agent. The appearance of the agent can be customized in a number of ways—some basic options are described in the section Changing the Appearance of Agents (Section 3.2). Controlling the motion of agents is described in the section Moving Agents Around the 3D World (Section 3.3). The final section describes how events can be scheduled for specific times (Section 3.4).
The majority of agents created in breve are simple mobile agents.
Here's a simple mobile agent. It inherits most of its behaviors from the class
mobile, but we'll customize it with our own init
and
iterate
methods.
Mobile : Bird { + variables: myShape (object). + to init: # make a new shape. myShape = new Shape. myShape init-with-cube size (1, 1, 1). # register this Mobile with our shape and we're done! self register with-shape myShape. + to iterate: # here we would specify our default behavior--the action # we take at each iteration. typically this involves a # change in velocity or acceleration based on some sort # of computation } |
The shape used need not be a cube—you can choose from a number of shapes using the class Shape. You can also construct your own shapes with the class CustomShape.
This is only a simple example—a template for a real agent. In the rest of the chapter we'll see how to customize the appearance, motion and behavior of an agent.
<< previous | breve Documentation table of contents | next >> |
@-Directives | Changing the Appearance of Agents |