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. mulit-criteria decision-making, 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:
GamlAgent
class,@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:
For example, regular species are defined with the following annotation:
@vars({ @var(name = IKeyword.NAME, type = IType.STRING), @var(name = IKeyword.PEERS, type = IType.LIST),
@var(name = IKeyword.HOST, type = IType.AGENT),
@var(name = IKeyword.LOCATION, type = IType.POINT, depends_on = IKeyword.SHAPE),
@var(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:
@species(value="animal" skills={"moving"})
All these annotations are defined in the GamlAnnotations.java
file of the msi.gama.processor
plug-in.