#Theorycraftimg: Rimworld/prison Architect style room detection

1 messages · Page 1 of 1 (latest)

modern iris
#

So, I'm wanting to add a feature to a game where you build a space craft, inside the space craft is broken into a grid, the player can erect walls, and what I'm wanting to do is have enclosed spaces be detected as "rooms" and assigned a purpose.

Now... The idea is each cell will be assigned a room identifier and then perform a validity check. A room will be considered valid if for every cell that has the same identifier, the following conditions are met:
A. Every cell is bordered on every side by a cell that has the same room identifier as itself.
B. Failing A, every side that is not bordered by an identically identifying cell, is bordered by a wall of some kind.

There is a yoyo asset that set out to do this here: https://marketplace.gamemaker.io/assets/8224/detect-rooms-like-rimworld

But it's a bit old and new features have been implemented in Gamemaker I think might enable to do the same thing better.

My idea is, take a room manager object, said ob contains a struct containing all player defined rooms. f the player clicks the define room tool, it creates a new sub-struct. The player can then click on cells which are added to the currently denoted sub-struct. Every time any struct is updated, all cells check if they satisfy condition A and/or B, and if yes, the struct is marked as a valid room.

I think this is the best way to do this that I could come up with. Thoughts?

trail horizon
#

For detecting rooms you would be looking at something like this, I guess: https://en.wikipedia.org/wiki/Flood_fill

Flood fill, also called seed fill, is a flooding algorithm that determines and alters the area connected to a given node in a multi-dimensional array with some matching attribute. It is used in the "bucket" fill tool of paint programs to fill connected, similarly colored areas with a different color, and in games such as Go and Minesweeper for d...