From 658120b8d91336abec6a9f42a0a8d1d4f8cab0a9 Mon Sep 17 00:00:00 2001 From: Khopa Date: Sun, 30 Jun 2019 05:48:19 +0200 Subject: [PATCH] Tweaked ground object generator --- theater/start_generator.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/theater/start_generator.py b/theater/start_generator.py index 349d7f9b..70056181 100644 --- a/theater/start_generator.py +++ b/theater/start_generator.py @@ -56,7 +56,7 @@ def generate_groundobjects(theater: ConflictTheater): with open("resources/groundobject_templates.p", "rb") as f: tpls = pickle.load(f) - def find_location(on_ground, near, theater, min, max) -> typing.Optional[Point]: + def find_location(on_ground, near, theater, min, max, others) -> typing.Optional[Point]: point = None for _ in range(1000): p = near.random_point_within(max, min) @@ -75,6 +75,13 @@ def generate_groundobjects(theater: ConflictTheater): point = None break + + if point: + for other in others: + if other.position.distance_to_point(point) < 10000: + point = None + break + if point: return point @@ -92,7 +99,7 @@ def generate_groundobjects(theater: ConflictTheater): if not cp.has_frontline: continue - amount = random.randrange(5, 7) + amount = random.randrange(1, 5) for i in range(0, amount): available_categories = list(tpls) if i >= amount - 1: @@ -102,7 +109,7 @@ def generate_groundobjects(theater: ConflictTheater): tpl = random.choice(list(tpls[tpl_category].values())) - point = find_location(tpl_category != "oil", cp.position, theater, 15000, 80000) + point = find_location(tpl_category != "oil", cp.position, theater, 10000, 40000, cp.ground_objects) if point is None: print("Couldn't find point for {}".format(cp))