Skip to content

Commit

Permalink
Minor additions and changes in some Library models
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexisDrogoul committed Mar 16, 2022
1 parent a2bb315 commit 2df6e07
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 85 deletions.
Expand Up @@ -79,13 +79,13 @@ experiment Field_view type:gui{
output {
layout #split;
display "field through mesh" type:opengl {
mesh field_display grayscale:true scale: 0.05 refresh: false triangulation: true smooth: true;
mesh field_display grayscale:true scale: 0.05 triangulation: true smooth: true refresh: false;
}
display "rgb field through mesh" type:opengl {
mesh field_display color:field_display.bands scale: 0.0 refresh: false;
mesh field_display color:field_display.bands scale: 0.1 triangulation: true smooth: 4 refresh: false;
}
display "rnd field with palette mesh" type:opengl {
mesh field_display.bands[2] color:scale([#red::100, #yellow::115, #green::101, #darkgreen::105]) scale:0.1 refresh:false;
mesh field_display.bands[2] color:scale([#red::100, #yellow::115, #green::101, #darkgreen::105]) scale:0.2 refresh: false ;
}
display "var field" type:opengl {
mesh var_field color:(brewer_colors("RdBu")) scale:0.0;
Expand Down
Expand Up @@ -213,12 +213,12 @@ experiment "Classic" type: gui {


output {
display Ants type: opengl synchronized: true antialias: false {
display Ants synchronized: false antialias: false type: opengl {
light #ambient intensity: 127;
light #default intensity: 127;
image terrain refresh: false;
image terrain refresh: true rotate: cycle;
agents "Grid" transparency: 0.4 value: ant_grid where ((each.food > 0) or (each.road > 0) or (each.is_nest));
species ant aspect: info;
species ant aspect: info rotate:-cycle;
}

}
Expand All @@ -231,6 +231,8 @@ experiment "3D View" type: gui {
parameter 'Grid dimension:' var: gridsize init: 100 unit: '(number of rows and columns)' category: 'Environment and Population';
parameter 'Number of food depots:' var: number_of_food_places init: 5 min: 1 category: 'Environment and Population';
output {


display Ants3D type: opengl show_fps: true antialias: false{
grid ant_grid elevation: grid_values triangulation: true texture: terrain refresh: false;
agents "Trail" transparency: 0.7 position: {0.05, 0.05, 0.02} size: {0.9, 0.9} value: (ant_grid as list) where ((each.food > 0) or (each.road > 0) or (each.is_nest));
Expand Down
Expand Up @@ -9,9 +9,7 @@
*/
model tutorial_gis_city_traffic


global
{
global {
//Load of the different shapefiles used by the model
file shape_file_buildings <- shape_file('../includes/building.shp', 0);
file shape_file_roads <- shape_file('../includes/road.shp', 0);
Expand All @@ -33,14 +31,13 @@ global

//Declaration of a graph that will represent our road network
graph the_graph;
init
{
create building from: shape_file_buildings with: [type:: string(read('NATURE'))]
{
if type = "Industrial"
{
color <- # blue;

init {
create building from: shape_file_buildings with: [type:: string(read('NATURE'))] {
if type = "Industrial" {
color <- #blue;
}

height <- 10 + rnd(90);
}

Expand All @@ -53,75 +50,62 @@ global

}

species building
{
species building {
string type;
rgb color <- # gray;
rgb color <- #gray;
int height;
aspect base
{

aspect base {
draw shape color: color depth: height;
}

}

species road
{
rgb color <- # black;
aspect base
{
species road {
rgb color <- #black;

aspect base {
draw shape color: color;
}

}

species people skills: [moving]
{
species people skills: [moving] {
float speed <- min_speed + rnd(max_speed - min_speed);
rgb color <- rnd_color(255);
building living_place <- one_of(residential_buildings);
building working_place <- one_of(industrial_buildings);
point location <- any_location_in(living_place) + { 0, 0, living_place.height };
point location <- any_location_in(living_place) + {0, 0, living_place.height};
int start_work <- min_work_start + rnd(max_work_start - min_work_start);
int end_work <- min_work_end + rnd(max_work_end - min_work_end);
string objectif;
point the_target;
reflex time_to_work when: day_time = start_work
{

reflex time_to_work when: day_time = start_work {
objectif <- 'working';
the_target <- any_location_in(working_place);
}

reflex time_to_go_home when: day_time = end_work
{
reflex time_to_go_home when: day_time = end_work {
objectif <- 'go home';
the_target <- any_location_in(living_place);
}

reflex move when: the_target != nil
{
do goto( target: the_target ,on: the_graph);
switch the_target
{
match location
{
reflex move when: the_target != nil {
do goto(target: the_target, on: the_graph);
switch the_target {
match location {
the_target <- nil;
location <- { location.x, location.y, objectif = 'go home' ? living_place.height : working_place.height };
location <- {location.x, location.y, objectif = 'go home' ? living_place.height : working_place.height};
}

}

}
} }

aspect default
{
aspect default {
draw sphere(3) color: color;
}

}
} }

experiment "Road Traffic" type: gui
{
experiment "Road Traffic" type: gui {
parameter 'Shapefile for the buildings:' var: shape_file_buildings category: 'GIS';
parameter 'Shapefile for the roads:' var: shape_file_roads category: 'GIS';
parameter 'Shapefile for the bounds:' var: shape_file_bounds category: 'GIS';
Expand All @@ -131,37 +115,36 @@ experiment "Road Traffic" type: gui
parameter 'Latest hour to end work' var: max_work_end category: 'People';
parameter 'minimal speed' var: min_speed category: 'People';
parameter 'maximal speed' var: max_speed category: 'People';
parameter 'Number of people agents' var: nb_people category: 'People' min: 0 max: 100000
{
parameter 'Number of people agents' var: nb_people category: 'People' min: 0 max: 100000 {
int nb <- length(people);
ask simulation
{
if (nb_people > nb)
{
ask simulation {
if (nb_people > nb) {
create people number: nb_people - nb;
} else
{
ask (nb - nb_people) among people
{
} else {
ask (nb - nb_people) among people {
do die;
}

}

}

}
output
{
display city_display type: opengl light: true
{

output {
display city_display type: opengl {
light #ambient intensity: 180;
light #default intensity: 180 direction: {0.5, 0.5, -1};
species building aspect: base refresh: false;
species road aspect: base refresh: false;
species people refresh: true;
}

}

}

experiment "Multiple Layers" type: gui
{
experiment "Multiple Layers" type: gui {
parameter 'Shapefile for the buildings:' var: shape_file_buildings category: 'GIS';
parameter 'Shapefile for the roads:' var: shape_file_roads category: 'GIS';
parameter 'Shapefile for the bounds:' var: shape_file_bounds category: 'GIS';
Expand All @@ -171,30 +154,29 @@ experiment "Multiple Layers" type: gui
parameter 'Latest hour to end work' var: max_work_end category: 'People';
parameter 'minimal speed' var: min_speed category: 'People';
parameter 'maximal speed' var: max_speed category: 'People';
parameter 'Number of people agents' var: nb_people category: 'People' min: 0 max: 1000
{
parameter 'Number of people agents' var: nb_people category: 'People' min: 0 max: 1000 {
int nb <- length(people);
ask simulation
{
if (nb_people > nb)
{
ask simulation {
if (nb_people > nb) {
create people number: nb_people - nb;
} else
{
ask (nb - nb_people) among people
{
} else {
ask (nb - nb_people) among people {
do die;
}

}

}

}
output
{
display city_display type: opengl
{

output {
display city_display type: opengl {
species road aspect: base;
species building aspect: base position: { 0, 0, 0.25 };
species people position: { 0, 0, 0.5 };
species building aspect: base position: {0, 0, 0.25};
species people position: {0, 0, 0.5};
}

}

}
Expand Up @@ -27,7 +27,7 @@ species object skills: [moving] {
}

experiment Display type: gui autorun: true {
float w -> simulation.shape.width;
float w -> simulation.shape.width;
float h -> simulation.shape.height;
point p -> first(object).location;
float factor <- 1.0;
Expand Down
Expand Up @@ -113,7 +113,7 @@ experiment "3D view" type: gui {
}
}
//The terrain is represented as a field (but could be equally represented as a grid
mesh patches texture: image_file("../images/DEM/Volcano Texture.jpg") triangulation: true ;
mesh patches texture: image_file("../images/DEM/Volcano Texture.jpg") triangulation: true smooth: true;
//We add to the representation the individual 'aabb's (axis-aligned bounding boxes) of the patches if 'draw_inside' is true
species patches;
//Finally, each lava agent is represented (with its velocity if 'draw_inside' is true)
Expand Down

0 comments on commit 2df6e07

Please sign in to comment.