How can I check if a room is formed on a grid system?

Hey I want to check when a room is fully enclosed but i dont know how.
I found some answer regarding FloodFill but i dont know how to make this work with my current system.

This cause a tile can have multiple wall North, East, South, West, and Diagonals. So i cant just check if a cell has a wall.

Looking forward to your reply!
I put an example down below how rooms can be formed.

Floodfill is good for raster images… I suppose you could snapshot your level into a texture and then floodfill.

Alternately perhaps use the NavMesh stuff to try and bake a navmesh at runtime, then see if you can get from inside the room to somewhere outside of it.

Or maybe something with raycasts to follow along a wall, but you’ll always have the chance of stepping over a very narrow opening.

Computer vision is a Very Hard Problem™.

1 Like

It seems a general answer could be check for closed polygon shape.
In your case, it seems you are in 2D and have certain rules for creating the rooms (fixed wall anchor points in a grid) which allows optimizations…

1 Like

I don’t quite understand why you can’t use Flood Fill… you’d be pretty much doing the same thing. Instead of checking if a cell is a wall, you’d just check if the direction the cell is would have a wall.

1 Like

Agree. Based on the sample image, I doubt it’s fit for purpose, but should work in principle.

1 Like

Ah okay so check the wall is the correct diagonal?

Thank you for the reply!

I will check out your sugestion

Not sure what you mean with 2d, do you mean the placement? x y

Yes, it seems that you mean with fully enclosed room in 2d space. (No consideration of wall height, roof, etc)