[Pogamut-list] Gracefully Stop Bot

jacob.schrum pogamut-forum at diana.ms.mff.cuni.cz
Mon Jul 2 23:49:36 CEST 2012


Re: Gracefully Stop Bot

Author: jacob.schrum

Ok, that helps, but I'm still having some problems. I have a test bot with the following logic method:

    public void logic() throws PogamutException {
        if(game.getTime() > getParams().getEvalSeconds()){
            System.out.println("Before stop");
            bot.getAct().act(new DisconnectBot());
            bot.stop();
            System.out.println("After stop");
        }
        // TODO: Control the bot here
    }

Also, I launch the bot with the following method:

    public static int launchBot(String host, int botPort) throws PogamutException {
        UT2004BotRunner runner = new UT2004BotRunner(NetworkControllerBot.class, "NetworkControllerBot").setMain(true).setHost(host).setPort(botPort);
        runner.startAgents(new NetworkControllerBotParameters("Test"));
        System.out.println("Match over ");
        return 1;
    }

Basically, I want to be able to return some value after the bot finishes execution. However, neither the "After stop" text in the logic method nor the "Match over" text in the launchBot method ever appear. The logic method doesn't matter too much, but I really need to regain control of execution when the bot it done and return a relevant result (1 is just a place-holder for this example). Instead, I'm getting the following errors:
(in particular, the ParserEOFException seems bad)

-------------------------------------------------------------------------
Before stop
(EvolvingBot)           [WARNING] 16:38:14.450                        Stopping agent NetworkControllerBot2-5 at 192.168.1.102/022ed0ee-e26a-367f-7da2-511e46dee0e8
(UCC)                   [INFO]    16:38:14.497                      ID0 In: State: Dead, BeginState()
(UCC)                   [INFO]    16:38:14.498                      ID0 BotConnection DM-1on1-Albatross.BotConnection (Function GameBots2004.BotConnection.ReceivedDisconnect:0045) Accessed None 'theBot'
(EvolvingBot)           [WARNING] 16:38:14.546                     Calling Mediator.kill().
(EvolvingBot)           [SEVERE]  16:38:14.546                     Fatal error in Mediator: MediatorWorker: Producer exception.
(EvolvingBot)           [SEVERE]  16:38:14.548                 Fatal error happenned - component bus is stopping.
FatalErrorEvent[
    Component:  Mediator[producer=WorldMessageTranslator[parser=UT2004Parser, handler=BotFSM], consumer=UT2004SyncLockableWorldView]
    Message:    MediatorWorker: Producer exception.
    Cause:      class cz.cuni.amis.pogamut.base.communication.parser.exception.ParserEOFException: cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.Yylex at 13e6226: EOF met, assuming that underlying reader has been closed. (at cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.Yylex.yylex(Yylex.java:9374))
    Stacktrace:
        cz.cuni.amis.pogamut.base.component.controller.ComponentController.fatalError(ComponentController.java:518)
        cz.cuni.amis.pogamut.base.communication.mediator.impl.Mediator$Worker.run(Mediator.java:312)
        java.lang.Thread.run(Thread.java:619)
    Caused by: class cz.cuni.amis.pogamut.base.communication.parser.exception.ParserEOFException: cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.Yylex at 13e6226: EOF met, assuming that underlying reader has been closed. (at cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.Yylex.yylex(Yylex.java:9374))
        cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.Yylex.yylex(Yylex.java:9374)
        cz.cuni.amis.pogamut.base.communication.parser.impl.yylex.YylexParser.parse(YylexParser.java:97)
        cz.cuni.amis.pogamut.base.communication.translator.impl.WorldMessageTranslator.getEvent(WorldMessageTranslator.java:121)
        cz.cuni.amis.pogamut.base.communication.mediator.impl.Mediator$Worker.run(Mediator.java:299)
        java.lang.Thread.run(Thread.java:619)
]
(EvolvingBot)           [SEVERE]  16:38:14.548                   Received fatal error from Mediator.
(EvolvingBot)           [WARNING] 16:38:14.548                   Calling Connection.kill().
(EvolvingBot)           [SEVERE]  16:38:14.548                   Connection.kill()ed.
(EvolvingBot)           [SEVERE]  16:38:14.548                       Received fatal error from Mediator.
(EvolvingBot)           [WARNING] 16:38:14.549                       Calling Parser.kill().
(EvolvingBot)           [SEVERE]  16:38:14.577                       Parser.kill()ed.
(EvolvingBot)           [SEVERE]  16:38:14.577       Received fatal error from Mediator.
(EvolvingBot)           [WARNING] 16:38:14.578       Calling WorldMessageTranslator.kill().
(EvolvingBot)           [SEVERE]  16:38:14.578       WorldMessageTranslator.kill()ed.
(EvolvingBot)           [SEVERE]  16:38:14.578                    Received fatal error from Mediator.
(EvolvingBot)           [WARNING] 16:38:14.579                    Calling WorldView.kill().
(EvolvingBot)           [SEVERE]  16:38:14.579                    WorldView.kill()ed.
(EvolvingBot)           [SEVERE]  16:38:14.579                          Received fatal error from Mediator.
(EvolvingBot)           [WARNING] 16:38:14.580                          Calling Act.kill().
(EvolvingBot)           [SEVERE]  16:38:14.580                          Act.kill()ed.
(EvolvingBot)           [SEVERE]  16:38:14.580                        Fatal error sensed: FatalErrorEvent[
    Component:  Mediator[producer=WorldMessageTranslator[parser=UT2004Parser, handler=BotFSM], consumer=UT2004SyncLockableWorldView]
    Message:    MediatorWorker: Producer exception.
    Cause:      class cz.cuni.amis.pogamut.base.communication.parser.exception.ParserEOFException: cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.Yylex at 13e6226: EOF met, assuming that underlying reader has been closed. (at cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.Yylex.yylex(Yylex.java:9374))
    Stacktrace:
        cz.cuni.amis.pogamut.base.component.controller.ComponentController.fatalError(ComponentController.java:518)
        cz.cuni.amis.pogamut.base.communication.mediator.impl.Mediator$Worker.run(Mediator.java:312)
        java.lang.Thread.run(Thread.java:619)
    Caused by: class cz.cuni.amis.pogamut.base.communication.parser.exception.ParserEOFException: cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.Yylex at 13e6226: EOF met, assuming that underlying reader has been closed. (at cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.Yylex.yylex(Yylex.java:9374))
        cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.Yylex.yylex(Yylex.java:9374)
        cz.cuni.amis.pogamut.base.communication.parser.impl.yylex.YylexParser.parse(YylexParser.java:97)
        cz.cuni.amis.pogamut.base.communication.translator.impl.WorldMessageTranslator.getEvent(WorldMessageTranslator.java:121)
        cz.cuni.amis.pogamut.base.communication.mediator.impl.Mediator$Worker.run(Mediator.java:299)
        java.lang.Thread.run(Thread.java:619)
]
(EvolvingBot)           [WARNING] 16:38:14.582                          Not running, can't send DISCONNECT
-------------------------------------------------------------------------------

So, how do I return a result after the bot is done executing. Basically, I want to be able to gather some data from the match and return it after executing and shutting down the bot.

-- 
Reply Link: <http://diana.ms.mff.cuni.cz/main/tiki-view_forum_thread.php?forumId=4&comments_reply_threadId=4&comments_parentId=988&post_reply=1#form>




More information about the Pogamut-list mailing list