Cleaned up a bit
This commit is contained in:
parent
e9d7f25bbe
commit
06de0e681f
@ -79,7 +79,6 @@ class GC(Cell):
|
||||
for row in environment:
|
||||
b = 0
|
||||
for col in row:
|
||||
print(col)
|
||||
if (type(col) is House):
|
||||
houses_list.append([col,[a,b]])
|
||||
if (type(col) is Dump):
|
||||
|
@ -2,8 +2,8 @@ import random, datetime, itertools
|
||||
|
||||
def GenerateMap():
|
||||
#generate random empty map
|
||||
width = random.randint(4,15) #up to 15
|
||||
height = random.randint(4,10) #up to 10
|
||||
width = random.randint(5,15) #up to 15
|
||||
height = random.randint(5,10) #up to 10
|
||||
grid = []
|
||||
|
||||
row = []
|
||||
@ -25,7 +25,6 @@ def GenerateMap():
|
||||
road_area = [coordinate-1, coordinate, coordinate+1]
|
||||
possible_coordiantes = [i for i in possible_coordiantes if i not in road_area] #removes road and surrounding coords (total 3 coords) from possible coords
|
||||
x_roads_coordinates.append(coordinate)
|
||||
print(x_roads_coordinates)
|
||||
|
||||
#select coords of roads for y
|
||||
y_roads_coordinates = [] #output coords
|
||||
@ -36,7 +35,6 @@ def GenerateMap():
|
||||
road_area = [coordinate-1, coordinate, coordinate+1]
|
||||
possible_coordiantes = [i for i in possible_coordiantes if i not in road_area] #removes road and surrounding coords (total 3 coords) from possible coords
|
||||
y_roads_coordinates.append(coordinate)
|
||||
print(y_roads_coordinates)
|
||||
|
||||
#create list of road coordinates
|
||||
roads = []
|
||||
@ -65,7 +63,6 @@ def GenerateMap():
|
||||
choice = random.choice(possible_roads_to_modify)
|
||||
possible_roads_to_modify.remove(choice)
|
||||
roads_to_modify.append(choice)
|
||||
print(roads_to_modify)
|
||||
|
||||
"""CREATION TIME"""
|
||||
#perform modification based on road
|
||||
@ -73,10 +70,8 @@ def GenerateMap():
|
||||
#select possible directions for modification
|
||||
x, y = r
|
||||
direction = random.choice([1,-1])
|
||||
print(x,y)
|
||||
if([x+1, y] in roads or [x-1, y] in roads):
|
||||
#modify y, as there is road on x coordinates
|
||||
print("y: up/down")
|
||||
route = []
|
||||
current_tile = [x,y+direction]
|
||||
while(True):
|
||||
@ -87,7 +82,6 @@ def GenerateMap():
|
||||
current_tile = [current_tile[0],current_tile[1]+direction]
|
||||
else:
|
||||
#modify x, as there is road on y coordinates
|
||||
print("x: left/right")
|
||||
route = []
|
||||
current_tile = [x+direction,y]
|
||||
while(True):
|
||||
@ -99,9 +93,10 @@ def GenerateMap():
|
||||
|
||||
#choose if the route should be complete or not
|
||||
if(len(route)>1):
|
||||
if(random.randint(1,100)<=40): #40% chance for route not to be full length
|
||||
route_len = random.randint(1,len(route))
|
||||
route = route[1:route_len]
|
||||
if(random.randint(1,100)<=65): #40% chance for route not to be full length
|
||||
#route.reverse()
|
||||
route_len = random.randint(1,len(route)-1)
|
||||
route = route[0:route_len]
|
||||
|
||||
#add new route to roads
|
||||
roads.extend(route)
|
||||
@ -110,8 +105,6 @@ def GenerateMap():
|
||||
for coord in roads:
|
||||
grid[coord[1]][coord[0]] = "R"
|
||||
|
||||
for g in grid: print(g)
|
||||
|
||||
"""OBJECTS BE HERE"""
|
||||
#Select area that possibly could hold objects
|
||||
objects_area = []
|
||||
@ -140,12 +133,8 @@ def GenerateMap():
|
||||
while(len(houses_area) > houses_to_leave_count):
|
||||
houses_area.remove(random.choice(houses_area))
|
||||
|
||||
|
||||
print("================================")
|
||||
|
||||
#insert houses into the grid
|
||||
for coord in houses_area:
|
||||
print(coord)
|
||||
grid[coord[1]][coord[0]] = "H"
|
||||
|
||||
#Select position for GC
|
||||
|
Loading…
Reference in New Issue
Block a user