Metroid Generator: Hectate's adventures in PCG (offline)

Hectate

  • *
  • Posts: 4643
So with the recent ProcJam and playing some Ghost Song Beta I happened upon the idea of creating a procedurally-built Metroid game. This journal is to document my attempts in that vein.

The approach I'm using is based on the concept of Lock and Keys to arrange rooms in a logical manner to support player progression.

So far, what I've done is build an initial "world map" generator. Note that this is the overall map generation; it's purpose is to decide the location of each room and some settings that will impact them later on. The actual content of each room is irrelevant at this point, which is why the view is rather abstract so far. Later on, what you are seeing now could be used to build a minimap, but will otherwise be completely hidden from the player.
See it in action here.
Press Enter to regenerate the map. Each character (numbers, letters) shows the relative position and size of the room using that character as it's identifier.

Right now the algorithm is relatively simple. Starting at the top center, rooms are generated in a method of "randomly pick left or right" then "down", repeat; building a chain that winds downward end-to-end. The length of each room varies randomly, with vertical rooms running shorter on average than horizontal ones. This is done in an attempt to hopefully build up layers of horizontal rooms.

Future work will be to have the algorithm build up branches instead of just a chain of rooms. This will be done by going back to previously generated rooms and branching off them. This will require some awareness of existing rooms, both to avoid overlap (which is not possible in the current setup) as well as to build cross-connections.
I also want to include occasional (1 or 2 per map) large vertical shafts to act as a hub for horizontal branches. These would need to be inserted early in the process, perhaps independently.

Remember, right now this is just a way of building a world by slotting empty rooms into it where space permits. Later on, each of these rooms will also be generated, with the appropriate content and connections to other rooms. That will be it's own kind of fun. :)

« Last Edit: March 08, 2015, 04:08:21 pm by Hectate »
:
:
Patience is a Virtue,
But Haste is my Life.
Proud member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.

Hectate

  • *
  • Posts: 4643
[reserved for future use]
:
:
Patience is a Virtue,
But Haste is my Life.
Proud member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.

ceosol

  • *
  • Posts: 2261
I was thinking about doing something similar with slotting maps together in my sheep game. Of course mine would not be anywhere near as advanced or vast in level design :)

Rimrook

  • Posts: 251
Wow this is sweet!
Ya know, with a custom font a la bitmap font editor, you could probably turn those letters, numbers, and dots into the rooms and grid as seen in Metroid.

I'd play your random gen game in a heartbeat. :)

Hectate

  • *
  • Posts: 4643
Yeah I already switched to a bitmap font just to maintain the monospacing; later on I can render it with images or actual tiles if desired for further testing. It's definitely on the todo list.
I've also done some additional tweaks to keep horizontal rooms closer together. Right now I'm working on joining up vertical shafts; if they are aligned and there are no other rooms between them, I connect them (technically, delete one and extend the other).  There's some wonkiness with it right now (a room recently detected itself as a match, which my code should prevent, so yea...) but it'll be nice when it works. Thanks!
:
:
Patience is a Virtue,
But Haste is my Life.
Proud member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.

merrak

  • *
  • Posts: 2478
Interested to see where this goes! I was just thinking of taking a similar approach myself, although a "procedurally-built Metroid game" sounds a lot more complex than what I was thinking of doing--a simple one-way, infinite descent.

Hectate

  • *
  • Posts: 4643
Wee! Nothing new to show but I did optimize the code that checks for vertical alignment between rooms and it doesn't do silly stuff like matching a room with itself ;)

Small progress, more soon!
:
:
Patience is a Virtue,
But Haste is my Life.
Proud member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.

Bombini

  • *
  • Posts: 1299
Keep it up!
I am very excited to see what you are working on :)

Hectate

  • *
  • Posts: 4643
Minor update visually, but big stuff in the background. I fixed a few more bugs I introduced (Haxe for loops are silly sometimes) and got something working to a point where I can stop (which is good, because I need to go to bed).

If you generate a map now and there are vertical shafts aligned it will attempt to interconnect them. To do so, it starts checking for the existence of a horizontal room between the two. While doing so it will add an "x" to each point until it hits the end of the gap or a room in the gap.
Now, you'll see these generated in cases where there was another room blocking (so it stops above the room but the x's remain), but everything is set up so that in the cases where they can connect they will. Additionally, if I like the layout with some shafts that extend down into horizontal rooms, I can choose to keep those also eventually. We shall see.

I'll probably have to add a maximum length to vertical shafts so avoid unpleasant map generation.

Anyway, for now, press Enter a few times to see what you get!

Edit: Oh, and it does recognize when there is no gap at all because they're adjacent. Those will be connected too.
:
:
Patience is a Virtue,
But Haste is my Life.
Proud member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.

Bombini

  • *
  • Posts: 1299
I guess you dont need so much input but i found this algo algorithm very helpful to expand my awareness:
http://www.roguebasin.com/index.php?title=Dungeon-Building_Algorithm

Cheers!

Hectate

  • *
  • Posts: 4643
Hey thanks, I'm not sure if I've read that specific design before or not but I've definitely heard of similar ones. Not as relevant in my case because it's not quite a rogue-like but still interesting, thanks!

Perhaps those of us interested in procedural design should make a thread to collect our favorite links on the topic. I know I've passed a few around on IRC.
:
:
Patience is a Virtue,
But Haste is my Life.
Proud member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.

Hectate

  • *
  • Posts: 4643
Small update for the weekend; the vertical interconnections are working as desired so far. Try generating a few maps and you'll see that the higher rooms are extended down and the lower room is removed entirely (pay attention to the character used for each room). It's still not very Metroid-ey but interconnections like this are important to get that exploration going on.
:
:
Patience is a Virtue,
But Haste is my Life.
Proud member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.

Photon

  • Posts: 2697
Very nice. Though still rough, on occasion you can get some pretty interesting configurations generated, which is impressive given how early on this project is. Keep it up man.
Do NOT PM me your questions, because I likely will not respond. If I have replied to your question on the forum, keep using that topic. Thanks!

1MrPaul1

  • *
  • Posts: 1268
Good job, only one suggestion, i think all maps got to be generated from the start of the game, and got to be generated in some list game attribute. And all enters and exits from one level to another got to be in the same place.
it will be bad if after leaving some scene player will return to the completely new scene...

Hectate

  • *
  • Posts: 4643
Thanks Photon!

MrPaul: worry not, I already have it covered. What you see right now is a tiny subset (positions and dimensions only) of everything that is generated and stored for the map.
:
:
Patience is a Virtue,
But Haste is my Life.
Proud member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.