hey there :) got stuck in exercise
made a class of CrazyPlane
now i need to make a infinite loop to get random coordinates for the planes
but if one of the planes is 2 or less coordinates between
i need to make the same plane a turn function to get it away by 1 point
in short i need the planes to not crash :S like a tower control :)
but my problem is i how do i compare between each plane?
do i make a loop?
another function?
any ideas will do
btw my main problem is how do i check if x of american is close to x of every other plane and same for y
if the are close by one than a call for a turn function will come
Thanks
[Image: Ra16HcN.jpg]
made a class of CrazyPlane
now i need to make a infinite loop to get random coordinates for the planes
but if one of the planes is 2 or less coordinates between
i need to make the same plane a turn function to get it away by 1 point
in short i need the planes to not crash :S like a tower control :)
but my problem is i how do i compare between each plane?
do i make a loop?
another function?
any ideas will do
btw my main problem is how do i check if x of american is close to x of every other plane and same for y
if the are close by one than a call for a turn function will come
Thanks
[Image: Ra16HcN.jpg]
import random class CrazyPlane: def __init__(self,x,y): self.__x = x self.__y = y def update_position(self): self.__x += random.randint(-1,1) self.__y += random.randint(-1,1) def get_position(self): return self.__x,self.__y def count_down(self): for i in range(10,0,-1): print i def __eq__(self, other): return self.value == other def crash_check(planes): x = 0 y = 1 flag = True while (flag): if (__eq__(planes[x], planes[y])): print " BOOM!" else: y = y + 1 if y == 3: x = x + 1 y = x + 1 if x == 3: flag = false return False ###AND!!!!!!!!!!!!!!!!!!!#### def main(): elal = CrazyPlane.CrazyPlane(1,2) american = CrazyPlane.CrazyPlane(3,4) british = CrazyPlane.CrazyPlane(5,6) lufthansa = CrazyPlane.CrazyPlane(7,8) planes = [elal,american,british,lufthansa] flag = True while (flag): for plane in planes: plane.update_position() if crash_check(planes): flag = False print 'Crash' main()