Skip to content
This repository has been archived by the owner on Jul 30, 2024. It is now read-only.

Commit

Permalink
fixes lot of minor issues for code examples
Browse files Browse the repository at this point in the history
  • Loading branch information
ptaillandier committed May 7, 2024
1 parent a2ef2be commit b098847
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ global {

init {
create dynamic_geometry_agent number: 10 {
shape <- circle(5);
shape <- square(5);
}

create dynamic_punctual_agent number: 10 ;
Expand Down Expand Up @@ -54,6 +54,9 @@ species unity_linker parent: abstract_unity_linker {
//in this model, the agents location and heading will be sent to the Players at every step, so we set do_info_world to true
bool do_send_world <- true;

//initial location of the player
list<point> init_locations <- [world.location];


init {
//define the unity properties
Expand Down Expand Up @@ -89,14 +92,43 @@ species unity_linker parent: abstract_unity_linker {
reflex send_agents when: not empty(unity_player) {
do add_geometries_to_send(dynamic_punctual_agent,up_car);
do add_geometries_to_send(dynamic_geometry_agent,up_geom);


}
}


//species used to represent an unity player, with the default attributes. It has to inherit from the built-in species asbtract_unity_player
species unity_player parent: abstract_unity_player;
species unity_player parent: abstract_unity_player {
//size of the player in GAMA
float player_size <- 1.0;

//color of the player in GAMA
rgb color <- #red ;

//vision cone distance in GAMA
float cone_distance <- 10.0 * player_size;

//vision cone amplitude in GAMA
float cone_amplitude <- 90.0;

//rotation to apply from the heading of Unity to GAMA
float player_rotation <- 90.0;

//display the player
bool to_display <- true;


//default aspect to display the player as a circle with its cone of vision
aspect default {
if to_display {
if selected {
draw circle(player_size) at: location + {0, 0, 4.9} color: rgb(#blue, 0.5);
}
draw circle(player_size/2.0) at: location + {0, 0, 5} color: color ;
draw player_perception_cone() color: rgb(color, 0.5);
}
}
}
experiment main type: gui {
output {
display map {
Expand All @@ -110,7 +142,7 @@ experiment main type: gui {
//The unity type allows to create at the initialization one unity_linker agent
experiment vr_xp parent:main autorun: false type: unity {
//minimal time between two simulation step
float minimum_cycle_duration <- 0.25;
float minimum_cycle_duration <- 0.05;

//name of the species used for the unity_linker
string unity_linker_species <- string(unity_linker);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ species unity_linker parent: abstract_unity_linker {
//send a message to all players; the message should be a map (key: name of the attribute; value: value of this attribute)
//the name of the attribute should be the same as the variable in the serialized class in Unity (c# script)
write "Send message: " + cycle;
do send_message players: unity_player as list mes: ["cycle:":: cycle];
do send_message players: unity_player as list mes: ["cycle":: cycle];
}

//action that will be called by the Unity player to send a message to the GAMA simulation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ global {

species static_punctual_agent {
aspect default {
draw circle(10) color: #red;
draw circle(10) color: #green;
}
}

Expand All @@ -55,6 +55,10 @@ species unity_linker parent: abstract_unity_linker {
bool do_send_world <- false;


//initial location of the player
list<point> init_locations <- [world.location];


init {
//define the unity properties
do define_properties;
Expand Down Expand Up @@ -94,9 +98,38 @@ species unity_linker parent: abstract_unity_linker {
}
}


//species used to represent an unity player, with the default attributes. It has to inherit from the built-in species asbtract_unity_player
species unity_player parent: abstract_unity_player;
species unity_player parent: abstract_unity_player {
//size of the player in GAMA
float player_size <- 1.0;

//color of the player in GAMA
rgb color <- #red ;

//vision cone distance in GAMA
float cone_distance <- 10.0 * player_size;

//vision cone amplitude in GAMA
float cone_amplitude <- 90.0;

//rotation to apply from the heading of Unity to GAMA
float player_rotation <- 90.0;

//display the player
bool to_display <- true;


//default aspect to display the player as a circle with its cone of vision
aspect default {
if to_display {
if selected {
draw circle(player_size) at: location + {0, 0, 4.9} color: rgb(#blue, 0.5);
}
draw circle(player_size/2.0) at: location + {0, 0, 5} color: color ;
draw player_perception_cone() color: rgb(color, 0.5);
}
}
}


experiment main type: gui {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,10 @@ species unity_linker parent: abstract_unity_linker {
//action that defines the different unity properties
action define_properties {

//define a unity_aspect called gray_square_aspect that will display the agents using their geometries, with a height of 2 meters, the gray color, and we use the default precision.
unity_aspect gray_square_aspect <- geometry_aspect(2.0, #gray, precision);
//define a unity_aspect called gray_square_aspect that will display in Unity the agents with the Gray Cube prefab, with a scale of 1.0, a y-offset of 0.5,
//a rotation coefficient of 1.0 (no change of rotation from the prefab), no rotation offset, and we use the default precision.
unity_aspect gray_square_aspect <- prefab_aspect("Prefabs/Visual Prefabs/Basic shape/Gray Cube",1.0,0.5,1.0,0.0, precision);


//define the up_no_interaction unity property, with the name "no interaction", no specific layer, the gray_square_aspect aspect, no interaction, and the agents location are not sent back
//to GAMA.
Expand All @@ -105,8 +107,11 @@ species unity_linker parent: abstract_unity_linker {
unity_properties << up_no_interaction;


//define a unity_aspect called gray_square_aspect that will display the agents using their geometries, with a height of 2 meters, the yellow color, and we use the default precision.
unity_aspect yellow_square_aspect <- geometry_aspect(2.0, #yellow, precision);
//define a unity_aspect called gray_square_aspect that will display in Unity the agents with the Yellow Cube prefab, with a scale of 1.0, a y-offset of 0.5,
//a rotation coefficient of 1.0 (no change of rotation from the prefab), no rotation offset, and we use the default precision.
unity_aspect yellow_square_aspect <- prefab_aspect("Prefabs/Visual Prefabs/Basic shape/Yellow Cube",1.0,0.5,1.0,0.0, precision);

//unity_aspect yellow_square_aspect <- geometry_aspect(2.0, #yellow, precision);

//define the up_collider unity property, with the name "collider", no specific layer, the yellow_square_aspect aspect, a collider interaction, and the agents location are not sent back
//to GAMA.
Expand All @@ -116,8 +121,10 @@ species unity_linker parent: abstract_unity_linker {
unity_properties << up_collider;


//define a unity_aspect called gray_square_aspect that will display the agents using their geometries, with a height of 2 meters, the green color, and we use the default precision.
unity_aspect green_square_aspect <- geometry_aspect(2.0, #green, precision);
//define a unity_aspect called gray_square_aspect that will display in Unity the agents with the Green Cube prefab, with a scale of 1.0, a y-offset of 0.5,
//a rotation coefficient of 1.0 (no change of rotation from the prefab), no rotation offset, and we use the default precision.
unity_aspect green_square_aspect <- prefab_aspect("Prefabs/Visual Prefabs/Basic shape/Green Cube",1.0,0.5,1.0,0.0, precision);


//define the up_collider unity property, with the name "collider", no specific layer, the green_square_aspect aspect, the possibility to interact with the objects through the ray interactor, and the agents location are not sent back
//to GAMA.
Expand All @@ -127,12 +134,13 @@ species unity_linker parent: abstract_unity_linker {
unity_properties << up_ray_interaction;


//define a unity_aspect called gray_square_aspect that will display the agents using their geometries, with a height of 2 meters, the pink color, and we use the default precision.
unity_aspect pink_square_aspect <- geometry_aspect(2.0, #pink, precision);
//define a unity_aspect called gray_square_aspect that will display in Unity the agents with the Pink Cube prefab, with a scale of 1.0, a y-offset of 0.5,
//a rotation coefficient of 1.0 (no change of rotation from the prefab), no rotation offset, and we use the default precision.
unity_aspect pink_square_aspect <- prefab_aspect("Prefabs/Visual Prefabs/Basic shape/Pink Cube",1.0,0.5,1.0,0.0, precision);

//define the up_grab_interaction unity property, with the name "grab interaction", no specific layer, the pink_square_aspect aspect, the possibility to grab the object, and the agents location are sent back
//to GAMA.
up_grab_interaction <- geometry_properties("grab interaction", nil, pink_square_aspect, #grabable, false);
up_grab_interaction <- geometry_properties("grab interaction", nil, pink_square_aspect, #grabable, true);

// add the up_geom up_grab_interaction to the list of unity_properties
unity_properties << up_grab_interaction;
Expand All @@ -157,7 +165,37 @@ species unity_linker parent: abstract_unity_linker {


//species used to represent an unity player, with the default attributes. It has to inherit from the built-in species asbtract_unity_player
species unity_player parent: abstract_unity_player;
species unity_player parent: abstract_unity_player {
//size of the player in GAMA
float player_size <- 1.0;

//color of the player in GAMA
rgb color <- #red ;

//vision cone distance in GAMA
float cone_distance <- 10.0 * player_size;

//vision cone amplitude in GAMA
float cone_amplitude <- 90.0;

//rotation to apply from the heading of Unity to GAMA
float player_rotation <- 90.0;

//display the player
bool to_display <- true;


//default aspect to display the player as a circle with its cone of vision
aspect default {
if to_display {
if selected {
draw circle(player_size) at: location + {0, 0, 4.9} color: rgb(#blue, 0.5);
}
draw circle(player_size/2.0) at: location + {0, 0, 5} color: color ;
draw player_perception_cone() color: rgb(color, 0.5);
}
}
}


experiment main type: gui {
Expand Down

0 comments on commit b098847

Please sign in to comment.