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