model NewModel
global{
int grid_size <- 15 min: 5 max: 100 parameter: true;
init{
create people number: 350{
current_cell <- one_of(cell);
location <- current_cell.location;
}
}
reflex printAllCellMemo{
loop i from: 0 to: grid_size {
loop j from: 0 to: grid_size {
write ""+ i + " , " + j + " -> " + cell[i,j].mat2;
}
}
}
}
species people{
rgb color <- rnd_color(255);
cell current_cell;
reflex move {
cell c <- (one_of (cell));
if((current_cell.grid_x != c.grid_x) and (current_cell.grid_y != c.grid_y)){
current_cell.mat2[c.grid_x,c.grid_y] <- (current_cell.mat2[c.grid_x,c.grid_y] + 1);
current_cell <- c;
location <- c.location;
}
}
aspect default {
draw sphere(1) at: {location.x,location.y,2} color: color;
}
}
grid cell width: grid_size height: grid_size {
matrix mat2 <- 0.0 as_matrix({grid_size,grid_size});
}
experiment goto_grid type: gui {
output {
display objects_display type: opengl{
grid cell lines: #black;
species people;
}
}
}
--
You received this message because you are subscribed to a topic in the Google Groups "GAMA" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gama-platform/kWhT7nI2Zzg/unsubscribe.
To unsubscribe from this group and all its topics, 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.
model NewModel
global{
int grid_size <- 5 min: 5 max: 100 parameter: true;
init{
create people number: 10{
current_cell <- one_of(cell);
location <- current_cell.location;
}
}
// reflex printAllCellMemo when: cycle<100{
// loop i from: 0 to: grid_size {
// loop j from: 0 to: grid_size {
// write ""+ i + " , " + j + " -> " + cell[i,j].mat2;
// }
// }
reflex computeProba when: cycle=100{
loop i from: 0 to: grid_size - 1 {
loop j from: 0 to: grid_size - 1 {
int sum <- cell[i,j].mat2 sum_of( each );
if(sum > 0){
loop k from: 0 to: grid_size - 1 {
loop l from: 0 to: grid_size - 1 {
cell[i,j].mat2[k,l] <- cell[i,j].mat2[k,l] / sum;
}
}
}
write ""+ i + " , " + j + " -> " + cell[i,j].mat2;
}
save cell to: "../results/cell_Proba.csv" type:"csv" rewrite: true;
do pause;
}
}
species people{
rgb color <- rnd_color(255);
cell current_cell;
reflex move {
cell c <- (one_of (cell));
if((current_cell.grid_x != c.grid_x) and (current_cell.grid_y != c.grid_y)){
current_cell.mat2[c.grid_x,c.grid_y] <- (current_cell.mat2[c.grid_x,c.grid_y] + 1);
current_cell <- c;
location <- c.location;
}
}
aspect default {
draw sphere(1) at: {location.x,location.y,2} color: color;
}
}
}
grid cell width: grid_size height: grid_size {
matrix mat2 <- 0.0 as_matrix({grid_size,grid_size});
}
experiment goto_grid type: gui {
output {
display objects_display type: opengl{
grid cell lines: #black;
species people;
}
}
To unsubscribe from this group and all its topics, send an email to gama-platform+unsubscribe@googlegroups.com.
To unsubscribe from this group and all its topics, 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.
--
You received this message because you are subscribed to a topic in the Google Groups "GAMA" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gama-platform/kWhT7nI2Zzg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gama-platfor...@googlegroups.com.