[Fwd: Re: [Tutor] Livewires Robot-5]
Gregor Lingl
glingl at aon.at
Fri Nov 21 20:00:47 EST 2003
Indentation of my previous post was completely damaged, (don't know why)
I try it once more:
robots = [] # initially empty
for i in range(number_of_robots_to_create): # number_of_robots_to_create
# for instance may be 5
newrobot = Robot() # a new one
## here check if there are collisions
## with robots already created, something SIMILAR TO
ok = False
while not ok:
ok = True
for oldrobot in robots:
if oldrobot.collides(newrobot):
ok = False
if not ok: # there was a collision
## put newrobot in a new place
.....
## ok is still False here, so the loop has to be done again
## here we come, if there was no collision (ok is True here)
## so the robot is ok and we append it to our list of robots:
robots.append(newrobot)
## Now all our robots are ready to do something:
for robot in robots:
### do something
...
hope it will work now ...
Regards, Gregor
More information about the Tutor
mailing list