Benjamin Mewes
unread,Jun 14, 2019, 8:50:43 AM6/14/19Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to GAMA
I have a strange problem with the current Gama GIT version. As soon as a SoilWaterAgent is created the location is set to 0,0,0. There, the physics skill still works, but all SoilWaterAgents are located at the same spot. Any idea why the location is overwritten? Even a hard reset of the location does not work.
Any ideas?
/**
* Name: geometrie
* Author: Mewes
* Description: Deichgeometrie
* Tags: Deich, Physics
* */
model geometrie
global {
//Variables
float globalWaterTransport <- 10E-3; // mm³
int dimension <- 50;
int scale <- 50;
float chanceInf <- 0.03;
rgb colorwood <- rgb([178, 112, 62]);
//Physics engine
physic_world physic_manager;
init {
create ground {
location <- { dimension / 2, dimension / 2, 0 };
collisionBound <- ["shape"::"floor", "x"::dimension / 2, "y"::dimension / 2, "z"::0];
shape <- (rectangle({ dimension/2, dimension/2 }));
mass <- 0.0;
}
create Tube number: 1 {
shape <- rectangle({ 50, 25 });
mass <- 0.0;
location <- {25,25,0};
collisionBound <- ["shape"::"floor","x"::100, "y":: 25/2, "z"::10];
}
create wall {
location <- { dimension / 2, 0, 0 };
shape <- rectangle({ dimension, 2 });
collisionBound <- ["shape"::"floor", "x"::dimension / 2, "y"::0, "z"::10];
mass <- 0.0;
color <- colorwood;
}
create wall {
location <- { dimension, dimension / 2, 0 };
shape <- rectangle({ 2, dimension });
collisionBound <- ["shape"::"floor", "x"::1, "y"::dimension / 2, "z"::10];
mass <- 0.0;
color <- colorwood;
}
//left wall
create wall {
location <- { 0, dimension / 2, 0 };
shape <- rectangle({ 2, dimension });
collisionBound <- ["shape"::"floor", "x"::1, "y"::dimension / 2, "z"::10];
mass <- 0.0;
color <- colorwood;
}
create WaterAgent number: 100 {
location <- {rnd(dimension),rnd(dimension/4),rnd(10)};
collisionBound <- ["shape"::"sphere", "radius"::waterTransportPerAgent];
mass <- waterTransportPerAgent/scale;
color <- #yellow;
}
create physic_world {
physic_manager <- self;
ask physic_manager {agents <- (WaterAgent as list)+(SoilWaterAgent as list)+(Tube as list)+(ground as list)+(wall as list);}
physic_manager.gravity <- true;
}
}
reflex createWatAgents {
if (every(50 #cycle)){
create WaterAgent number: 100 {
location <- {rnd(dimension),rnd(dimension/4),1};
collisionBound <- ["shape"::"sphere", "radius"::waterTransportPerAgent];
mass <- waterTransportPerAgent/scale;
color <- #red;
}
}
}
reflex computeForces {
ask physic_manager {agents <- (WaterAgent as list)+(SoilWaterAgent as list)+(Tube as list)+(ground as list)+(wall as list);}
ask physic_manager {do compute_forces step: 1.0;}
}
}
species Tube skills: [physics] {
reflex checkInf {
ask WaterAgent {
distanceTub <- self distance_to myself;
}
list candidatesInf <- agents_at_distance(7.5) of_species WaterAgent;
ask candidatesInf where (each.location.y > 12.0) {
if (rnd(1.0)<chanceInf){
color <- #blue;
create SoilWaterAgent number: 1 {
color <- #green;
init_x <- myself.location.x+(1.0);
init_y <- myself.location.y+rnd(2.0);
init_z <- myself.location.z;
//this location is still correct
location <- {init_x, init_y,init_z};
//but set to 0,0,0 during the next time step!
write location;
mass <- 0.3;
write name;
}
do die;
}
}
}
reflex checkReInf{
ask WaterAgent {
distanceTub <- self distance_to myself;
}
list candidatesReInf <- agents_at_distance(15.0) of_species WaterAgent;
ask candidatesReInf where ((each.location.z > 5.0) and (each.location.y > 12.0)) {
color <- #blue;
if (rnd(1.0)<chanceInf){
create SoilWaterAgent number: 1{
color <- #green;
location <- {myself.location.x, myself.location.y, myself.location.z-1.0};
}
do die;
}
}
}
aspect cube {
draw shape depth: 10 color:#blue ;
}
}
species ground skills: [physics] {
aspect default {
draw shape color: rgb(255, 255, 255
);
}
}
species wall skills: [physics] {
rgb color;
aspect default {
draw shape color: color depth: 10;
}
}
species SoilWaterAgent skills: [physics] {
float waterTransportPerAgent <- globalWaterTransport*scale;
float speed <- 1.0;
float mass <- 0.01;
float init_x;
float init_y;
float init_z;
rgb color;
reflex resetLoc {
if ((location.x+location.y+location.z) < 1.0){
//In case that soil water agents are located at 0,0
write name+ " reset Location";
write init_x;
write init_y;
write init_z;
//Location is resetted
location <- {init_x,init_y,init_z};
//Leads to force calculation but ends again in location 0,0,0
ask physic_manager {do compute_forces step: 1.0;}
}
}
reflex checkifdead {
if (location.z > 10) {
create WaterAgent number: 1{
color <- #yellow;
location <- {myself.location.x, myself.location.y, myself.location.z+0.1};
mass <- 1.0;
}
write name + " dies";
do die;
}
if (location.z < 0) {
//write name + " dies";
//do die;
}
}
aspect sphere{
draw sphere(waterTransportPerAgent) color: color ;
}
}
species WaterAgent skills: [physics] {
float waterTransportPerAgent <- globalWaterTransport*scale;
float speed;
float distanceTub;
rgb color;
float mass <- 1.0;
reflex checkifdead {
if (location.z < -1) {
do die;
}
if (location.x < -1) {
do die;
}
if (location.x > 51) {
do die;
}
}
aspect sphere{
draw sphere(waterTransportPerAgent) color: color ;
}
}
species physic_world parent: physical_world ;
experiment Init type: gui {
output {
display cells type:opengl draw_env: true {
species ground;
species Tube aspect:cube;
species wall aspect: default;
species SoilWaterAgent aspect:sphere;
species WaterAgent aspect:sphere;
}
}
}