def generateShips(self): num = 0 while num < 4: self.find = False orientation = self.determineOrientation() size = num + 2 x = randint(1, 9) y = randint(1, 9) ship = Ship(size, orientation, x, y) ship.createShip() coord = ship.getCoordinates() for point in coord: for occupied in self.occupied: if point == occupied: self.find = True break if self.find: break if self.find: continue if size == 2: self.ship_2 = ship.getCoordinates() elif size == 3: self.ship_3 = ship.getCoordinates() elif size == 4: self.ship_4 = ship.getCoordinates() else: self.ship_5 = ship.getCoordinates() num += 1 for point in coord: self.occupied.append(point)