# Maze generation not generating around rooms properly?

Attention Topic was automatically imported from the old Question2Answer platform.

I’m using Godot 3.1 on windows 10

I’m using an adaptation of Bob Nystrom’s dungeon generation found here (blogpost here) for a roguelike I’m working on. So far it works pretty well, but the only problem is that the maze gives each room a space of 2 cells on the southern and eastern borders, rather than a space of 1 cell like the northern and western borders (like it should).

It’s hard to describe so here’s a picture with the problem area’s highlighted. White = Maze start, Blue = generated maze, Gray = room and Purple = Wall.

The code for this is here in this paste: Wych's maze implementation - Pastebin.com though the code is somewhat messy atm.

Also I should mention that the floorRect is `var floorRect = Rect2(Vector2(0,0), Vector2(65,38))` and each tile is 16x16, but other than that all of the code is in there.

Also, I want to handle the room to maze connections in a separately from the generation (as Bob Nystrom does) so that’s why I want the single cell spaces to begin with. There’s probably a simple solution I’m overlooking, so any help at all will help!

Thank you so much in advance.

Edit: I found the problem. In the tileFill() function, I had to comment out the following `+1`

``````tileFill(areaRect, tileType):
var areaRectEnd = areaRect.end

var x = areaRect.position.x
var y = areaRect.position.y

var endX = areaRect.end.x #+ 1

var endY = areaRect.end.y #+ 1

var tile = tileIndex(tileType)
while x < endX :
while y < endY :
var currentCell = get_node("/root/Main/dungeonLevel").set_cell(x,y,tile)
y += 1
y = areaRect.position.y
x += 1
``````

However I’m still having a problem with the far right of the map as highlighted here:

I’m going to keep looking into this!