Преглед на файлове

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

master
Noëlle Anthony преди 7 години
родител
ревизия
7a5f7cebde
променени са 2 файла, в които са добавени 34 реда и са изтрити 6 реда
  1. 1
    1
      README.md
  2. 33
    5
      procgen.py

+ 1
- 1
README.md Целия файл

@@ -1,5 +1,5 @@
# 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).

+ 33
- 5
procgen.py Целия файл

@@ -1,4 +1,5 @@
import random as r
import sys

def createDungeon(x=None, y=None, seed=None):
""" Initializes an x by y grid.
@@ -61,14 +62,41 @@ def printDungeon(d_map, wall=None, path=None):
print("".join([wall if x == True else path for x in line]))
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)
my_map = refineDungeon(my_map, 4, 4)
my_map = refineDungeon(my_map, d_lmt, d_lmt)
printDungeon(my_map)
my_map = refineDungeon(my_map, 4, 4)
my_map = refineDungeon(my_map, d_lmt, d_lmt)
printDungeon(my_map)


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)

Loading…
Отказ
Запис