cz.cuni.amis.pogamut.sposh
Class JavaBehaviour<AGENT>

Package class diagram package JavaBehaviour
java.lang.Object
  extended by cz.cuni.amis.pogamut.sposh.JavaBehaviour<AGENT>

public class JavaBehaviour<AGENT>
extends Object

Base class for definitions of senses and acts of SPOSH bot.

User will implement actions and senses used in the plan by deriving this class and by creating senses and actions for SPOSH plan in following fashion:

actions are methods annotated with @SPOSHAction annotation. Name of method is arbitrary and return type should one of the standard ones (String + numbers). SPOSH engine will use toString() method for the return values of user defined classes (probably), but because there are some issues with jython-java interaction, it may produce some weird bugs.

Sense is a method returning value annotated with @SPOSHSense. Name and return restrictions are similar to action. For simplest action see doNothing() or sense fail(). The actions can utilize log, that is available through log member of class (it is a AgentLogger of the SPOSH bot. This basic class (as well all derived ones) implements following actions and senses

Author:
Honza, Jimmy

Field Summary
protected  AGENT bot
           
 
Constructor Summary
JavaBehaviour(String name, AGENT bot)
          Create new behaviour.
 
Method Summary
 ActionResult doNothing()
          Standard action that has to be implemented everywhere.
 boolean fail()
          Standard sense that has to be implemented everywhere.
 String[] getActions()
          Returns list of actions that are declared in the behaviour class.
 AGENT getBot()
          Returns underlying AGENT instance.
 String getName()
          Get name of the behaviour specified in the constructor.
 String[] getSenses()
          Returns list of senses that are declared in the behaviour class.
 void logicAfterPlan()
          Method that is triggered every time the plan for executor is evaluated.
 void logicBeforePlan()
          Method that is triggered every time the plan for executor is evaluated.
 boolean succeed()
          Standard sense that has to be implemented everywhere.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

bot

protected AGENT bot
Constructor Detail

JavaBehaviour

public JavaBehaviour(String name,
                     AGENT bot)
Create new behaviour.

Parameters:
name - Name of behaviour so it is easy to distinguish between different behaviours classes in the log and error messages
bot - Class of the bot that this behaviour is serving. Used by sense and actions for gathering info and manipulation of the bot.
Method Detail

getName

public String getName()
Get name of the behaviour specified in the constructor.

Returns:
Name of the behaviour

getActions

public String[] getActions()
Returns list of actions that are declared in the behaviour class. Search for the actions is performed only on first execution of method.

Use Java Reflection API to search through the methods for methods with annotations @SPOSHActions and return list of strings that contains the methods.

Returns:
list with names of actions methods

getSenses

public String[] getSenses()
Returns list of senses that are declared in the behaviour class. Search for the senses is performed only on first execution of method.

Use Java Reflection API to search through the methods for methods with annotations @SPOSHSense and return list of strings that contains the methods.

Returns:
list with names of sense methods

doNothing

public ActionResult doNothing()
Standard action that has to be implemented everywhere. Sleep for 250ms.

Returns:
true

fail

public boolean fail()
Standard sense that has to be implemented everywhere.

Returns:
false

succeed

public boolean succeed()
Standard sense that has to be implemented everywhere.

Returns:
true

logicBeforePlan

public void logicBeforePlan()
Method that is triggered every time the plan for executor is evaluated. It is triggered right before the plan evaluation.


logicAfterPlan

public void logicAfterPlan()
Method that is triggered every time the plan for executor is evaluated. It is triggered right after the plan evaluation.


getBot

public AGENT getBot()
Returns underlying AGENT instance.

Returns:


Copyright © 2014 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.