Ver código fonte

Added command-line arguments (in the order width, height, seed, death limit, birth limit) and defaults

master
Noëlle Anthony 7 anos atrás
pai
commit
7a5f7cebde
2 arquivos alterados com 34 adições e 6 exclusões
  1. 1
    1
      README.md
  2. 33
    5
      procgen.py

+ 1
- 1
README.md Ver arquivo

# Simple procedural generation of "dungeon maps" # Simple procedural generation of "dungeon maps"


Basic proof of concept. No real refinement at this point.
Basic proof of concept for a "cellular automata" model. No real refinement at this point.


Initial work based on [this tutorial](https://gamedevelopment.tutsplus.com/tutorials/generate-random-cave-levels-using-cellular-automata--gamedev-9664). Initial work based on [this tutorial](https://gamedevelopment.tutsplus.com/tutorials/generate-random-cave-levels-using-cellular-automata--gamedev-9664).

+ 33
- 5
procgen.py Ver arquivo

import random as r import random as r
import sys


def createDungeon(x=None, y=None, seed=None): def createDungeon(x=None, y=None, seed=None):
""" Initializes an x by y grid. """ Initializes an x by y grid.
print("".join([wall if x == True else path for x in line])) print("".join([wall if x == True else path for x in line]))
print() print()


def main():
my_map = createDungeon(20,20)
def main(x=None, y=None, seed=None, d_lmt=None, a_lmt=None):
# Initialize
x = 20 if x == None else int(x)
y = 20 if y == None else int(y)
seed = 45 if seed == None else int(seed)
d_lmt = 4 if d_lmt == None else int(d_lmt)
a_lmt = 4 if a_lmt == None else int(a_lmt)
my_map = createDungeon(x,y,seed)
printDungeon(my_map) printDungeon(my_map)
my_map = refineDungeon(my_map, 4, 4)
my_map = refineDungeon(my_map, d_lmt, d_lmt)
printDungeon(my_map) printDungeon(my_map)
my_map = refineDungeon(my_map, 4, 4)
my_map = refineDungeon(my_map, d_lmt, d_lmt)
printDungeon(my_map) printDungeon(my_map)




if __name__ == "__main__": if __name__ == "__main__":
main()
args = sys.argv
try:
x = args[1]
except:
x = None
try:
y = args[2]
except:
y = None
try:
seed = args[3]
except:
seed = None
try:
d_lmt = args[4]
except:
d_lmt = None
try:
a_lmt = args[5]
except:
a_lmt = None
main(x, y, seed, d_lmt, a_lmt)

Carregando…
Cancelar
Salvar