DOCUMENTATION TUTORIALS DOWNLOAD NEWS CONTRIBUTE

Developing Species

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.

Implementation

A new species can be any Java class that:

Similarly to skills, a species can define additional attributes and actions.

Additional attributes

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);

Additional actions

An additional action is a method annotated by the @action annotation.

@action(name = ISpecies.stepActionName)
public Object _step_(final IScope scope) {

Annotations

@species

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:

All these annotations are defined in the GamlAnnotations.java file of the msi.gama.processor plug-in.