I've been working on a simple procedural generation class which currently places rooms on a x, y grid and selects a starting room. Each room needs to be connected with passageways so the player will be able to access them. The part that I am having issues with is how to actually connect the rooms.
There's a number of algorithms I've seen online, but I am unsure how to implement most of them.
As for my implementation of placing the rooms, the code tries placing them randomly on the grid until I get the desired density of rooms. After each room is placed, it is added to a list which stores the dimensions of the room. A room is them randomly selected to be the starting room.
Preferably, the rooms should be connected with their nearest neighbor. I'm not sure what the best way to go about this is.