Skip to main content
Version: 🚧 Alpha 🚧

7. Agent aspects

This step defines alternative aspects for prey and predators: image icons for the main view and a square with the agent's energy for an information view.

Define aspects in the parent species​

my_icon stores the image used by the icon aspect. The info aspect also draws the agent's energy with two digits of precision.

species generic_species {
float size <- 1.0;
rgb color;
float energy;
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;
}
}

Assign an icon to each species​

The model library includes a sheep image for prey and a wolf image for predators.

species prey parent: generic_species {
image_file my_icon <- image_file("../includes/data/sheep.png");
}

species predator parent: generic_species {
image_file my_icon <- image_file("../includes/data/wolf.png");
}

The sheep icon and wolf icon are also available for inspection. The runnable model stores them in its includes/data directory.

Choose an aspect in each display​

The main display uses the icons. A second display uses the info aspect to show energy values.

output {
display main_display renderer: 3d antialias: false map_order: true {
grid vegetation_cell border: #black;
species prey aspect: icon;
species predator aspect: icon;
}

display info_display renderer: 3d antialias: false map_order: true {
grid vegetation_cell border: #black;
species prey aspect: info;
species predator aspect: info;
}
}

See the complete Predator–Prey model 7 for the full parent species, experiment parameters and monitors.