edu.udo.cs.ie.cowbots.internalActions.experimental2
Class exCreatePlan

Package class diagram package exCreatePlan
java.lang.Object
  extended by DefaultInternalAction
      extended by edu.udo.cs.ie.cowbots.internalActions.experimental2.exCreatePlan

public class exCreatePlan
extends DefaultInternalAction

Faster replacement for the dynamic planner. Not really adjustable...


Field Summary
(package private)  java.util.List<java.lang.String> agHelpers
           
(package private)  java.util.HashMap<java.lang.String,java.lang.Integer> agIndex
           
(package private)  java.util.HashMap<java.lang.Integer,java.lang.String> agInvIndex
           
(package private)  java.util.HashMap<java.lang.String,java.awt.Point> agPositions
           
(package private)  java.util.List<java.lang.String> debugLog
           
(package private)  java.util.HashMap<java.awt.Point,java.lang.String> gateDirections
           
(package private)  java.util.HashMap<java.awt.Point,java.awt.Point> gatePositions
           
(package private)  java.util.HashMap<java.lang.String,java.util.List<java.lang.String>> groups
           
(package private)  java.util.ArrayList<java.lang.Integer> ignoreList
           
(package private)  java.lang.String myself
           
(package private)  boolean startWithIgnore
           
 
Constructor Summary
exCreatePlan()
           
 
Method Summary
protected  void buildGroups(BeliefSet bs)
          this method sets up some internal data structure for planning, in this case agent positions and helper lists. the groups list is based on the beliefs of an agent.
 java.lang.Object execute(TransitionSystem ts, Unifier un, Term[] args)
          Used by a teamleader to generate an asl plan to send orders to the team.
protected  void fillGatePositions(TransitionSystem ts)
          Fills the gate positions according to the agents beliefs
protected  java.lang.String getAgentName(int i)
          Returns the agents name, used to send orders in jason
protected  java.awt.Point getNextFencePositionOnPath(java.util.LinkedList<java.awt.Point> path, GridMap map)
          Returns the next fence position on the provided path, or at least a point where the agent should look for a fence
protected  int getNumberOfFencesOnPath(java.util.LinkedList<java.awt.Point> path, GridMap map)
          Returns the number of fences known on the provided path.
 java.awt.Point getSwitchPosition(BeliefSet bs, java.awt.Point aPos, java.awt.Point fencePosition, GridMap map)
          Returns the position of the switch.
protected  boolean isFenceOnPosition(int x, int y, GridMap map)
           
protected  boolean isSameSwitch(java.awt.Point f1, java.awt.Point f2)
          Returns true, if both provided fence tiles belong to the same fence
protected  void logSeparator(java.lang.String caption)
          this method adds a separator (line of "-" to an agents debug log
protected  java.awt.Point moveSwitchPointToAgent(java.awt.Point aPos, java.awt.Point tPos, java.lang.String direction, GridMap map)
          Used to get the switch position on the agents side on the fence
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

gatePositions

java.util.HashMap<java.awt.Point,java.awt.Point> gatePositions

gateDirections

java.util.HashMap<java.awt.Point,java.lang.String> gateDirections

groups

java.util.HashMap<java.lang.String,java.util.List<java.lang.String>> groups

agPositions

java.util.HashMap<java.lang.String,java.awt.Point> agPositions

agHelpers

java.util.List<java.lang.String> agHelpers

agIndex

java.util.HashMap<java.lang.String,java.lang.Integer> agIndex

agInvIndex

java.util.HashMap<java.lang.Integer,java.lang.String> agInvIndex

myself

java.lang.String myself

ignoreList

java.util.ArrayList<java.lang.Integer> ignoreList

startWithIgnore

boolean startWithIgnore

debugLog

java.util.List<java.lang.String> debugLog
Constructor Detail

exCreatePlan

public exCreatePlan()
Method Detail

execute

public java.lang.Object execute(TransitionSystem ts,
                                Unifier un,
                                Term[] args)
                         throws java.lang.Exception
Used by a teamleader to generate an asl plan to send orders to the team. Generates a task to open the next fence, and send the others driving the cow. Can ignore agents, if there is no way to get them to the group, or if they have to wait because of a switch which is only accessible from one side of the fence.

Throws:
java.lang.Exception

getNumberOfFencesOnPath

protected int getNumberOfFencesOnPath(java.util.LinkedList<java.awt.Point> path,
                                      GridMap map)
Returns the number of fences known on the provided path.

Parameters:
path -
map -
Returns:

getNextFencePositionOnPath

protected java.awt.Point getNextFencePositionOnPath(java.util.LinkedList<java.awt.Point> path,
                                                    GridMap map)
Returns the next fence position on the provided path, or at least a point where the agent should look for a fence

Parameters:
path -
map -
Returns:

getAgentName

protected java.lang.String getAgentName(int i)
Returns the agents name, used to send orders in jason

Parameters:
i -
Returns:

fillGatePositions

protected void fillGatePositions(TransitionSystem ts)
Fills the gate positions according to the agents beliefs

Parameters:
ts -

isSameSwitch

protected boolean isSameSwitch(java.awt.Point f1,
                               java.awt.Point f2)
Returns true, if both provided fence tiles belong to the same fence

Parameters:
f1 -
f2 -
Returns:

getSwitchPosition

public java.awt.Point getSwitchPosition(BeliefSet bs,
                                        java.awt.Point aPos,
                                        java.awt.Point fencePosition,
                                        GridMap map)
Returns the position of the switch. If the switch is unknown, return a good point for looking for the switch

Parameters:
aPos - Agents position
sPos - Position of the switch
direction - Direction of the switch
Returns:

moveSwitchPointToAgent

protected java.awt.Point moveSwitchPointToAgent(java.awt.Point aPos,
                                                java.awt.Point tPos,
                                                java.lang.String direction,
                                                GridMap map)
Used to get the switch position on the agents side on the fence

Parameters:
aPos -
tPos -
direction -
map -
Returns:

isFenceOnPosition

protected boolean isFenceOnPosition(int x,
                                    int y,
                                    GridMap map)

buildGroups

protected void buildGroups(BeliefSet bs)
this method sets up some internal data structure for planning, in this case agent positions and helper lists. the groups list is based on the beliefs of an agent.

Parameters:
bs -

logSeparator

protected void logSeparator(java.lang.String caption)
this method adds a separator (line of "-" to an agents debug log