-
Notifications
You must be signed in to change notification settings - Fork 99
PredatorPrey_step7
In this seventh step, we will focus on the display and more specifically the aspects of the agents: how they are represented. It can be a simple shape (circle, square, etc.), an icon, a polygon (see later GIS support).
- Definition of two new aspects for the prey and predator agents:
- A icon
- A square with information about the agent energy
- Use of the
icon
aspect as default aspect for the prey and predator agents.
We add a new variable of type image_file
(a particular kind of file
) called my_icon
to the generic_species
.
We define as well two new aspects:
-
icon
: draw the image given by the variablemy_icon
, -
info
: draw a square of side sizesize
and colorcolor
and draw as a text the energy of the agent (with a precision of 2 digits).
species generic_species {
...
image_file my_icon;
...
aspect base {
draw circle(size) color: color ;
}
aspect icon {
draw my_icon size: 2 * size ;
}
aspect info {
draw square(size) color: color ;
draw string(energy with_precision 2) size: 3 color: #black ;
}
}
We specialize the prey
species from the generic_species
species as follows:
- definition of the initial value of the agent variables:
species prey parent: generic_species {
...
image_file my_icon <- image_file("../includes/data/sheep.png") ;
...
}
You have to copy it in your project folder: includes/data/
.
As done for the prey
species, we specialize the predator
species from the generic_species
species:
- definition of the initial value of the agent variables:
species predator parent: generic_species {
...
image_file my_icon <- image_file("../includes/data/wolf.png") ;
...
}
You have to copy it in your project folder: includes/data/
.
We change the default aspect of the prey and predator agents to icon
aspect.
output {
display main_display {
grid vegetation_cell lines: #black ;
species prey aspect: icon ;
species predator aspect: icon ;
}
}
We define a new display called info_display
that displays the prey and predator agents with the info
aspect.
output {
display info_display {
grid vegetation_cell lines: #black ;
species prey aspect: info;
species predator aspect: info;
}
}
https://github.com/gama-platform/gama/blob/GAMA_1.9.2/msi.gama.models/models/Tutorials/Predator%20Prey/models/Model%2007.gaml
- 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 Model Section
- Multi-Paradigm Modeling
- Manipulate 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