- def add_thing(type_):
- t = self.game.thing_types[type_](self)
- t.position = (random.randint(0, yx[0] -1),
- random.randint(0, yx[1] - 1))
- self.things += [t]
- return t
+ def add_thing_at_random(type_):
+ while True:
+ new_pos = (random.randint(0, yx[0] -1),
+ random.randint(0, yx[1] - 1))
+ if self.map_[new_pos] != '.':
+ continue
+ if len(self.things_at_pos(new_pos)) > 0:
+ continue
+ return self.add_thing_at(type_, new_pos)