|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcz.cuni.amis.pogamut.ut2004.bot.impl.UT2004BotController<BOT>
cz.cuni.amis.pogamut.ut2004.bot.impl.UT2004BotLogicController<BOT>
cz.cuni.amis.pogamut.sposh.ut2004.SposhLogicController<BOT,WORK_EXECUTOR>
public abstract class SposhLogicController<BOT extends UT2004Bot,WORK_EXECUTOR extends IWorkExecutor>
Logic controller that utilizes sposh engine for decision making of bot in UT2004 environment.
Sposh requires two things: plan and primitives. The plan is provided bySposhLogicController#getPlan()
method and are supplied by IWorkExecutor
.
IWorkExecutor
is instantiated during first call of logic, so if the varioud
modules are already initialized.
If needed, override createTimer()
, but it
shouldn't be needed.
Field Summary | |
---|---|
static String |
SPOSH_LOG_CATEGORY
|
Fields inherited from class cz.cuni.amis.pogamut.ut2004.bot.impl.UT2004BotLogicController |
---|
logicModule |
Fields inherited from class cz.cuni.amis.pogamut.ut2004.bot.impl.UT2004BotController |
---|
bot, log, USER_LOG_CATEGORY_ID |
Constructor Summary | |
---|---|
SposhLogicController()
|
Method Summary | |
---|---|
protected ITimer |
createTimer()
Create timer for posh engine. |
protected abstract WORK_EXECUTOR |
createWorkExecutor()
Create IWorkExecutor that will execute primitives contained in the plan. |
protected List<PoshEngine> |
getEngines()
Get engines used by this bot. |
protected String |
getPlanFromFile(String filename)
Read POSH plan from the file and return it. |
protected String |
getPlanFromResource(String resourcePath)
Get POSh plan from resource int the same jar as the class. |
protected String |
getPlanFromStream(InputStream in)
Read POSH plan from the stream and return it. |
protected abstract List<String> |
getPlans()
Get all Yaposh plans this bot is supposed to execute. |
protected List<String> |
getPlansFromDirectory(String directoryPath)
Reads all '.lap' file from specified directory. |
protected ITimer |
getTimer()
Get timer that is used by posh engine to make sure timeouts and other stuff that requires time are working properly. |
protected WORK_EXECUTOR |
getWorkExecutor()
Get work executor. |
void |
initializeController(BOT bot)
. |
void |
logic()
Logic method evaluates all Yaposh plans in same order as they were specified. |
protected void |
logicAfterPlan()
Method that is triggered every time the plan for executor is evaluated. |
protected void |
logicBeforePlan()
Method that is triggered every time the plan for executor is evaluated. |
Methods inherited from class cz.cuni.amis.pogamut.ut2004.bot.impl.UT2004BotLogicController |
---|
beforeFirstLogic, getLogicInitializeTime, getLogicShutdownTime, initializeLogic, logicInitialize, logicShutdown |
Methods inherited from class cz.cuni.amis.pogamut.ut2004.bot.impl.UT2004BotController |
---|
botFirstSpawn, botInitialized, botKilled, botShutdown, finishControllerInitialization, getAct, getBot, getInitializeCommand, getLog, getName, getPassword, getWorldView, prepareBot |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface cz.cuni.amis.pogamut.ut2004.bot.IUT2004BotController |
---|
botFirstSpawn, botInitialized, botKilled, botShutdown, finishControllerInitialization, getAct, getBot, getInitializeCommand, getLog, getPassword, getWorldView, prepareBot |
Field Detail |
---|
public static final String SPOSH_LOG_CATEGORY
Constructor Detail |
---|
public SposhLogicController()
Method Detail |
---|
public void initializeController(BOT bot)
getEngines()
doesn't return empty list after this).
initializeController
in interface IUT2004BotController<BOT extends UT2004Bot>
initializeController
in class UT2004BotLogicController<BOT extends UT2004Bot>
bot
- protected abstract WORK_EXECUTOR createWorkExecutor()
IWorkExecutor
that will execute primitives contained in the plan.
This method will be called only once.
protected final WORK_EXECUTOR getWorkExecutor()
createWorkExecutor()
.
public final void logic()
logic
in interface cz.cuni.amis.pogamut.base.agent.module.IAgentLogic<cz.cuni.amis.pogamut.base.agent.module.LogicModule>
logic
in class UT2004BotLogicController<BOT extends UT2004Bot>
protected void logicBeforePlan()
workExecutor
is a
ILogicWorkExecutor
and if it is, it executes ILogicWorkExecutor.logicBeforePlan()
.
protected void logicAfterPlan()
workExecutor
is a
ILogicWorkExecutor
and if it is, it executes ILogicWorkExecutor.logicBeforePlan()
.
protected ITimer createTimer()
SystemClockTimer
.
getTimer()
protected final ITimer getTimer()
protected final List<PoshEngine> getEngines()
initializeController(UT2004Bot)
) or the engines.protected abstract List<String> getPlans() throws IOException
getPlanFromResource(java.lang.String)
, getPlanFromFile(java.lang.String)
,
or {@link #getPlansFromDirectory(String)}.
.
IOException
protected final String getPlanFromStream(InputStream in) throws IOException
in
- Input stream from which the plan is going to be read
IOException
- If there is some error while reading the streamprotected final List<String> getPlansFromDirectory(String directoryPath) throws IOException
directoryPath
-
IOException
protected final String getPlanFromFile(String filename) throws IOException
filename
- Path to the file that contains the POSH plan.
IOException
- If there is some error while reading the streamprotected final String getPlanFromResource(String resourcePath) throws IOException
// Plan is stored in package cz.cuni.amis.pogamut.testbot under name poshPlan.lap // This can get the file from .jar or package structure getPlanFromResource("cz/cuni/amis/pogamut/testbot/poshPlan.lap");
resourcePath
- Path to the plan in some package
IOException
- if something goes wrong, like file is missing, hardisk has blown up ect.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |