Yannick wrote: > Thank you all for the detailled answers. > > What I would like to achieve is something like: > > # main loop > while True: > for robot in robots: > robot.start() > robot.join(0.2) # wait 200ms > if robot.is_active(): > robot.stop() > # run all the game physics, pause, frame/rate, etc... > > Unfortunately the stop() call doesn't exist in Python. > > By using a generator I would make the assumption that every robot is > playing fair, and would yield often. But I cannot control this as > eventually robots would be coded by third parties. > > Using Python scheduler would allow me to share time equally between > each robot, but then I would loose the ability to have a main thread > organizing everything. >
I think the best way is to give each robot its own thread. That way the interpreter will share time between each of the robots (whether or not they sleep or yield) on a reasonably fair basis. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden -- http://mail.python.org/mailman/listinfo/python-list