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 __init__(self): self.objects = OrderedDict() self.round = -1 self.next_id = 0 Scheduler.create(self)
def add_object(self, obj): self.objects[obj.id] = obj Scheduler.instance().spawn_thread(obj)