I am starting a new game where dungeon rooms are generated randomly across a grid in a map. I have made a couple games with dynamic maps like this and some of these early decisions I make haunt me for the rest of the development process, and I am self taught so I really wonder what more experienced game developers would tell me about this. The way I see it, there are two ways I can track the rooms in a dungeon. - The first one is to just keep an array of rooms, every time one is added, it goes to the back of the array. So they would be sorted in creation order. Coordinates of the room would be recorded in the room's class.This is simple. But the thing is, when a room is created, it needs to check adjacent rooms in each 4 directions, and if there is one a path is created connecting them. And so I need to loop through all rooms when a new is generated to check where paths will be added. This is obviously not great on performance, specially when rooms are getting generated all the time. - So my solution, which I've done in my last game, is to use a two-dimensional array to track the rooms. So when a room is added, it goes to a position in the array of arrays based on it's actual position in the game map. This way, when a room is created and starts checking the adjacent rooms, we don't need to loop anything, I can just use the expected adjacent coordinates to get the rooms I need to check.This makes programming a bit more complicated for me and therefore slower, as every time rooms are added to the left or bottom, the whole grid needs to be shifted, and calculations need to be made. I usually miss something and create bugs later on. But maybe this is how it has to be? - I am now thinking I can just stick to the first method, and also use a system like the second one just to record the array indexes of the rooms, and make them easier to find. But maybe there's a nice little tool I don't know about that could help with this? Sorry if this is a stupid or duplicate question, I wasn't able to find much when searching.