Alright, so chances are I might be diving right in unnecessarily as I haven't done my own experimenting, but... I'm not much of a programmer (I did try things here and there outside of Game Maker but all of it is more or less simple console stuff with the exception of one Allegro image masking test) and I have no idea how to handle algorithms in general, so at the very least please help me with those
So let's say I want to create an engine that generates a random PMD-esque dungeon, one with rectangular rooms of varying sizes that are connected by corridors with items sprawled around and a staircase placed in one of the rooms, in Game Maker (either 8 or Studio, preferably the former). While I'm not entirely sure how to program that, I have a plan of how I want the (bare-bones) process to go. Basically this:
Step 1: Prepare a big generic block for the wall tiles. This will be the max size of the dungeon floor that's x tiles wide and y tiles high.
Step 2: Lay out a randomly generated number of rectangular blocks onto the bigger block. These will vary in size and will serve as rooms, so they are where ground tiles will be placed (i.e. we're carving hollow areas in a solid block). They must have an offset that prevents the rooms from touching, coming close to or going over the big block's edges.
Step 3: Create corridors. They are virtually the same as rooms, except they have a fixed value in 1 direction (i.e. a corridor going horizontally has to be 1 tile high and a corridor going vertically has to be 1 tile wide) and they have to connect to each other, i.e. a corridor tile has to be adjacent to either a room, a room and another corridor tile, or up to 4 other corridor tiles, and in each case it can't be in both x and y direction i.e. diagonally. All corridors have to be connected to at least one room and all rooms have to be connected to at least one corridor that leads to another room. In addition, there need to be enough corridors to allow access to every generated room.
Step 4: Place objects into rooms. At the bare minimum there must be a staircase object placed in one of the rooms, an enemy spawn object (so that enemies can spawn on room tiles periodically), and a spawn point for the player in one of the rooms for when the dungeon floor is finished generating and the player starts playing it. Additionally, room tiles may also spawn other objects such as items, traps and pre-spawned enemies to greet the player.
Step 5: Apply the tileset on the generated dungeon floor layout. For a case where a ground tile and a wall tile connects, both kinds will have a different image depending on where and how many of them connect.
I hope you can see what I want to achieve. The only problem is that I am not entirely sure how to go about it in GML. In other words, I know the process I want to use but not how to translate this into code that the programming language understands. Game Maker's grid data structure function looks like the way to generate the bare-bones layout but after that I don't know how to continue from there.
So my question is, how do I tell Game Maker to use the grid to create something that looks like
this (I hope this pic is sufficient)? How do I implement the rules so that the generator generates the above and not a mess of randomly placed tiles? Any tips on implementing algorithms in general?
By the way, I would just like to try replicating (what I see as) PMD's apparently simple dungeon generator process before I try going for other people's existing algorithms. Hopefully I'm not biting off more than I can chew
Also sorry for possibly making this post a huge one guys! I've tried to elaborate my problem in a way that helps you help me, but if you have any questions of your own (e.g. if I wasn't clear somewhere) feel free to ask. Thanks in advance