Skip to content

Instantly share code, notes, and snippets.

@daaray
Last active October 19, 2019 01:48
Show Gist options
  • Save daaray/f020384c0bc376b61a76668bfc777317 to your computer and use it in GitHub Desktop.
Save daaray/f020384c0bc376b61a76668bfc777317 to your computer and use it in GitHub Desktop.
def topo_generator(min_elev, max_elev, width, height):
matrix = []
for y in range(0, height):
matrix.append([])
for x in range(0, width):
matrix[y].append(random.randrange(min_elev, max_elev))
return matrix
def topo_generator(min_e, max_e, width, height):
matrix = []
for y in range(0, height):
matrix.append([])
for x in range(0, width):
if y == 0 and x == 0:
matrix[y].append(random.randrange(min_e, max_e))
elif x == 0:
min_delta = int(matrix[y-1][x] * .90)
max_delta = int(matrix[y-1][x] * 1.10)
matrix[y].append(random.randrange(min_delta, max_delta))
else:
min_delta = int(matrix[y][x-1] * .90)
max_delta = int(matrix[y][x-1] * 1.10)
if min_delta == 0 or max_delta == 0:
min_delta = min_e
max_delta = max_e
matrix[y].append(random.randrange(min_delta, max_delta))
return matrix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment