Browse Source

Added the "chunky" flag.

master
Noëlle Anthony 6 years ago
parent
commit
5ef183fda8
2 changed files with 27 additions and 7 deletions
  1. 5
    0
      README.md
  2. 22
    7
      procgen.py

+ 5
- 0
README.md View File

* --reps *x*: the number of smoothing passes to take on the map. *x* must be a positive integer. Large values can significantly extend runtime. * --reps *x*: the number of smoothing passes to take on the map. *x* must be a positive integer. Large values can significantly extend runtime.
* --out: save the result to an image in the maps/ directory instead of printing it to the screen. * --out: save the result to an image in the maps/ directory instead of printing it to the screen.
* --color: uses random complementary colors in the saved image instead of black and white. *Does nothing if not used with the --out flag.* * --color: uses random complementary colors in the saved image instead of black and white. *Does nothing if not used with the --out flag.*
* --chunky: makes each cell 2x2 instead of 1x1. *Does nothing if not used with the --out flag.*


### A note on width and height ### A note on width and height


If you use --out, width and height are in pixels. If you use --out, width and height are in pixels.


If you don't, height is lines of text, and width is measured in **chunks of two characters**; "--width 40" will produce a map 80 characters wide. This is because each "wall" cell is represented by a double **I** character and each "empty" cell is represented by a double space; in the font the developer uses, this makes it so that if a map's width and height are the same, the map is roughly square. If you don't, height is lines of text, and width is measured in **chunks of two characters**; "--width 40" will produce a map 80 characters wide. This is because each "wall" cell is represented by a double **I** character and each "empty" cell is represented by a double space; in the font the developer uses, this makes it so that if a map's width and height are the same, the map is roughly square.

### Chunky cells

Smaller maps blown up to a larger size sometimes look better than larger maps, for some reason. The --chunky flag doubles the size of each cell, which makes the raw output twice as big and slightly more attractive. Use with caution on larger image sizes.

+ 22
- 7
procgen.py View File

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(x=None, y=None, seed=None, d_lmt=None, a_lmt=None, reps=None, out=None, color=None):
def main(x=None, y=None, seed=None, d_lmt=None, a_lmt=None, reps=None, out=None, color=None, chunky=None):
# Initialize # Initialize
x = 20 if x == None else int(x) x = 20 if x == None else int(x)
y = 20 if y == None else int(y) y = 20 if y == None else int(y)
reps = 2 if reps == None else int(reps) reps = 2 if reps == None else int(reps)
out = False if out == None else bool(out) out = False if out == None else bool(out)
color = False if color == None else bool(color) color = False if color == None else bool(color)
chunky = False if chunky == None else bool(chunky)
my_map = createDungeon(x,y,seed) my_map = createDungeon(x,y,seed)
if not out: if not out:
printDungeon(my_map) printDungeon(my_map)
if not out: if not out:
printDungeon(my_map) printDungeon(my_map)
if out: if out:
img = Image.new("RGB",(x,y),(0,0,0))
if chunky:
true_x, true_y = x*2, y*2
else:
true_x, true_y = x, y
img = Image.new("RGB",(true_x,true_y),(0,0,0))
lst = [] lst = []
c_wall = [r.randint(0,255), r.randint(0,255), r.randint(0,255)] if color else [0,0,0] c_wall = [r.randint(0,255), r.randint(0,255), r.randint(0,255)] if color else [0,0,0]
c_space = [255-x for x in c_wall] c_space = [255-x for x in c_wall]

for line in my_map:
for val in line:
lst.append(tuple(c_space) if val else tuple(c_wall))
if chunky:
for line in my_map:
for _ in range(2):
for val in line:
for _ in range(2):
lst.append(tuple(c_space) if val else tuple(c_wall))
else:
for line in my_map:
for val in line:
lst.append(tuple(c_space) if val else tuple(c_wall))
img.putdata(lst) img.putdata(lst)
hexes = ["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"] hexes = ["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"]
filename = [] filename = []
"--reps" : 2, "--reps" : 2,
"--out" : False, "--out" : False,
"--color" : False, "--color" : False,
"--chunky" : False,
} }
for flag, default in flags.items(): for flag, default in flags.items():
if flag in args: if flag in args:
flags["--out"] = True flags["--out"] = True
elif flag == "--color": elif flag == "--color":
flags["--color"] = True flags["--color"] = True
elif flag == "--chunky":
flags["--chunky"] = True
else: else:
flags[flag] = args[args.index(flag) + 1] flags[flag] = args[args.index(flag) + 1]
return flags return flags
flags["--birth"], flags["--birth"],
flags["--reps"], flags["--reps"],
flags["--out"], flags["--out"],
flags["--color"])
flags["--color"],
flags["--chunky"])

Loading…
Cancel
Save