Thibaut Démare
LITIS - Université du Havre
NeX Days' 2015 - Agadir, Morocco
28 - 30 April 2015
Netstream is basically a network protocol aiming at opening the GraphStream project access to other tools/projects/programs especially those written in other languages than Java. The interface is managed through a network interface (client/server approach).
gs-gama allows to connect a GAMA simulation with an external software supporting the NetStream protocol, such as GraphStream-based applications..
https://github.com/graphstream/gs-gama/wiki
GAMAProjectfolder as a project. Go to:
File > Import... > General > Existing projects into workspace
Demo_NeX2015and click on
Finish.
NetStreamReceiver receiver = new NetStreamReceiver("localhost", 2001);
Viewer v = new Viewer(receiver.getDefaultStream());
v.addDefaultView(true);
gs_clear_senders;
gs_add_sender gs_host:"localhost" gs_port:2001 gs_sender_id:"humans";
init {
gs_add_node gs_sender_id:"humans" gs_node_id:name;
gs_add_node_attribute gs_sender_id:"humans" gs_node_id:name gs_attribute_name:"x" gs_attribute_value:location.x;
gs_add_node_attribute gs_sender_id:"humans" gs_node_id:name gs_attribute_name:"y" gs_attribute_value:location.y*-1;
}
reflex move {
if(tar.x = location.x and tar.y = location.y){
tar <- any_location_in(world.shape);
}
do goto target:tar speed: 5;
gs_add_node_attribute gs_sender_id:"humans" gs_node_id:name gs_attribute_name:"x" gs_attribute_value:location.x;
gs_add_node_attribute gs_sender_id:"humans" gs_node_id:name gs_attribute_name:"y" gs_attribute_value:location.y*-1;
}
if(distance_to(self, humans_connected[i]) > length){
gs_remove_edge gs_sender_id:"humans" gs_edge_id:(name + humans_connected[i].name);
remove index:i from: humans_connected;
}
And add new edges for new connection
if(!contains(humans_connected, humans[i])){
humans_connected <- humans_connected + humans[i];
gs_add_edge gs_sender_id:"humans" gs_edge_id:(name + humans[i].name) gs_node_id_from:name gs_node_id_to:humans[i].name gs_is_directed:true;
}
Get the Slides and Materials on-line:
NeX2015)