Package eu.su.mas.dedale.env.gs
Class gsEnvironment
java.lang.Object
eu.su.mas.dedale.env.gs.gsEnvironment
- All Implemented Interfaces:
IEnvironment
This class is an implementation of the IEnvironment using the graphStream library
It currently offers :
- several environments generators and any predefined ones that respect the DGS format
- 3 types of agents (tanker, explorer and collector),
- 2 type of wumpus (which generates stench),
- 1 type of keyboardControlled agent (Human), that must be unique on a given instance.
- Well (that generate wind and kill the agents that come in them),
- 2 types of treasures (gold and diamonds) with safes with 2 opening conditions (lockpicking expertise and strength)
- Author:
- hc
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanClose the lock of the safe (if any) on the current location Do not work if there are severalvoidCreateEnvironment(GeneratorType g, String topologyConfigurationFilePath, String instanceConfiguration, boolean diamond, boolean gold, boolean well, Integer... topologyParameters) Create an environment.voiddeployEntity(String entityName, EntityCharacteristics e, Location locationId) Add an entity to the graphbooleandropOff(Location location, ElementType e, Integer quantity) There can be only one safe of one unique type on a given location.getCurrentPosition(String entityName) getName()getOoa()getUserChoosenPath(String agentName) booleanisReachable(String senderName, String receiverName, int communicationReach) This method must be synchronized due tothe way graphStream computes the shortestPathmoveTo(String entityName, EntityCharacteristics e, Location targetedPosition) List<dataStructures.tuple.Couple<Location, List<dataStructures.tuple.Couple<Observation, String>>>> booleanopenLock(String entityName, Location location, ElementType e) intpick(String agentName, Location currentPosition, ElementType e, Integer maxQuantity) voidremoveEntity(String entityName, EntityCharacteristics e) booleanthrowGrenade(String agentName, Location targetName) voidvoidupdateCommunicationStats(int nbSent, int nbReceived) Update the nb of messages sent and effectively transmittedvoidvoidupdateUserChoosenPath(String agentName) When the user select next, we update the proposed path in incremental order of the neighbours id (whatever the sorting algo)
-
Constructor Details
-
gsEnvironment
public gsEnvironment()
-
-
Method Details
-
CreateEnvironment
public void CreateEnvironment(GeneratorType g, String topologyConfigurationFilePath, String instanceConfiguration, boolean diamond, boolean gold, boolean well, Integer... topologyParameters) Description copied from interface:IEnvironmentCreate an environment.- Specified by:
CreateEnvironmentin interfaceIEnvironment- Parameters:
g- type of generator to usetopologyConfigurationFilePath- fullPath towards the topology fileinstanceConfiguration- fullPath towards the file indicating the elements on the mapdiamond- true is we should generate diamondsgold- true is we should generate goldswell- true is we should generate wellstopologyParameters- at least, indicate the size of the environment to generate, if necessary add the generatorType specific parameters
-
deployEntity
Description copied from interface:IEnvironmentAdd an entity to the graph- Specified by:
deployEntityin interfaceIEnvironment- Parameters:
entityName- Should be uniquee- Type of the agentlocationId- position where to deploy the agent, null if free Add the agent entityName of type e on the position locationId
-
removeEntity
- Specified by:
removeEntityin interfaceIEnvironment
-
getCurrentPosition
- Specified by:
getCurrentPositionin interfaceIEnvironment- Parameters:
entityName- Name of the agent to locate- Returns:
- The entity current position, null if the entity is not in the environment
-
observe
public List<dataStructures.tuple.Couple<Location,List<dataStructures.tuple.Couple<Observation, observeString>>>> (Location currentPosition, String agentName) - Specified by:
observein interfaceIEnvironment- Parameters:
currentPosition- the position from which the agent observeagentName- the name of the agent- Returns:
- The list of observed positions, and for each one the list of observations
-
moveTo
- Specified by:
moveToin interfaceIEnvironment- Parameters:
entityName- the name of the entitye- characteristics of the entitytargetedPosition- its expected destination- Returns:
- 1 if true, 0 if refused, -1 if the consequence of the move is the agent dying
-
openLock
- Specified by:
openLockin interfaceIEnvironment- Parameters:
entityName- the name of the entitylocation- the position to pick the resourcee- Type of resource to unlock in the environment (Currently only gold or diamond )- Returns:
- True is the lock is opened, false otherwise
-
closeLock
Close the lock of the safe (if any) on the current location Do not work if there are several- Specified by:
closeLockin interfaceIEnvironment- Parameters:
location- the position to close the safe(s)- Returns:
- True if there was at least one safe on the current position (they are now closed), false otherwise
-
pick
- Specified by:
pickin interfaceIEnvironment- Parameters:
agentName- the name of the entitycurrentPosition- the position to pick the resourcee- ElementType to pickmaxQuantity- maximum number of e that the agent is able to pick- Returns:
- the amount of resources that the agent was able to collect
-
dropOff
There can be only one safe of one unique type on a given location.- Specified by:
dropOffin interfaceIEnvironment- Parameters:
location- id of the node where to drop the elemente- the element the entity intends to dropquantity- the amount of value to drop on the current position- Returns:
- true if the drop off was realised
-
throwGrenade
- Specified by:
throwGrenadein interfaceIEnvironment- Parameters:
agentName- The name of the agent that is shootingtargetName- the id of the room it aims at- Returns:
- true if done, false otherwise
-
isReachable
This method must be synchronized due tothe way graphStream computes the shortestPath- Specified by:
isReachablein interfaceIEnvironment- Parameters:
senderName- name of the entity willing to send the messagereceiverName- name of the receivercommunicationReach- number of hops autorised to reach the targer- Returns:
- true if the receiver is within reach
-
getName
- Specified by:
getNamein interfaceIEnvironment- Returns:
- The name of the environment
-
updateNodeInterfaceComRendering
-
updateCommunicationStats
public void updateCommunicationStats(int nbSent, int nbReceived) Update the nb of messages sent and effectively transmitted- Parameters:
nbSent- number of messages sentnbReceived- number of messages received (as the messages can be losts if agents are out of reach)
-
updateAgentsStatsWithinGui
public void updateAgentsStatsWithinGui() -
getAgentToKill
- Returns:
- the (local)name of the agent the user wants to terminate
-
getOoa
- Returns:
- Return the object used to the observer of the agent state and sent to the GUI for stat updating
-
getGuiController
- Returns:
- Method used by the user-controlled agent to connect him to the events the gui receives (to move the agent)
-
getUserChoosenPath
- Parameters:
agentName- name of the agent controlled by the user- Returns:
- the node currently proposed as next destination to the user
-
updateUserChoosenPath
When the user select next, we update the proposed path in incremental order of the neighbours id (whatever the sorting algo)- Parameters:
agentName- name of the agent controlled by the user
-