-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWorld_Map_Generator.py
158 lines (140 loc) · 4.98 KB
/
World_Map_Generator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
import Location
import json
import random
BASIC_RANGE = [0,1,2,3,4,5]
# min SIZE = 6, I'd recommend 8 - 13 for good worlds, doesn't work past 20.
SIZE = 8
def Print_Terrain(grid):
for i in range(SIZE):
for j in range(SIZE):
# inverting j and i so the poles are north and south
print(grid[j][i].biome, end="; ")
print()
def Print_Emoticon(grid):
for i in range(SIZE):
for j in range(SIZE):
# inverting j and i so the poles are north and south
if grid[j][i].temperature == -1:
print('⬛', end=' ')
elif grid[j][i].temperature == 0:
print('⬜', end=' ')
elif grid[j][i].biome == 'water':
print('🟦', end=' ')
elif grid[j][i].elevation > 3:
print('🔺', end=' ')
elif grid[j][i].vegitation > 3:
print('🌳', end=' ')
elif grid[j][i].temperature == 1:
print('⬜', end=' ')
elif grid[j][i].temperature > 3 and grid[j][i].vegitation <= 2:
print('🟨', end=' ')
else:
print('🟩', end=' ')
print()
# def Print_Civ(grid):
# def Print_All_Map(grid):
# def Add_Pop(grid)
def Ocean_Generator(grid, flood_limit):
for i in range(SIZE):
if (flood_limit <= 0):
break
for j in range(SIZE):
if grid[j][i].elevation == 0 and grid[j][i].temperature != 0:
choice=[False, True, True, True, True]
if SIZE > 8:
choice.append(False)
if SIZE > 17:
choice.append(False)
flood = random.choice(choice)
if flood:
grid[j][i].submerge()
flood_limit-= 1
elif grid[j][i].elevation == 1 and grid[j][i].temperature != 0:
choice = [False, True, True, True]
if SIZE > 8:
choice.append(False)
if SIZE > 17:
choice.append(False)
flood = random.choice(choice)
if flood:
grid[j][i].submerge()
flood_limit-= 1
elif grid[j][i].elevation == 2 and grid[j][i].temperature != 0:
choice = [False, True]
if SIZE > 8:
choice.append(False)
if SIZE > 17:
choice.append(False)
flood = random.choice(choice)
if flood:
grid[j][i].submerge()
flood_limit-= 1
if (flood_limit <= 0):
break
return flood_limit
# climate is based on two poles and equator
def Basic_Polar_World_Generator():
last_veg = -1
last_height = -1
grid=[[None]*SIZE for o in range(SIZE)]
for i in range(SIZE):
for j in range(SIZE):
if last_veg != -1:
NEW_RANGE = BASIC_RANGE.copy()
NEW_RANGE.extend([last_veg, last_veg])
if last_veg != 0 and last_veg != 5:
NEW_RANGE.extend([last_veg+1, last_veg-1])
veg = random.choice(NEW_RANGE)
else:
veg = random.choice(BASIC_RANGE)
if last_height != -1:
NEW_RANGE = BASIC_RANGE.copy()
NEW_RANGE.extend([1,2,3])
NEW_RANGE.extend([last_height, last_height])
if last_height != 0 and last_height != 5:
NEW_RANGE.extend([last_height+1, last_height-1])
height = random.choice(NEW_RANGE)
else:
height = random.choice(BASIC_RANGE)
if j == 0 or j == SIZE-1:
temp = 0
elif j == 1 or j == SIZE - 2:
temp = random.choice([1, 2])
if height > 3:
temp-=1
elif j == 2 or j == SIZE - 3:
temp = random.choice([2, 3])
if height > 3:
temp-=1
else:
temp = random.choice([3, 3, 4, 4, 5])
if height > 3:
temp-=1
# creation function call
grid[i][j] = Location.Location(i, j, temp, height, veg)
last_veg = veg
last_height = height
Ocean_Generator(grid, round(SIZE*SIZE/5)+2)
Print_Emoticon(grid)
return grid
# climate of the world is generated similar to terrain and vegitation
def Basic_Nonpolar_World_Generator():
grid=[[]]
return grid
# generate planet with Islands and lots of water
def Basic_Island_World_Generator():
grid=[[]]
return grid
# generate world with square planets and void
def Basic_Galactic_World_Generator():
grid=[[]]
return grid
# generate world that uses z-levels for multiple planes of existence
"""
this sounds painful
def Basic_MultiPlanar_Generator():
grid=[[]]
return grid
"""
# testing area
Basic_Polar_World_Generator()