[Pogamut-list] Gracefully Stop Bot

michal.bida pogamut-forum at diana.ms.mff.cuni.cz
Wed Jul 4 14:37:43 CEST 2012


Re: Gracefully Stop Bot

Author: michal.bida

First of all - always choose between sending disconnect, or calling the stop method. Calling stop after sending disconnect can sometimes prevent the disconnect command to be sent to GameBots (one row in the error report confirms this: (EvolvingBot) WARNING 16:38:14.582 Not running, can't send DISCONNECT ).

Now what I would do in order to get result from my bot is this: 
1) I would detect with some method that I already have all the data I wanted and I am ready to shut down the bot
2) I would export the data to some file or store them to some object - in the mean time I would stop the bot logic  (e.g. put in the bot logic something like if (exportingBeforeShutdown == true) return;) and unhook all the listeners I would use to gather data. I can emulate the return value of the bot - instead of returning the value I will store it in some object before I will shutdown the bot.
3) When 2) is done, I would send the disconnect command. 

This way I've got data exported and the bot stopped. If I have other thread I am using to launch the bots I can catch the exception there and notify that the bot is finished. Now I can launch a new one.
Now if you want to resume this same bot then it will be a problem, because this is not yet possible. You could emulate something like this for yourself skipping the point 3), but instead resuming the bot execution again.

Does this help? 

Best,
Michal

-- 
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