mas.agentsHempelsSofa.data.zone
Class ZoneManager

java.lang.Object
  extended by mas.agentsHempelsSofa.data.zone.ZoneManager

public class ZoneManager
extends java.lang.Object

An implementation of a zone manager which shall keep all zones up to date. it can be created and there is a single method update() to update all zones.

Author:
Hempels-Sofa

Constructor Summary
ZoneManager(Graph graph)
          Creates a new zone manager.
 
Method Summary
 void addAllIsolatedVertices()
          adds all isolated vertices to each zone.
 void computeDominatingTeams()
          looks up which vertex is dominated by which ownTeam.
 void createElementaryNeighboringZones()
          creates elementary zones for a team out of each vertex, if the following conditioned are complied with.
 void createElementaryZones()
          creates elementary zones for each dominated vertex and saves these in zones.
 void determineTeams(java.lang.String[] dominatingTeams)
          computes a list of all different teams which are dominating at least one vertex.
 boolean enemiesSpotted()
           
 Zone getBiggestEnemyZone()
           
 Zone getBiggestZone()
           
 Zone getMostPreciousEnemyZone()
           
 Zone getMostPreciousZone()
           
 java.util.LinkedList<java.lang.String> getTeams()
           
 int getValue()
           
 int getValue(AgentToken agent)
           
 int getValue(Vertex vertex)
           
 Zone getZone(AgentToken agent)
           
 Zone getZone(Vertex vertex)
           
 java.util.LinkedList<Zone> getZones()
           
 boolean isInMostPreciousZone(Vertex vertex)
           
 void setOwnTeam(java.lang.String ownTeam)
           
 void setTeams(java.util.LinkedList<java.lang.String> teams)
           
 void setZones(java.util.LinkedList<Zone> zones)
           
 java.util.LinkedList<apltk.interpreter.data.LogicBelief> toBeliefs()
           
 java.lang.String toString()
           
 void uniteAllNeighboringZones()
          unites all neighboring zones to one zone in zones.
 void update()
          updates the zone manager. this should be executed everytimes after updating the graph and agent tokens.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ZoneManager

public ZoneManager(Graph graph)
Creates a new zone manager. It manages all zones in the graph.

Parameters:
graph - the graph the zones shall refer to.
ownTeam - the team of the agent which creates this manager.
Method Detail

setOwnTeam

public void setOwnTeam(java.lang.String ownTeam)

update

public void update()
updates the zone manager. this should be executed everytimes after updating the graph and agent tokens.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

computeDominatingTeams

public void computeDominatingTeams()
looks up which vertex is dominated by which ownTeam.


determineTeams

public void determineTeams(java.lang.String[] dominatingTeams)
computes a list of all different teams which are dominating at least one vertex.

Parameters:
dominatingTeams - the array which is a mapping: graph.vertices(i) -> dominatingTeam(i)

createElementaryZones

public void createElementaryZones()
creates elementary zones for each dominated vertex and saves these in zones.


createElementaryNeighboringZones

public void createElementaryNeighboringZones()
creates elementary zones for a team out of each vertex, if the following conditioned are complied with.
  1. at least two zones of the same team are neighboring the vertex.
  2. the team has more neighboring zones to the vertex than each other teams.


uniteAllNeighboringZones

public void uniteAllNeighboringZones()
unites all neighboring zones to one zone in zones.


addAllIsolatedVertices

public void addAllIsolatedVertices()
adds all isolated vertices to each zone. This can be incorrectly calculated if there is no enemy agent is spotted yet and the percepted value is not set. So it is recommended to pass the percepted value of each zone of the own team. The stability value is computed too.


getValue

public int getValue()
Returns:
the total value of all zones of the own team.

getValue

public int getValue(Vertex vertex)
Parameters:
vertex - the vertex of one zone.
Returns:
the value of the zone the vertex belongs to. if vertex is in no zone the value will be 0.

getValue

public int getValue(AgentToken agent)
Parameters:
agent - the agent token of one zone
Returns:
the value of the zone the agent is positioned in. if agent is in no zone the value will be 0.

getZone

public Zone getZone(Vertex vertex)
Parameters:
vertex - the vertex of one zone.
Returns:
the zone the vertex belongs to. if the vertex is in no zone the return value will be null.

getZone

public Zone getZone(AgentToken agent)
Parameters:
agent - the agent token of one zone.
Returns:
the zone the agent is positioned in. if the agent is in no zone the return value will be null.

getMostPreciousZone

public Zone getMostPreciousZone()
Returns:
the most precious zone of the own team.

getMostPreciousEnemyZone

public Zone getMostPreciousEnemyZone()
Returns:
the most precious zone of all enemy teams.

getBiggestZone

public Zone getBiggestZone()
Returns:
the zone with the most vertices of the own team.

getBiggestEnemyZone

public Zone getBiggestEnemyZone()
Returns:
the zone with the most vertices of all enemy teams.

enemiesSpotted

public boolean enemiesSpotted()
Returns:
  • true, if there are enemy agent tokens on the graph
  • false, otherwise.

getZones

public java.util.LinkedList<Zone> getZones()
Returns:
all zones

toBeliefs

public java.util.LinkedList<apltk.interpreter.data.LogicBelief> toBeliefs()

isInMostPreciousZone

public boolean isInMostPreciousZone(Vertex vertex)
Parameters:
vertex - the vertex
Returns:
  • true, if the vertex is in the most precious zone of the own team.
  • false, otherwise.

setZones

public void setZones(java.util.LinkedList<Zone> zones)
Parameters:
zones - the zones to set

setTeams

public void setTeams(java.util.LinkedList<java.lang.String> teams)
Parameters:
teams - the teams to set

getTeams

public java.util.LinkedList<java.lang.String> getTeams()
Returns:
the teams


Copyright © 2012. All Rights Reserved.