|
Skills14
Skills(Modeling Guide)
OverviewSkills are built-in modules, written in Java, that provide a set of related built-in variables and built-in actions (in addition to those already provided by GAMA) to the species that declare them. A declaration of skill is done by filling the skills attribute in the species definition: species my_species skills: [skill1, skill2] {
...
}Skills have been designed to be mutually compatible so that any combination of them will result in a functional species. The list of available skills in GAMA is:
So, for instance, if a species is declared as: species foo skills: [moving, carrying]{
...
}its agents will automatically be provided with the following variables : "speed, heading, destination (r/o), capacity, contents(r/o)" and the following actions: "move, goto, wander, drop, load" in addition to those built-in in species and declared by the modeller. Most of these variables, except the ones marked read-only, can be customized and modified like normal variables by the modeller. For instance, one could want to set a maximum for the speed; this would be done by redeclaring it like this: var speed type:float max:100 min:0; Or, to obtain ever growing agents: var speed type:float max:100 min:0 value: area * 1.01; Or, to change their capacity in a behavior: if condition: capacity = 5 {
set capacity value: 10;
}movingvariablesspeedfloat, the speed of the agent, in meter/second. headingint, the absolute heading of the agent in degrees (in the range 0-359). destinationpoint, read-only, continuously updated destination of the agent with respect to its speed and heading. actionsfollowmoves the agent along a given path passed in the arguments.
do action: follow {
arg speed value: speed * 2;
arg path value: road_path;
}gotomoves the agent towards the target passed in the arguments.
do action: goto{
arg target value: one_of (list (species (self)));
arg speed value: speed * 2;
arg on value: road_network;
}movemoves the agent forward, the distance being computed with respect to its speed and heading. The value of the corresponding variables are used unless arguments are passed.
do action: move {
arg speed value: speed - 10;
arg heading value: heading + rnd (30);
arg bounds value: agentA;
}wandermoves the agent towards a random location at the maximum distance (with respect to its speed). The heading of the agent is chosen randomly if no amplitude is specified. This action changes the value of heading.
do action: wander{
arg speed value: speed - 10;
arg amplitude value: 120;
arg bounds value: agentA;
}carryingvariablescapacityint, the maximum number of agents that can be carried contentslist, read-only, the current list of agents carried. actionsdropmakes the agent leave, at its location, all or some of the agents it was carrying.
do action: drop
arg agents value: contents of_species foo;
}loadmakes the agent pick & carry all or some of the agents specified by the arguments.
do action: load {
arg agents value: (agents_overlapping (self)) of_species foo;
arg number value: 10;
}communicatingThis skill implements the major FIPA communication and negotiation protocols and enable the agents to communicate using them. It brings along two new datatypes : message and conversation. GAMA implements the following interaction protocols of FIPA : FIPA Brokering, FIPA Contract Net, FIPA Propose, FIPA Query, FIPA Request, FIPA Request When, FIPA Subscribe. Besides the standard interaction protocols of FIPA, GAMA support a special interaction protocol named "no-protocol". variablesconversationslist, read-only, the conversation in which the agent is currently engaged. messageslist, read-only, the messages received by the agent. accept_proposals, agrees, cancels, cfps, failures, informs, proposes, queries, refuses, reject_proposals, requests, requestWhens, subscribeslist, read-only, the messages received by the agent, broken down by performative. actionssendallows the agent to send an existing message, or to create one and send it immediately. Either use the argument:
Or a combination of the following arguments:
let mes type: list of: message value: [];
create species: message number: 1 return: mes {
set receivers value: (agents_overlapping (self));
set content value:['Hello !'];
set protocol value:'no-protocol';
set performative value:'inform';
}
do action: send {
arg message value: first(mes);
}do action: send {
set receivers value: (agents_overlapping (self));
set content value:['Hello !'];
set protocol value:'no-protocol';
set performative value:'inform';
}end, failure, inform, propose, query, refuse, reject-proposal, request, subscribereplies a list of messages with the corresponding performatives "end", "failure", "inform", "propose", "query", "refuse", "reject-proposal", "request", "subscribe". The replied messages will be filled automatically with the corresponding performatives.
let noProtocolInformMsgs type: list value:(informs) where: ((species (each.sender) = foodCarrier) and (each.protocol = 'no-protocol'));
do action: end {
arg message value: noProtocolInformMsgs;
}data typesmessageAn instance of message represents a piece of information exchanged between agents. It has the following attributes :
conversationAn instance of conversation represents a FIPA interaction protocol. It helps ensure that a conversation between agents respects the specification of a corresponding protocol defined by FIPA. It has the following attributes :
NotesGAMA supports a special interaction protocol named "no-protocol". If the modeller finds that no supported FIPA Interaction Protocols fits his modelling case, he can use the "no-protocol". Uppon declaring a conversation following this procotol, the modeller is free to send messages having whatever performative between agents. But it 's upto the modeller to finish up the corresponding conversation by using the "end" primitive. exploringThis skill implements the patrolling capability of agents, enables the agents to go on patrol in a list of given points. variablespointslist, the list of points to patrol. This list must not be empty before the agents can begin its patrolling activity. patrollingbool, determines if the corresponding agent is going on patrol or not. actionspatroldo the patrolling activity if the list of points is not empty.
task name: patrol_the_terrain while: patrolTheTerrain {
priority if: patrolTheTerrain value: 10 else: 0;
duration max: 2 hours;
repeat action: patrol {
arg speed value: maxSpeed;
}
}
| |