Skip to content

Customization

Arnaud Grignard edited this page May 6, 2021 · 9 revisions

This model Custom Model gives you the possibility to inherits from the initial model and to populate it with any new species of your choice.

Customize your model

Here is the different step in order to run your custom species on top of the original model

Import the orginal model.

This will give you access to all the feature of the original model

import "CityScope_main.gaml"

Create your custom species.

In this case a simple species with a moving skills that wanders all over the world and displayed as a red circle.

species CustomSpecies skills:[moving]{
  reflex move{
    do wander;
  }
  aspect base{
    draw circle(10#m) color:#red;
  }
}

Initialize custom species.

In this case we create 10 instances of CustomSpecies. The initialization of the imported model will also be called.

global{
  init{
    create CustomSpecies number:10;
  }
}

Define a new experiment

Complete Experiment (main model + customized species)

customizedExperimentinherits from CityScopeMain so that you can display the initial model and add the CustomSpecies using the extra layer species CustomSpecies aspect:base;

Customize Experiment

You can eventually display only your customized species if you want to focus on their specific behavior.

experiment customizedExperiment type:gui parent:CityScopeMain{
  output{
    display CityScopeAndCustomSpecies type:opengl parent:CityScopeVirtual{
      species CustomSpecies aspect:base;
    }
    display CustomSpeciesOnly type:opengl{
      species CustomSpecies aspect:base;
    }
  }
}

Run it!