On 2006-08-09, Yannick <[EMAIL PROTECTED]> wrote: > Hi, > > I would like to program a small game in Python, kind of like robocode > (http://robocode.sourceforge.net/). > Problem is that I would have to share the CPU between all the robots, > and thus allocate a time period to each robot. However I couldn't find > any way to start a thread (robot), and interrupt it after a given time > period.
The robot code thread needs to block when it runs out of things to do. > Any suggestions on how to proceed? Just start a thread for each robot, and put a call to time.sleep(0.010) in the main loop for the robot code. Adjust the 0.010 value to taste. As an alternative to sleeping, you could wait for some sort of event each time through the loop. > Is Python just not adapted to this kind of things? It's quite well adapted to this sort of thing. -- Grant Edwards grante Yow! Why don't you at ever enter and CONTESTS, visi.com Marvin?? Don't you know your own ZIPCODE? -- http://mail.python.org/mailman/listinfo/python-list