GMS 2 [Help] Procedural Dungeon with premade rooms


Hi, so recently I started to feel more confident in my programming skills and started to mess around with grids and lists, until I decided to try to do a random dungeon with premade rooms, and I can’t understand how it works, I mean, I understand the grid stuff and how each room corresponds to a cell in the grid, my problem is to understand what I have to write in codes so that my game knows which cell in the grid is adjacent to one that I already have a room??? And so on, how do I get the grid to choose a random direction from another room??

I'm using this tutorial that I found as a basis:

My problem is in item 5, how do I "choose a random adjacent cell for my grid to set to 1" ??

I'm going crazy trying to find a solution.

Thank u!!!


That's not what item 5 on the list appears to say. But to choose an adjacent cell you randomly choose one of four alternatives: y-1, x+1, y+1 or x-1. Which is not all there is to it, as you have to mind not crossing grid edges. If above text is all that there's to the tutorial, it seems to omit mentioning that you must be tracking your current grid position. You can't "choose adjacent" if you don't know where you are.

(Incidentally, this random wander proc-gen method is usually called the Drunkard Walk.)