edu.udo.cs.ie.cowbots.internalActions.scout
Class getScoutSwitchFinder

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

public class getScoutSwitchFinder
extends DefaultInternalAction

Class to calculate the Helper, who should be ordered to serach for a switch if the switch for the relevant fence isn't found yet


Field Summary
(package private)  ICowbot cowbot
           
(package private)  GridMap map
           
(package private)  java.awt.Point target1
           
(package private)  java.awt.Point target2
           
 
Constructor Summary
getScoutSwitchFinder()
           
 
Method Summary
private  int calcDistance(ELPLiteral e, int x, int y)
          Utility function for calculating the distance between Agent and point to go
private  java.lang.String[] calcfinders(java.awt.Point p1, java.awt.Point p2)
          Utility function to get the two helpers required to search for the switch
 java.lang.Object execute(TransitionSystem ts, Unifier un, Term[] args)
           
private  java.lang.String getHelper(int x, int y, java.lang.String name)
          Utility function to get the nearest Helper to the point specified
private  void settargets(int xcoord, int ycoord, int wpxcoord, int wpycoord, java.lang.String dir)
          Utility function for setting the targets the searching helpers should go to.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cowbot

ICowbot cowbot

target1

java.awt.Point target1

target2

java.awt.Point target2

map

GridMap map
Constructor Detail

getScoutSwitchFinder

public getScoutSwitchFinder()
Method Detail

execute

public java.lang.Object execute(TransitionSystem ts,
                                Unifier un,
                                Term[] args)
                         throws java.lang.Exception
Throws:
java.lang.Exception

settargets

private void settargets(int xcoord,
                        int ycoord,
                        int wpxcoord,
                        int wpycoord,
                        java.lang.String dir)
Utility function for setting the targets the searching helpers should go to.

Parameters:
xcoord - X-coordinate of the fencecell, which belongs to the fence
ycoord - Y-coordinate of the fencecell, which belongs to the fence
wpxcoord - X-coordinate waypoint required to calculate the coordinates (usually the fenceopenwp)
wpycoord - Y-coordinate waypoint required to calculate the coordinates (usually the fenceopenwp)
dir - direction of the fence (vertical or horizontal)

calcfinders

private java.lang.String[] calcfinders(java.awt.Point p1,
                                       java.awt.Point p2)
Utility function to get the two helpers required to search for the switch

Parameters:
p1 - first destination, where to look
p2 - second destination, where to look
Returns:
array containing both helper-names

calcDistance

private int calcDistance(ELPLiteral e,
                         int x,
                         int y)
Utility function for calculating the distance between Agent and point to go

Parameters:
e - the ELPLiteral encoding the agents position.
x - X-coordinate of the point
y - Y-coordinate of the point
Returns:
the distance

getHelper

private java.lang.String getHelper(int x,
                                   int y,
                                   java.lang.String name)
Utility function to get the nearest Helper to the point specified

Parameters:
x - X-coordinate of the pointCP
y - Y-coordinate of the point
name - the name to be excluded in the search (to avoid that the same agent is chosen twice)
Returns:
the agent's name