public class JavaBehaviour<AGENT> extends Object
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.
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
| Constructor and Description |
|---|
JavaBehaviour(String name,
AGENT bot)
Create new behaviour.
|
| Modifier and Type | Method and Description |
|---|---|
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.
|
protected AGENT bot
public JavaBehaviour(String name, AGENT bot)
name - Name of behaviour so it is easy to distinguish between
different behaviours classes in the log and error messagesbot - Class of the bot that this behaviour is serving.
Used by sense and actions for gathering info and manipulation of the bot.public String getName()
public String[] getActions()
Use Java Reflection API to search through the methods for methods with annotations @SPOSHActions and return list of strings that contains the methods.
public String[] getSenses()
Use Java Reflection API to search through the methods for methods with annotations @SPOSHSense and return list of strings that contains the methods.
public ActionResult doNothing()
public boolean fail()
public boolean succeed()
public void logicBeforePlan()
public void logicAfterPlan()
public AGENT getBot()
Copyright © 2012 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.