Poprawiono zapisywanie map i inputu pod Linucha
This commit is contained in:
parent
6fbd5c76d0
commit
60e9a253be
@ -59,7 +59,7 @@ def GenerateMap():
|
||||
|
||||
possible_roads_to_modify = [i for i in roads if i not in intersections_area]
|
||||
roads_to_modify = []
|
||||
for i in range(1,len(possible_roads_to_modify)//3):
|
||||
for i in range(1,len(possible_roads_to_modify)//3):
|
||||
choice = random.choice(possible_roads_to_modify)
|
||||
possible_roads_to_modify.remove(choice)
|
||||
roads_to_modify.append(choice)
|
||||
@ -90,7 +90,7 @@ def GenerateMap():
|
||||
else:
|
||||
route.append(current_tile)
|
||||
current_tile = [current_tile[0]+direction,current_tile[1]]
|
||||
|
||||
|
||||
#choose if the route should be complete or not
|
||||
if(len(route)>1):
|
||||
if(random.randint(1,100)<=65): #40% chance for route not to be full length
|
||||
@ -113,7 +113,7 @@ def GenerateMap():
|
||||
objects_area = [c for c in objects_area if c not in roads] #remove coords that contain roads
|
||||
objects_area.sort()
|
||||
objects_area = [objects_area[i] for i in range(len(objects_area)) if i == 0 or objects_area[i] != objects_area[i-1]] #remove duplicates
|
||||
|
||||
|
||||
houses_area = [i.copy() for i in objects_area]
|
||||
for o in objects_area:
|
||||
if(o[0] < 0 or o[1] < 0 or o[0] >= width or o[1] >= height):
|
||||
@ -132,7 +132,7 @@ def GenerateMap():
|
||||
houses_to_leave_count = len(houses_area)//4
|
||||
while(len(houses_area) > houses_to_leave_count):
|
||||
houses_area.remove(random.choice(houses_area))
|
||||
|
||||
|
||||
#insert houses into the grid
|
||||
for coord in houses_area:
|
||||
grid[coord[1]][coord[0]] = "H"
|
||||
@ -141,7 +141,7 @@ def GenerateMap():
|
||||
GC_position = random.choice(roads)
|
||||
|
||||
#Save map to file
|
||||
name = ".\\Resources\\Maps\\map"+str(datetime.datetime.now().strftime("%Y%m%d%H%M%S%f"))+"_auto.txt"
|
||||
name = "./Resources/Maps/map"+str(datetime.datetime.now().strftime("%Y%m%d%H%M%S%f"))+"_auto.txt"
|
||||
map_file = open(name, "w+")
|
||||
map_file.write(str(width)+" "+str(height)+"\n")
|
||||
map_file.write(str(GC_position[0])+" "+str(GC_position[1])+"\n")
|
||||
@ -150,4 +150,4 @@ def GenerateMap():
|
||||
map_file.close()
|
||||
print(name)
|
||||
|
||||
return(name)
|
||||
return(name)
|
||||
|
31
VowPalInputData/input_map20190604233125746257_auto.txt
Normal file
31
VowPalInputData/input_map20190604233125746257_auto.txt
Normal file
@ -0,0 +1,31 @@
|
||||
3 1.0 map20190604233125746257_auto|GC_Position 11,4 |GC_Area E(10,3) R(10,4) E(10,5) R(11,3) R(11,5) E(12,3) R(12,4) Y(12,5)
|
||||
3 1.0 map20190604233125746257_auto|GC_Position 10,4 |GC_Area R(9,3) R(9,4) R(9,5) E(10,3) E(10,5) R(11,3) R(11,4) R(11,5)
|
||||
3 1.0 map20190604233125746257_auto|GC_Position 9,4 |GC_Area V(8,3) R(8,4) E(8,5) R(9,3) R(9,5) E(10,3) R(10,4) E(10,5)
|
||||
3 1.0 map20190604233125746257_auto|GC_Position 8,4 |GC_Area V(7,3) R(7,4) R(7,5) V(8,3) E(8,5) R(9,3) R(9,4) R(9,5)
|
||||
3 1.0 map20190604233125746257_auto|GC_Position 7,4 |GC_Area E(6,3) R(6,4) E(6,5) V(7,3) R(7,5) V(8,3) R(8,4) E(8,5)
|
||||
3 1.0 map20190604233125746257_auto|GC_Position 6,4 |GC_Area R(5,3) R(5,4) R(5,5) E(6,3) E(6,5) V(7,3) R(7,4) R(7,5)
|
||||
3 1.0 map20190604233125746257_auto|GC_Position 5,4 |GC_Area E(4,3) R(4,4) V(4,5) R(5,3) R(5,5) E(6,3) R(6,4) E(6,5)
|
||||
3 1.0 map20190604233125746257_auto|GC_Position 4,4 |GC_Area B(3,3) R(3,4) E(3,5) E(4,3) V(4,5) R(5,3) R(5,4) R(5,5)
|
||||
3 1.0 map20190604233125746257_auto|GC_Position 3,4 |GC_Area R(2,3) R(2,4) R(2,5) B(3,3) E(3,5) E(4,3) R(4,4) V(4,5)
|
||||
3 1.0 map20190604233125746257_auto|GC_Position 2,4 |GC_Area E(1,3) R(1,4) E(1,5) R(2,3) R(2,5) B(3,3) R(3,4) E(3,5)
|
||||
5 1.0 map20190604233125746257_auto|GC_Position 2,5 |GC_Area R(1,4) E(1,5) V(1,6) R(2,4) R(2,6) R(3,4) E(3,5) E(3,6)
|
||||
5 1.0 map20190604233125746257_auto|GC_Position 2,6 |GC_Area E(1,5) V(1,6) E(1,7) R(2,5) R(2,7) E(3,5) E(3,6) E(3,7)
|
||||
5 1.0 map20190604233125746257_auto|GC_Position 2,7 |GC_Area V(1,6) E(1,7) R(1,8) R(2,6) R(2,8) E(3,6) E(3,7) R(3,8)
|
||||
5 1.0 map20190604233125746257_auto|GC_Position 2,8 |GC_Area E(1,7) R(1,8) R(2,7) E(3,7) R(3,8)
|
||||
2 1.0 map20190604233125746257_auto|GC_Position 3,8 |GC_Area R(2,7) R(2,8) E(3,7) E(4,7) R(4,8)
|
||||
2 1.0 map20190604233125746257_auto|GC_Position 4,8 |GC_Area E(3,7) R(3,8) E(4,7) R(5,7) R(5,8)
|
||||
2 1.0 map20190604233125746257_auto|GC_Position 5,8 |GC_Area E(4,7) R(4,8) R(5,7) E(6,7) R(6,8)
|
||||
4 1.0 map20190604233125746257_auto|GC_Position 5,7 |GC_Area E(4,6) E(4,7) R(4,8) R(5,6) R(5,8) V(6,6) E(6,7) R(6,8)
|
||||
4 1.0 map20190604233125746257_auto|GC_Position 5,6 |GC_Area V(4,5) E(4,6) E(4,7) R(5,5) R(5,7) E(6,5) V(6,6) E(6,7)
|
||||
4 1.0 map20190604233125746257_auto|GC_Position 5,5 |GC_Area R(4,4) V(4,5) E(4,6) R(5,4) R(5,6) R(6,4) E(6,5) V(6,6)
|
||||
4 1.0 map20190604233125746257_auto|GC_Position 5,4 |GC_Area E(4,3) R(4,4) V(4,5) R(5,3) R(5,5) E(6,3) R(6,4) E(6,5)
|
||||
3 1.0 map20190604233125746257_auto|GC_Position 4,4 |GC_Area B(3,3) R(3,4) E(3,5) E(4,3) V(4,5) R(5,3) R(5,4) R(5,5)
|
||||
3 1.0 map20190604233125746257_auto|GC_Position 3,4 |GC_Area R(2,3) R(2,4) R(2,5) B(3,3) E(3,5) E(4,3) R(4,4) V(4,5)
|
||||
3 1.0 map20190604233125746257_auto|GC_Position 2,4 |GC_Area E(1,3) R(1,4) E(1,5) R(2,3) R(2,5) B(3,3) R(3,4) E(3,5)
|
||||
5 1.0 map20190604233125746257_auto|GC_Position 2,5 |GC_Area R(1,4) E(1,5) V(1,6) R(2,4) R(2,6) R(3,4) E(3,5) E(3,6)
|
||||
5 1.0 map20190604233125746257_auto|GC_Position 2,6 |GC_Area E(1,5) V(1,6) E(1,7) R(2,5) R(2,7) E(3,5) E(3,6) E(3,7)
|
||||
5 1.0 map20190604233125746257_auto|GC_Position 2,7 |GC_Area V(1,6) E(1,7) R(1,8) R(2,6) R(2,8) E(3,6) E(3,7) R(3,8)
|
||||
5 1.0 map20190604233125746257_auto|GC_Position 2,8 |GC_Area E(1,7) R(1,8) R(2,7) E(3,7) R(3,8)
|
||||
3 1.0 map20190604233125746257_auto|GC_Position 1,8 |GC_Area G(0,7) R(0,8) E(1,7) R(2,7) R(2,8)
|
||||
3 1.0 map20190604233125746257_auto|GC_Position 0,8 |GC_Area G(0,7) E(1,7) R(1,8)
|
||||
1 1.0 map20190604233125746257_auto|GC_Position 0,8 |GC_Area G(0,7) E(1,7) R(1,8)
|
@ -54,7 +54,7 @@ def generate_input(importance):
|
||||
i += 1
|
||||
input_file_content.append(input_line)
|
||||
#save to file
|
||||
filename = ".\VowPalInputData\input_" + str(tag) + ".txt"
|
||||
filename = "./VowPalInputData/input_" + str(tag) + ".txt"
|
||||
input_file = open(filename,"w+")
|
||||
for line in input_file_content:
|
||||
print(line)
|
||||
|
Loading…
Reference in New Issue
Block a user