From 0fdb9ce843f15dfa02f2d9c61385a477d8e1e41f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Magdalena=20Wilczy=C5=84ska?= Date: Sun, 19 May 2019 18:22:46 +0200 Subject: [PATCH] Disabled road modification for time being --- MapGenerator.py | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/MapGenerator.py b/MapGenerator.py index a958c5f..8f47112 100644 --- a/MapGenerator.py +++ b/MapGenerator.py @@ -38,22 +38,6 @@ def GenerateMap(): y_roads_coordinates.append(coordinate) print(y_roads_coordinates) - """combine coords into list of intersection coordinates with number of roads they are joining - (if less than 2, then removed as it is no longer an intersection)""" - - intersections = [] - roads = [] - for x in x_roads_coordinates: - for y in y_roads_coordinates: - #check how many roads are joined - joining_roads_count = 4 - if(x == 0 or x == width-1): - joining_roads_count -= 1 - if(y == 0 or y == height-1): - joining_roads_count -= 1 - if(joining_roads_count > 2): - intersections.append([[x,y],joining_roads_count]) - #create list of road coordinates roads = [] for x in x_roads_coordinates: @@ -67,7 +51,24 @@ def GenerateMap(): """AND HERE WE ARE, MODIFYING ALL THE ROADS select half the intersections for modification or at least remove half from the initial list - i mean we're operating on copy""" + i mean we're operating on copy + THIS MIGHT NOT WORK AS INTENDED""" + + """combine coords into list of intersection coordinates with number of roads they are joining + (if less than 2, then removed as it is no longer an intersection)""" + + """ + intersections = [] + for x in x_roads_coordinates: + for y in y_roads_coordinates: + #check how many roads are joined + joining_roads_count = 4 + if(x == 0 or x == width-1): + joining_roads_count -= 1 + if(y == 0 or y == height-1): + joining_roads_count -= 1 + if(joining_roads_count > 2): + intersections.append([[x,y],joining_roads_count]) intersections_to_modify = [j[0].copy() for j in [i for i in intersections]] intersections_to_leave_count = (len(intersections)//2) + 1 @@ -139,12 +140,12 @@ def GenerateMap(): #EXPERIMENTAL #decide if modified route should disappear or just have some field removed - """f = random.randint(0,100) - if(not(f % 2 or f % 5)): - route.remove(random.choice(route))""" + #f = random.randint(0,100) + #if(not(f % 2 or f % 5)): + # route.remove(random.choice(route)) #remove modified route from roads - roads = [c for c in roads if c not in route] + roads = [c for c in roads if c not in route]""" #insert roads into the grid for coord in roads: