def run(self): self.round += 1 # begin round print '[WORLD] begin round', self.round for obj in self.objects.itervalues(): obj.begin_round() # execute each object - TODO: assumes all robots are objects for obj in self.objects.itervalues(): obj.begin_turn() Scheduler.instance().run_thread(obj.id) obj.end_turn() # end round for obj in self.objects.itervalues(): obj.end_round() print '[WORLD] end round', self.round
def add_object(self, obj): self.objects[obj.id] = obj Scheduler.instance().spawn_thread(obj)