Quick question: Interaction in case a buffer is intersected

47 views
Skip to first unread message

Benjamin Mewes

unread,
Jul 13, 2016, 8:36:30 AM7/13/16
to GAMA
Imagine I have agents with a known room of interaction (kind of a viewshed), If the viewsheds intersect both agents negotiate a trade (kind of exchange in this case of the good h). If Agent0 has the bigger amount of h he receives the amount of water given by the quotient of intersected area of both viewsheds. Right now, I face two problems: How do I update both values of h quick enough and how do calculate the area of both intersection areas (as overlapping just returns a bool).

Any ideas?

My GAMA model:

model bufferInteraction

/* Insert your model definition here */

global{
    init {
        create Agent number:10;
       
        ask Agent {h <- rnd(5.0);}
    }
   
    reflex updateStatus {
        ask Agent {
            do updateH;
        }
    }
}

species Agent skills: [moving] {
    rgb color;
   
    float h;
   
   
    float self_in;
    float self_out;
   
   
   
   
    geometry viewshed update: h around location;
   
    list<Agent>nearNeighbours update: Agent at_distance h;
   
    action updateH {
        h <- h + self_in - self_out;
        self_in <- 0.0;
        self_out <- 0.0;
    }
   
    reflex dieChecker {
        if(h <= 0) {
            write name + " dies.";
            do die;
        }
    }
   
    reflex interactionAgents{
        if (length(nearNeighbours)!=0) {loop neighbour over:nearNeighbours {
            if (self.h != neighbour.h) {
                if(viewshed partially_overlaps neighbour.viewshed) {
                    if(self.h < neighbour.h) {self_out <- neighbour.h - self.h;}
                   
                    ask neighbour {
                        self_in <- self.self_out;
                    }
                   
                    if(self.h > neighbour.h) {self_in <- self.h - neighbour.h;}
                   
                    ask neighbour {
                        self_out <- self.self_in;
                    }
                }
            }
        } }
    }
   
    reflex move{
        do wander;
       
    }

       
    aspect view {
        draw viewshed color:#lightblue;
        draw name color: #black size:3;
    }
}

grid cell width: 2 height: 2 {
   
}

experiment choose type:gui {
    output{
        display OpenGL type: opengl {
            grid cell lines:#black;
            species Agent aspect: view;
        }
 }

Benjamin Mewes

unread,
Jul 14, 2016, 3:23:23 AM7/14/16
to GAMA
Dear all, I got the quick updating working, but still my question. Am I able to calculate the intersection of two geometries within GAML?

Srirama Bhamidipati

unread,
Jul 14, 2016, 3:49:28 AM7/14/16
to GAMA
Hi,

I dont understand the question completely. But if you want to do an intersection of two geometries, yes, it is possible using the
  • inter (geometry , geometry) --->  geometry
operator

regards,
Srirama
Reply all
Reply to author
Forward
0 new messages