model sandboxDammAgent
global {
graph my_graph <- graph([]);
init {
ask plot_cell {
create water_node{
location <- myself.location;
}
}
loop i from: 0 to: 3 {
if (i < 3) {
water_node nx1 <- first(water_node overlapping plot_cell[i,0]);
water_node nx2 <- first(water_node overlapping plot_cell[i+1,0]);
add to:my_graph edge: nx1::nx2 ;
}
loop j from: 0 to: 3 {
water_node ny1 <- first(water_node overlapping plot_cell[i,j]);
water_node ny2 <- first(water_node overlapping plot_cell[i,j+1]);
add to:my_graph edge: ny1::ny2 ;
}
}
}
}
grid plot_cell width: 4 height: 5 neighbours: 4 {
float water_need <- 1.0 ;
float water_taken <- (rnd(1000) / 1000) * 0.01 ;
aspect base {
draw shape color: #gray;
}
}
species water_node {
float water_available;
aspect base {
draw circle(1) color: #blue ;
}
}
experiment sandboxDammAgent type: gui {
output {
display "grid 1" {
species plot_cell aspect: base;
graphics "links" {
loop link over: my_graph.edges {
draw link color: #white;
}
}
species water_node aspect: base;
}
}
}
--
You received this message because you are subscribed to the Google Groups "GAMA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gama-platfor...@googlegroups.com.
To post to this group, send email to gama-p...@googlegroups.com.
Visit this group at https://groups.google.com/group/gama-platform.
For more options, visit https://groups.google.com/d/optout.