massim.competition2012
Class GraphSimulationWorldState

java.lang.Object
  extended by massim.gridsimulations.SimulationWorldState
      extended by massim.competition2012.GraphSimulationWorldState
All Implemented Interfaces:
java.io.Serializable, WorldState

public class GraphSimulationWorldState
extends SimulationWorldState
implements WorldState

Holds the current state of a graph simulation (2012 Mars Scenario)

See Also:
Serialized Form

Field Summary
protected  java.util.Map<java.lang.String,GraphSimulationAgentState> agentNamesMap
          A map from an agent's name to its current state.
protected  java.util.Vector<GraphSimulationAgentState> agents
          A vector holding all agents that take part in the simulation.
protected  GraphSimulationConfiguration config
          The configuration of this simulation.
protected  java.util.Map<GraphNode,java.util.List<GraphEdge>> connectedEdgesMap
          A map holding the list of edges connected to each node.
protected  java.util.Vector<GraphEdge> edges
          The edges conforming the map graph.
protected  java.util.Map<GraphNode,java.util.List<GraphNode>> neighborsMap
          A map holding the list of nodes directly connected to each node.
protected  java.util.Map<java.lang.String,GraphNode> nodeNamesMap
          A map from a node's name to its current state.
protected  java.util.Vector<GraphNode> nodes
          The nodes conforming the map graph.
protected  int sizeX
          The width of the abstract grid to which the graph is subscribed.
protected  int sizeY
          The height of the abstract grid to which the graph is subscribed.
 java.util.Vector<TeamState> teamsStates
          A vector holding the states of all the teams that take part in the simulation.
 
Fields inherited from class massim.gridsimulations.SimulationWorldState
actionSuccessProbability, currentStep, informationDistortionProbability, maxNumberOfSteps, numberOfAgents, numberOfObstacles, numberOfSteps, outputFolder, simulationName, sizex, sizey, teamName, teamScore, tournamentName
 
Constructor Summary
GraphSimulationWorldState(GraphSimulationConfiguration config)
          Creates a simulation state as defined by config
 
Method Summary
 void addAgent(GraphSimulationAgentState agent, java.util.Vector<java.lang.Integer> agentPositions, boolean newPosition)
          Adds agent to the currently simulation, and situates it in a random node in the map.
 GraphSimulationAgentState getAgent(java.lang.String agentName)
          Returns the state of an agent given its name.
 java.util.Vector<GraphSimulationAgentState> getAgents()
          getter for the vector holding all agents that take part in the simulation.
 GraphSimulationConfiguration getConfig()
          getter for the configuration object.
 java.util.List<GraphEdge> getConnectedEdges(GraphNode node)
          Returns the list of the edges connected to node
 java.util.List<GraphNode> getNeighborNodes(GraphNode node)
          Returns the list of the nodes directly connected to node
 GraphNode getNode(java.lang.String nodeName)
          Returns the node object representation given its name.
 java.util.Collection<GraphNode> getNodes()
          getter for the vector holding all nodes of the map.
 java.lang.String getTeamName(int number)
          Provides a numeric representation of the team name, null if the number does not correspond to any team.
 int getTeamNr(java.lang.String name)
          Returns a numeric representation of the team name, -1 if the team has not been added to the teams list of the simulation.
 TeamState getTeamState(java.lang.String name)
          Returns the state of team given its name.
protected  void populateMapsCahes()
          Initialize the maps used as cache for faster data access.
 void setAgents(java.util.Vector<GraphSimulationAgentState> agents)
          setter for the vector holding all agents that take part in the simulation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

nodes

protected java.util.Vector<GraphNode> nodes
The nodes conforming the map graph.


edges

protected java.util.Vector<GraphEdge> edges
The edges conforming the map graph.


neighborsMap

protected java.util.Map<GraphNode,java.util.List<GraphNode>> neighborsMap
A map holding the list of nodes directly connected to each node. It is used as a cache to provide fast access to this information that is heavily accessed during the simulation execution.


connectedEdgesMap

protected java.util.Map<GraphNode,java.util.List<GraphEdge>> connectedEdgesMap
A map holding the list of edges connected to each node. It is used as a cache to provide fast access to this information that is heavily accessed during the simulation execution.


agentNamesMap

protected java.util.Map<java.lang.String,GraphSimulationAgentState> agentNamesMap
A map from an agent's name to its current state. It is used as a cache to provide fast access to this information that is heavily accessed during the simulation execution.


nodeNamesMap

protected java.util.Map<java.lang.String,GraphNode> nodeNamesMap
A map from a node's name to its current state. It is used as a cache to provide fast access to this information that is heavily accessed during the simulation execution.


agents

protected java.util.Vector<GraphSimulationAgentState> agents
A vector holding all agents that take part in the simulation.


config

protected GraphSimulationConfiguration config
The configuration of this simulation.


teamsStates

public java.util.Vector<TeamState> teamsStates
A vector holding the states of all the teams that take part in the simulation.


sizeX

protected int sizeX
The width of the abstract grid to which the graph is subscribed.


sizeY

protected int sizeY
The height of the abstract grid to which the graph is subscribed.

Constructor Detail

GraphSimulationWorldState

public GraphSimulationWorldState(GraphSimulationConfiguration config)
Creates a simulation state as defined by config

Parameters:
config -
Method Detail

populateMapsCahes

protected void populateMapsCahes()
Initialize the maps used as cache for faster data access.


getAgents

public java.util.Vector<GraphSimulationAgentState> getAgents()
getter for the vector holding all agents that take part in the simulation.

Returns:

setAgents

public void setAgents(java.util.Vector<GraphSimulationAgentState> agents)
setter for the vector holding all agents that take part in the simulation.

Parameters:
agents -

getConfig

public GraphSimulationConfiguration getConfig()
getter for the configuration object.

Returns:

getAgent

public GraphSimulationAgentState getAgent(java.lang.String agentName)
Returns the state of an agent given its name.

Parameters:
agentName -
Returns:

getNode

public GraphNode getNode(java.lang.String nodeName)
Returns the node object representation given its name.

Parameters:
nodeName -
Returns:

getNeighborNodes

public java.util.List<GraphNode> getNeighborNodes(GraphNode node)
Returns the list of the nodes directly connected to node

Parameters:
node -
Returns:

getConnectedEdges

public java.util.List<GraphEdge> getConnectedEdges(GraphNode node)
Returns the list of the edges connected to node

Parameters:
node -
Returns:

getNodes

public java.util.Collection<GraphNode> getNodes()
getter for the vector holding all nodes of the map.

Returns:

addAgent

public void addAgent(GraphSimulationAgentState agent,
                     java.util.Vector<java.lang.Integer> agentPositions,
                     boolean newPosition)
Adds agent to the currently simulation, and situates it in a random node in the map.

Parameters:
agent -

getTeamNr

public int getTeamNr(java.lang.String name)
Returns a numeric representation of the team name, -1 if the team has not been added to the teams list of the simulation. The number representation is arbitrary, possibly affected by the order in which teams are added, and should remain for the duration of the match.

Parameters:
name -
Returns:

getTeamName

public java.lang.String getTeamName(int number)
Provides a numeric representation of the team name, null if the number does not correspond to any team. The number representation is arbitrary, possibly affected by the order in which teams are added, and should remain for the duration of the match.

Parameters:
name -
Returns:

getTeamState

public TeamState getTeamState(java.lang.String name)
Returns the state of team given its name.

Parameters:
name -
Returns:


Copyright © 2012. All Rights Reserved.