def generateComplementaryHuman(self, human, availableId): a = math.pi * human.angle / 180. #dist = float(QtCore.qrand()%300+50) dist = int(random.uniform(105, 225)) #Original: 65 y 225 xa = int(random.uniform(0, 10)) human2 = None while human2 is None: if time.time() - self.generation_time > MAX_GENERATION_WAIT: raise RuntimeError('MAX_GENERATION_ATTEMPTS') if (xa == 9 or xa == 8): # GeneraciĆ³n totalmente aleatoria xPos = QtCore.qrand() % 400 - 200 yPos = QtCore.qrand() % 400 - 200 human2 = Human(availableId, xPos, yPos, (QtCore.qrand() % 360) - 180) else: xPos = (human.xPos + dist * math.sin(a)) yPos = (human.yPos - dist * math.cos(a)) c = human.angle + 180 c_1 = (human.angle + 180) + 60 # Amplitud de 60 c_2 = (human.angle + 180) - 60 # Amplitud de 60 d = int(random.uniform(c_1, c_2)) human2 = Human(availableId, xPos, yPos, d) if not self.room.containsPolygon(human2.polygon()): dist -= 5 # Original 30 if dist < 30: human.setAngle(human.angle + 180) a = math.pi * human.angle / 180. dist = float(random.uniform(105, 225)) # Original: 55 y 65 #dist = float(QtCore.qrand()%300+50) human2 = None return human2
def generateInteractuatorHuman(self, human, availableId): a = math.pi * human.angle / 180. #a radianes dist = float(QtCore.qrand() % 300 + 50) human2 = None while human2 is None: if time.time() - self.generation_time > MAX_GENERATION_WAIT: raise RuntimeError('MAX_GENERATION_ATTEMPTS') xPos = human.xPos + dist * math.sin(a) yPos = human.yPos - dist * math.cos(a) l = [1, -1] option = random.choice(l) angle = human.angle + 180 + (option * QtCore.qrand() % 25) # print('angle human2:', angle) if angle > 180.: angle = -360. + angle # print('angle human2 normalize:', angle) angleHead = angle + random.choice([-1, 1]) * QtCore.qrand() % 100 human2 = Human(availableId, xPos, yPos, angle, angleHead) if not self.room.containsPolygon(human2.polygon()): dist -= 5 if dist < 20: human.setAngle(human.angle + 180) a = math.pi * human.angle / 180. dist = float(QtCore.qrand() % 300 + 50) human2 = None return human2
def generateHuman(self, availableId): human = None while human is None: if time.time() - self.generation_time > MAX_GENERATION_WAIT: raise RuntimeError('MAX_GENERATION_ATTEMPTS') if QtCore.qrand() % 3 == 0: xx = int(random.normalvariate(0, 150)) yy = int(random.normalvariate(0, 150)) else: xx = QtCore.qrand() % 800 - 400 yy = QtCore.qrand() % 800 - 400 human = Human(availableId, xx, yy, (QtCore.qrand() % 360) - 180) if not self.room.containsPolygon(human.polygon()): human = None return human
def generateComplementaryHuman(self, human, availableId): a = math.pi * human.angle / 180. dist = float(QtCore.qrand() % 300 + 50) human2 = None while human2 is None: if time.time() - self.generation_time > MAX_GENERATION_WAIT: raise RuntimeError('MAX_GENERATION_ATTEMPTS') xPos = human.xPos + dist * math.sin(a) yPos = human.yPos - dist * math.cos(a) human2 = Human(availableId, xPos, yPos, human.angle + 180) if not self.room.containsPolygon(human2.polygon()): dist -= 5 if dist < 20: human.setAngle(human.angle + 180) a = math.pi * human.angle / 180. dist = float(QtCore.qrand() % 300 + 50) human2 = None return human2