Correct formulas for random enumeration of a grid
This commit is contained in:
parent
49e261557c
commit
20cbf546f9
|
@ -90,7 +90,7 @@ class Generator:
|
||||||
yxs = [i for i in range(len(room) * len(room[0]))]
|
yxs = [i for i in range(len(room) * len(room[0]))]
|
||||||
shuffle(yxs)
|
shuffle(yxs)
|
||||||
for pos in yxs:
|
for pos in yxs:
|
||||||
y, x = pos // len(room), pos % len(room)
|
y, x = pos // len(room[0]), pos % len(room[0])
|
||||||
if room[y][x] == Tile.EMPTY:
|
if room[y][x] == Tile.EMPTY:
|
||||||
if room[y-dy][x-dx] == Tile.FLOOR:
|
if room[y-dy][x-dx] == Tile.FLOOR:
|
||||||
build_here = True
|
build_here = True
|
||||||
|
@ -160,7 +160,7 @@ class Generator:
|
||||||
positions = [i for i in range()]
|
positions = [i for i in range()]
|
||||||
shuffle(positions)
|
shuffle(positions)
|
||||||
for pos in positions:
|
for pos in positions:
|
||||||
y, x = pos // height, pos % width
|
y, x = pos // width, pos % width
|
||||||
if self.room_fits(level, y, x, room, door_y, door_x, dy, dx):
|
if self.room_fits(level, y, x, room, door_y, door_x, dy, dx):
|
||||||
self.place_room(level, y, x, door_y, door_x, room)
|
self.place_room(level, y, x, door_y, door_x, room)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue