-
Notifications
You must be signed in to change notification settings - Fork 99
ThreeD_step2
This second step model adds the moving3D skills to the cell agents and simply makes move the cells agent by defining a reflex that will call the action move. We will also add additional visual information to the display.
- Redefining the shape of the world with a 3D Shape.
- Attaching new skills (moving3D) to cells agent.
- Modify cells aspect
- Add a graphics layer
We use a new global variable called _environmentSize_that to define the size of our 3D environment. In the global section we define the new variable
int environmentSize <-100;
Then we redefine the shape of the world (by default the shape of the world is a 100x100 square) as cube that will have the size defined by the environment_size variable. To do so we change the shape of the world in the global section:
geometry shape <- cube(environmentSize);
When we create the cells agent we want to place them randomly in the 3D environement. To do so we set the location with a random value for x, y and z between 0 and environmentSize.
create cells number: nb_cells {
location <- {rnd(environmentSize), rnd(environmentSize), rnd(environmentSize)};
}
In the previous example, we only created cells agent that did not have any behavior. In this step we want to make move the cells agent. To do so we add a moving3D skills to the cells.
More information on built-in skills proposed by Gama can be found here
species cells skills:[moving3D]{
...
}
Then we define a new reflex for the species cells that consists in calling the action move bundled in moving3D skills.
reflex move{
do move;
}
Finally we modify a bit the aspect of the sphere to set its size according to the environmentSize global variable previously defined.
aspect default {
draw sphere(environmentSize*0.01) color:#blue;
}
The experiment is the same as the previous one except that we will display the bounds of the environment by using the graphics layer.
graphics "env"{
draw cube(environmentSize) color: #black empty:true;
}
output {
display View1 type:opengl{
graphics "env"{
draw cube(environmentSize) color: #black empty:true;
}
species cells;
}
}
The GIT version of the model can be found here Model 02.gaml
model Tuto3D
global {
int nb_cells <-100;
int environmentSize <-100;
geometry shape <- cube(environmentSize);
init {
create cells number: nb_cells {
location <- {rnd(environmentSize), rnd(environmentSize), rnd(environmentSize)};
}
}
}
species cells skills:[moving3D]{
reflex move{
do move;
}
aspect default {
draw sphere(environmentSize*0.01) color:#blue;
}
}
experiment Tuto3D type: gui {
parameter "Initial number of cells: " var: nb_cells min: 1 max: 1000 category: "Cells" ;
output {
display View1 type:opengl{
graphics "env"{
draw cube(environmentSize) color: #black empty:true;
}
species cells;
}
}
}
- 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