[Pogamut-list] How to handle bot threads in simple fashion?

jakub.gemrot pogamut-forum at diana.ms.mff.cuni.cz
Thu Apr 22 11:55:57 CEST 2010


Re: How to handle bot threads in simple fashion?

Author: jakub.gemrot

Yes, that was design-decision - having blocking start/stop methods.

The problem with non-blocking method is that there must be a non-standard feature (some sort of state-listening mechanism) that allows you to made them blocking.
Alas making any method non-blocking means just to execute the blocking method inside a thread.

Another nice thing about blocking-method is their ability to use exceptions - whenever the agent could not be started due to whatever error, an exception can be propagated back to you allowing you to write cleaner code (passing exceptions between multiple threads is no joke...).

I admit it leads to a weird state that to startup 10 bots in parallel means to start additional 10 threads but these threads usually terminates quickly. Note that
you can not achieve true start-10-bots-in-sync via these 10 threads - you would have to hack UT2004Bot.initCommandRequested() method. Or the better way - implement the logic of bots so it won't start doing anything till a requested number of bots connect to the game.

Additionally you may use ThreadPoolExecutor and create some StartAgentTasks to deal with the problem gracefully.

Advice: DO NOT EVER combine threads/tasks with SingleUT2004BotRunner ... use UT2004BotRunner instead.

Sorry to disappoint you.

Jimmy

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





More information about the Pogamut-list mailing list