-
Notifications
You must be signed in to change notification settings - Fork 5
DevelopingSpecies
Additional built-in species can be defined in Java in order to be used in GAML models. Additional attributes and actions can be defined. It could be very useful in order to define its behavior thanks to external libraries (e.g. database connection...).
A new built-in species extends the GamlAgent
class, which defines the basic GAML agents. As a consequence, new built-in species have all the attributes (name
, shape
, ...) and actions (die
...) of regular species.
A new species can be any Java class that:
- extends the
GamlAgent
class, - begins by the @species:
@species(name = "name_of_the_species_gaml")
,
@species(name = "multicriteria_analyzer")
public class MulticriteriaAnalyzer extends GamlAgent {
Similarly to skills, a species can define additional attributes and actions.
Defining new attributes needs:
- to add @vars (and one embedded @variable per additional attribute) annotation on top of the class,
- to define @setter and @getter annotations to the accessors methods.
For example, regular species are defined with the following annotation:
@vars({ @variable(name = IKeyword.NAME, type = IType.STRING), @variable(name = IKeyword.PEERS, type = IType.LIST),
@variable(name = IKeyword.HOST, type = IType.AGENT),
@variable(name = IKeyword.LOCATION, type = IType.POINT, depends_on = IKeyword.SHAPE),
@variable(name = IKeyword.SHAPE, type = IType.GEOMETRY) })
And accessors are defined using:
@getter(IKeyword.NAME)
public abstract String getName();
@setter(IKeyword.NAME)
public abstract void setName(String name);
An additional action is a method annotated by the @action annotation.
@action(name = ISpecies.stepActionName)
public Object _step_(final IScope scope) {
This annotation represents a "species" in GAML. The class annotated with this annotation will be the support of a species of agents.
This annotation contains:
- name (string): the name of the species that will be created with this class as base. Must be unique throughout GAML.
-
skills (set of strings, empty by default): An array of skill names that will be automatically attached to this species. Example:
@species(value="animal" skills={"moving"})
- internal (boolean, false by default): whether this species is for internal use only.
- doc (set of @doc, empty by default): the documentation attached to this operator.
All these annotations are defined in the GamlAnnotations.java
file of the msi.gama.processor
plug-in.
- Installation and Launching
- Workspace, Projects and Models
- Editing Models
- Running Experiments
- Running Headless
- Preferences
- Troubleshooting
- Introduction
- Manipulate basic Species
- Global Species
- Defining Advanced Species
- Defining GUI Experiment
- Exploring Models
- Optimizing Models
- Multi-Paradigm Modeling
- Manipulate OSM Data
- Cleaning OSM Data
- Diffusion
- Using Database
- Using FIPA ACL
- Using BDI with BEN
- Using Driving Skill
- Manipulate dates
- Manipulate lights
- Using comodel
- Save and restore Simulations
- Using network
- Headless mode
- Using Headless
- Writing Unit Tests
- Ensure model's reproducibility
- Going further with extensions
- Built-in Species
- Built-in Skills
- Built-in Architecture
- Statements
- Data Type
- File Type
- Expressions
- Exhaustive list of GAMA Keywords
- Installing the GIT version
- Developing Extensions
- Introduction to GAMA Java API
- Using GAMA flags
- Creating a release of GAMA
- Documentation generation