def spawnPosition(self): for x in range(self.TARGETS[1]): if f"place-{x}" in ScreenObjectManager.instance.objects: ScreenObjectManager.instance.unregisterVisual(f"place-{x}") self.setBotPos() n_targets = random.randint(*self.TARGETS) offset = random.randint(0, 359) places = self.PLACES[:] random.shuffle(places) self.commands = [] for x in range(n_targets): distance = random.randint(20, 40) bearing = int(360 * x / n_targets + offset) % 360 self.commands.append((places[x], bearing, distance)) obj = visualFactory( **{ "name": "Image", "image_path": f"custom/Locations/ui/{places[x]}.png", "position": [ distance * np.cos(bearing * np.pi / 180), distance * np.sin(bearing * np.pi / 180) ], "fill": [ 255 * x for x in hsl_to_rgb(random.randint(0, 359), 1, 0.5) ], "scale": 1.3, "zPos": 3 }) ScreenObjectManager.instance.registerVisual(obj, f"place-{x}") self.restartBots() ScriptLoader.instance.postInput(str(n_targets)) for s, b, d in self.commands: ScriptLoader.instance.postInput(f"{s} is {d} away at {b} degrees.") location = random.randint(0, n_targets - 1) ScriptLoader.instance.postInput(f"Go to {self.commands[location][0]}")
def randomColor(self, minHue, maxHue, minSat, maxSat, minLight, maxLight): h = random.randint(minHue, maxHue) % 360 s = minSat + random.random() * (maxSat - minSat) l = minLight + random.random() * (maxLight - minLight) r, g, b = hsl_to_rgb(h, s, l) return rgb_to_hex(int(r * 255), int(g * 255), int(b * 255))