diff options
Diffstat (limited to 'misc/maze.py')
-rwxr-xr-x | misc/maze.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/misc/maze.py b/misc/maze.py index 9a2c2d7..19b02b2 100755 --- a/misc/maze.py +++ b/misc/maze.py @@ -1,4 +1,5 @@ #!/usr/bin/python2 +# TODO: Automatic 20x20 margins import numpy from numpy.random import randint as rand @@ -10,6 +11,12 @@ def tile(): 1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,10] return str(tiles[rand(len(tiles))]) +def block20(txt=True): + if txt: + return "5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,"; + else: + return [5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5]; + def generate_maze(width=81, height=51, complexity=.75, density=.75): """Generate a maze using a maze generation algorithm.""" # Only odd shapes @@ -130,12 +137,17 @@ while MazeID < MaxMazes: MAZEDATA="" for line in TRUEMAZE: if line != []: - MAZEDATA+=(str(line).replace('[','').replace(']','').replace(' ','')+",\n") + MAZEDATA+=block20() + MAZEDATA+=(str(line).replace('[','').replace(']','').replace(' ','')) + MAZEDATA+=","+block20()+"\n" # Clean MAZEDATA properly MAZEDATA=MAZEDATA[:-2]+"\n" #MAZEMPTY=MAZEDATA.replace("10", "1").replace("2", "1").replace("5", "0") MAZEMPTY=MAZEDATA.replace("10", "0").replace("1", "0").replace("2", "0").replace("5", "0")[:-1] + # Margin fix + width+=40 + # Write the TMX file f.write("""<?xml version="1.0" encoding="UTF-8"?> <map version="1.0" tiledversion="1.0.3" orientation="orthogonal" renderorder="right-down" width="%d" height="%d" tilewidth="32" tileheight="32" nextobjectid="1"> |