gama-platform / gama.old

Main repository for developing the 1.x versions of GAMA
GNU General Public License v3.0
304 stars 99 forks source link

Trace triggering from a key doesn't have the same behavior depending on the initial value of the facet trace #3498

Closed agrignard closed 2 years ago

agrignard commented 2 years ago

Describe the bug I want to press a key ('t') to trigger or not the trace facet on a specific layer (e.g people)

I wanted to use something like this

event["t"] {show_trace<-!show_trace;}
species cell trace:(show_trace ? 10: 0);

So far so good when you initialize show_trace to true (if you press the key 't' the trace will be on and off)

bool show_trace<-true;

now if you initialize show_trace to false (ones might not want to see the trace at the beginning of the simualton especially if it's too show a feature)

bool show_trace<-false;

Then pressing 't' as no effect To Reproduce Run this model and just change the initial value of show_trace

/**
* Name: Moving cells
* Author: Arnaud Grignard
* Description: Second part of the tutorial : Tuto3D
* Tags: grid, agent_movement
*/
model Tuto3D   

global {
    int nb_cells <- 100;
    int environment_size <- 100;
    bool show_trace<-false; 
    geometry shape <- cube(environment_size);

    init {
        create cell number: nb_cells {
            location <- {rnd(environment_size), rnd(environment_size), rnd(environment_size)};
        }
    }
}

species cell skills: [moving3D] {
    reflex move {
        do move;
    }

    aspect default {
        draw sphere(environment_size * 0.01) color: #blue;
    }
}

experiment Tuto3D type: gui {
    parameter "Initial number of cells: " var: nb_cells min: 1 max: 1000 category: "Cells";
    output {
        display View1 type: opengl {
            graphics "env" {
                draw cube(environment_size) color: #black wireframe: true;
            }
            event["t"] {show_trace<-!show_trace;}
            species cell trace:(show_trace ? 10: 0);
        }
    }
}

Expected behavior Same effect whatever is the value of show_trace

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

AlexisDrogoul commented 2 years ago

This issue is normally fixed. Please check the latest commit ! https://github.com/gama-platform/gama/commit/381a0b870551317f2279bca59212d0ce4fc792d2

agrignard commented 2 years ago

Great! Sorry for this tricky bug not easy to track and also not easy to get either (who on earth want to trigger a trace by pressing a key !)

I'll try the last commit and try to check as much as possible if it has other effect and other layers

agrignard commented 2 years ago

Just tested on GAMA_1.8.2_MacOS_M1_with_JDK_10.13.22_f53a785c and it works