Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Library Models] Turning global facet torus to true messes up agents display with certain models #3783

Closed
chapuisk opened this issue Apr 17, 2023 · 5 comments
Assignees
Labels
About GAML This issue concerns the GAML language About Models Library This issue or request concerns the models shipped with GAMA 😱 Bug The issue reveals a bug in GAMA 🖥 Display OpenGL This issue or request concerns only OpenGL displays V. 1.9.1 Bug specific to the 1.9.1 release
Milestone

Comments

@chapuisk
Copy link
Contributor

Describe the bug

I run into examples of models from the library (Ant Foraging.gaml and soccer.gaml) where turning global facet torus to true, makes display not displaying agent or env anymore. It also raises a NPE related to OpenGL: the two lines

Runtime error null in OpenGL loop
java.lang.NullPointerException

keeps repeating in eclipse console, even when the model is paused.

To Reproduce
Steps to reproduce the behavior:

  1. Go to Library models > Toy models > Ants (Foraging and Sorting) > Ant Foraging.gaml (same with soccer.gaml)
  2. Put torus: true in global definition
  3. Run classic simulation experiment
  4. See main display fully black (with soccer.gaml agent do not show up anymore, and turning param "display marked player" to true raises the error)

Expected behavior
Displays run as if the environment was not a torus one. I do not know exactly how torus world should be considered, but there is example of models (boids.gaml for instance) that work like a charm with toroidal environment...

Screenshots

With torus off:
Screen Shot 2023-04-17 at 11 58 18

With torus on:
Screen Shot 2023-04-17 at 11 57 08

Desktop (please complete the following information):

  • OS: MacOS Monterey
  • PC Model: Apple M1
  • GAMA version: Gama git 1.9.2
  • Java version: JDK17
  • Graphics cards / Display system: Apple M1 chipset

Additional context
The facet initially messes up with one of my model (agent appeared glitched, with part of drawn geometry missing, huge in size, etc.) , and then I investigate potential same behavior in model library. All models that feature torus global by default works as intended.

@chapuisk chapuisk added 😱 Bug The issue reveals a bug in GAMA About GAML This issue concerns the GAML language 🖥 Display OpenGL This issue or request concerns only OpenGL displays About Models Library This issue or request concerns the models shipped with GAMA V. 1.9.1 Bug specific to the 1.9.1 release labels Apr 17, 2023
@AlexisDrogoul
Copy link
Member

I can reproduce it on Ant Foraging. Commenting the line draw line([location + {0, 0, 0.5}, {location.x + 5 * cos(heading), location.y + 5 * sin(heading)} + {0, 0, 0.5}]) + 0.1 color: #white border: false end_arrow: 1.2; in the aspect makes it work like a charm however. Inspecting further, removing the end_arrow: facet is enough, so I suspect there is something fishy with the arrows and how they are drawn in a torus environment. Does you model have similar artefacts ?

@AlexisDrogoul AlexisDrogoul self-assigned this Apr 17, 2023
@AlexisDrogoul AlexisDrogoul added this to the GAMA 1.9.2 milestone Apr 17, 2023
@chapuisk
Copy link
Contributor Author

@AlexisDrogoul well, my model is way much simpler than ant one. If I remove aspect of agent, there are well displayed as points. Even a simple draw self, failed to render agent, which do not have any explicit shape.

@AlexisDrogoul
Copy link
Member

Can you share it ?

@chapuisk
Copy link
Contributor Author

Here is the model:

global {

string COWARD <- "coward";
string HERO <- "hero";
list behavior <- [COWARD,HERO];
map<string,rgb> behavior_color <- [COWARD::#darkred,HERO::#darkgreen];

float coward_x_heroes <- 0.0 parameter:true min:0.0 max:1.0 on_change:update_state;

init { create people number:100; do update_state; do ufe; }

action update_state {
	list cowards <- int(length(people) * (1-coward_x_heroes)) among people;  
	ask cowards { state <- COWARD; }
	ask people - cowards { state <- HERO; }
}

action ufe { ask people {do choose_a_friend; do choose_an_enemy;}}

}

species people skills:[moving] {

people friend;
people enemy;

string state;

reflex move { do goto target:choose_a_target(); }

point choose_a_target {
	switch state {
		match COWARD {return {friend.location.x + (friend.location.x - enemy.location.x) / 2,
				friend.location.y + (friend.location.y - enemy.location.y) / 2};}
		match HERO {return {(friend.location.x + enemy.location.x) / 2,
     			(friend.location.y + enemy.location.y) / 2};}
	}
}

action choose_a_friend { friend <- any(people-self-friend-enemy); }
action choose_an_enemy { enemy <- any(people-self-friend-enemy); }

aspect default { draw triangle(1#m) color: behavior_color[state] rotate: heading + 90.0; }

}

experiment xp {

user_command "Randomize" color:#darkblue {ask world {do ufe();}}
user_command "Relocate" color:#darkblue {ask people {location <- any_location_in(world.shape);}}

float minimum_cycle_duration <- 0.02;

output { display main {species people;}}

}

@AlexisDrogoul
Copy link
Member

I fixed the error. However, the behavior of the model is not completely clear to me and I suspect that models using the moving skill will never properly work in a torus environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
About GAML This issue concerns the GAML language About Models Library This issue or request concerns the models shipped with GAMA 😱 Bug The issue reveals a bug in GAMA 🖥 Display OpenGL This issue or request concerns only OpenGL displays V. 1.9.1 Bug specific to the 1.9.1 release
Projects
None yet
Development

No branches or pull requests

2 participants