def placeLeak(self, leak):
tooClose = True
attempts = 0
while tooClose and attempts < self._MAX_TRIES:
attempts += 1
locator = self.locators[random.randint(0, len(self.locators) - 1)]
relative = self.getRelativePoint(self.board, Point3(locator.getX(), 0, locator.getZ()))
x = relative.getX()
z = relative.getZ()
tooClose = False
for otherLeak in self.activeLeaks:
dist = math.hypot(otherLeak.getX() - x, otherLeak.getZ() - z)
if dist < self._MIN_DIST:
tooClose = True
continue
for otherLeak in self.patchedLeaks:
dist = math.hypot(otherLeak.getX() - x, otherLeak.getZ() - z)
if dist < self._MIN_DIST:
tooClose = True
continue
leak.repositionTo(x, z)
评论列表
文章目录