A Very Quick Overview of Writing Agent Behaviors in breve
Before jumping into Capture the Flag, here's take a quick overview of how a typical agent behaves in a breve simulation. In breve, agent behaviors are run repeatedly over a series of timesteps. At each timestep, the agents typically perform the following steps:
- Get data about the environment from sensors
- Process sensor data
- Preform an action based on the data
Defining a simple agent behavior in breve is simply a matter of performing these steps via a function called iterate. As an example of this concept, we'll write a player with a simple behavior divided into these three steps:
CaptureTheFlagPlayer : myBluePlayer {
+ to iterate:
if ( self get-angle to ( self get-other-home-location ) ) < 0:
self turn-left.
super iterate.
}
The specific steps in the example above are:
- The agent senses the angle to the other team's home territory
- The agent processes this value by comparing it to 0
- The agent performs an action (turns left) if the angle is less than 0.
super iterate. is required by the breve engine to execute agent behaviors correctly. It should be included at the bottom of every agent strategy.
