Make generation more sparse by asking for extra space around rooms; also add out of bounds option to Map.neighbourhood

This commit is contained in:
Charles Peyrat
2021-01-08 07:38:47 +01:00
parent 605696dddd
commit 641f5c7872
2 changed files with 10 additions and 3 deletions

View File

@ -39,9 +39,16 @@ class Generator:
for rx in range(rw):
if room[ry][rx] == Tile.FLOOR:
ly, lx = y + ry - door_y, x + rx - door_x
# tile must be in bounds and empty
if not(0 <= ly < lh and 0 <= lx < lw) or \
level[ly][lx] == Tile.FLOOR:
return False
# so do all neighbouring tiles bc we may
# need to place walls there eventually
for ny, nx in Map.neighbourhood(level, ly, lx, large=True, oob=True):
if not(0 <= ny < lh and 0 <= nx < lw) or \
level[ny][nx] != Tile.EMPTY:
return False
return True
@staticmethod