Thursday, July 15, 2021

Metroidvania and Randomization: Forgetting the Moment

What comes to mind when you hear the term "Metroidvania"? Is it a connected world full of secrets and treasure? Is it a bounty hunter exploring a deep dungeon, jumping on platforms and shooting everything in the way? What about an rpg-esque level up system and a series of equipment that gets stronger as you progress? Deep lore that provides ultimate immersion?

What if I told you that the core of a metroidvania isn't any of that? It's actually just the map, with upgrades-as-keys needed to unlock areas. Take a look: https://www.kongregate.com/games/lozzajp/maptroid

Maptroid is a wonderful proof of concept. There are various lore bits scattered around the world to fill in the gaps, but the emphasis is on upgrades. You need a shovel to break through weak floors and a hammer to break weak walls. Cold areas need warm clothes. The map itself supports this; the first upgrade unlocks areas that you had seen before, but couldn't access due to the lack of a grappling hook.

Maptroid strips away all of the fancy graphics, world building, and platforming you would find in other, the game can be simplified to a basic story: Go left, find a key. Use it to move downward, find a second key. Repeat until you find all the keys and finish the game.

Creating a map in a more complex environment is a challenge. The world needs to have a cohesive idea. Traps, puzzles, roadblocks, and keys need to be scattered all over the places. Dead ends with precious loot entice the player into exploring every nook and cranny. Various parts of the map are intended to be replayed in the first run, let alone any replays that happen. All games need to start somewhere, so let's draw up a basic design for a procedural map that does one thing.

The Backtracking T




We start in the center. Basic controls are movement; we can go left and right. A door blocks our way to the right, and we can't jump, so we go to the left and grab a key. The key unlocks the door, so we go to the right and grab the next item. Now we can jump, so we go to the top of the map and touch the flag. You win!

This certainly works as a proof of concept. It has all of the core elements of a metroidvania: exploration, lock-and-key progression, and a connected world. The map was procedurally generated with an algorithm that can only follow one procedure with some slight variation, so you don't have to worry too much about testing branching paths, the map looping back in on itself, or odd ideas like the map changing as you progress through the run.

Let's assume that the basic mechanics are rock solid. At any given second the player has full control over the player. Platforming is fun, enemies are engaging, and everything on the screen does exactly what you want it to. At this very second, the game is great. A lot of games get built from the smallest details and expand over time.

Let's also assume that a game designer comes along and sees this well-working game and decides to layer on some of the more interesting things, like story and themeing. The generator gets split up into different zones. A Robot Named Fight separates its map out into a new city, a cave, a robot factory, an old city, and then expects you to travel these in reverse after you're done. This means we get to build from both ends of ground-up and top-down.

On the surface, there's nothing missing from this plan. The player's story should sound something like "The megabeast is closing in, you must defeat it! You start in a city, defeat a boss, grab a random upgrade, and progress into a cave where you do it all again. Find the cave's boss, grab the abandoned city's ultimate power, and return to the surface to defeat the megabeast."

Unfortunately, most procedurally generated games I've seen stick to this formula. The best ones focus on the "overall experience", while many of them focus on the interesting parts on the edge. They work on the smallest details like combat or upgrade variety or challenge. They might instead focus on the overall story, like a cult kidnapping villagers and the hero rescues the town, then takes on the elder god X'Tua Ulak. With all the effort and all the compromise to get both large and small working it should work out, right? Right?!

Desperation kicks in at some point when the developer realizes the entire process they thought would magically come together doesn't materialize. A lot of people will see the big and the small working just fine and assume they come together for a great experience. The novelty and the uniqueness of each experience will surely cover up any blemishes on the project. That is a trap that leads developers to layer on more and more ideas, or tweak and compromise on some of the core premises until the entire project is simultaneously hollow and bloated. 

Magic in the middle

 

What part is actually missing from the overall experience? In a phrase: moment-to-moment gameplay. It is the time period between twitchy active gameplay and a slow, methodical story. The moment-to-moment gameplay is where most games live and thrive, and is what many people mistakenly call 'Content'. This is the middle ground.

- Great mechanics. Platforming, upgrades, and combat. Timeframe: half a second
- MAGIC?!?! Timeframe: ???
- Great theme. Story and lore and bosses. Timeframe: 20 minutes to 300 hours

Let's focus on that middle part for now. Minecraft embodies moment-to-moment perfectly, to the exclusion of everything else. Combat is lame and movement is basic. It takes forever and a day to do anything. I would wager that you could tell me everything that went on the first day you played the game. Here's how mine went
1. The title screen started up, version 1.2 beta. I created a world called "New World". The game loaded up and I was off
2. Everything is made of blocks? This is cool, let me look around and get used to the controls
3. Sheep! Punch the sheep! I have wool? Place the wool? OOH THIS IS HOW THE GAME WORKS
4. Punch the nearest tree. Logs are nice, leaves don't do anything. Punch more trees.
5. Punch the sand. Water pushes me around, so I want more sand. Sand is life.
6. The sun is getting lower in the sky. I should find somewhere to shelter for the night. Dirt on the side of a cave is the way forward.
7. The sun is setting. I built a nice hovel with a doorway. The game is lagging now... let's go inside.
8. Nothing to do inside. Stare at the sand... I guess I can get the sand
9. WHAT THE HECK IS THAT AND WHY IS EVERYTHING EXPLODED?!?!
10. Delete world, throw computer in trash

That is the story of the first 15 minutes of gameplay. The minute, miniature story beats that define quite a lot of games. For some games this time scale runs on a bit too long and for others it gets compressed and chaotic, but the underlying structure is the same. This is also why older games tend to be more interesting than newer games. Filling 200 hours of content 90 seconds at a time is a nigh impossible challenge.

It also seems really weird that Minecraft would focus exclusively on the middle ground. There are a lot of ideas floating around about how game mechanics work and how overall game story progresses, but very little that focuses on the middle. When games were shorter, they had to fill in the middle as much as possible. Complicated mechanics are very hard to program in assembly, and memory limitations prevented anything but the most basic of games from having long-lived experiences. These games needed to focus on the most important aspect to deliver maximum potential. 

Building up Features

 

How do we deliver on the middle ground? We have obviously good mechanics and obviously good themeing. Generating a dungeon randomly is still missing something... let's add in some structure and see where that leads. The Backtracking T map needs a few more rules to it. Our initial rules:
1. The map is divided up into separate areas called zones. Each zone has a key area that unlocks the next zone. Zones are desert, cave, and mountain.
2. Zones have their own set of rooms, picked randomly from a list of choices.

We have the high end of design - zones - and the low end of mechanics - rooms. The design is flexible; it can be any size that we want. The design is also sparse enough that anything at all can be inserted. We can use this as a base to build off of and add in story, enemies, crafting, jukeboxes, liquid particle simulation, jaywalking, and stealing candy from the dirt.
 
Thinking that this is a complete design is a trap. If the design is so flexible that you can put anything in it, then it has to accept everything. The design doesn't add enough restrictions so anything that goes in needs to fit with everything else. The stories that the design will tell do not depend at all on the design, but from the content. If the intention is chaotic random happenstance, then it's a fine idea. If the intention is poor, you will end up with generic cookie-cutter pieces that make a complete puzzle of a square built out of squares.

We need more rules than that. Let's go deeper.
1. The map is divided up into separate areas called zones. Each zone has a key area that unlocks the next zone. Zones are desert, cave, and mountain. The starting area is a forest.
2. Each zone should be around 3 moments long, or about five minutes.
3. Zones have their own set of rooms. Rooms are grouped up into features, and each feature has its own story to tell.
4. Features can overlap and blend together.

Rooms in many metroidvania games try to capture a single moment in time. This is why Super Metroid's rooms tend to be so large. You will spend as much time as you need to in them, they are distinct and the expected time in any single room varies somewhere between 30 seconds and 4 minutes.

Features are a way of trying to string these individual moments along. They can form a miniature cohesive story on their own. If two features overlap, then they can blend together in a way that leads the player down a path from one miniature story to the next. You might end up walking down a path, stop to smell the flowers, get off on a side trail, find a squirrel, climb its tree, and then return to the trail. This was expected, and the experience still feels like a natural exploration of the world.

Features can also control the flow of difficulty and pacing in a game. A particularly difficult obstacle will be notable if the surrounding area is easier, and will seem out of place if it's put in at random. In fact, extra difficult obstacles are usually left out of randomized games because they break the flow too much. If you can guarantee that an infinite pit comes after a series of smaller pits though... you can work in the idea of a death trap at the end of a series of constantly increasing difficulty features.

The design structure for blending features looks like this:
<[ 1 ]=[ 1 ]=[ 12 ]=[ 12 ]=[ 12 ]=[ 2 ]=[ 2 ]>

Features 1 and 2 are both five rooms long. They have a significant amount of overlap in the middle. The overlap will take more effort to generate than simply randomizing everything around it, but will allow for much smoother transitions than "this magic portal leads to space". You might need to run some special code to generate two rooms on top of each other or have a kind of middle ground between the two.

An expanded blended map looks like this:
     [!1]=[12]=[2 ]>
      ||
{ !]-[!@]-[@#]-[#$]-[$%]-[% ]>
      ||
[AB]=[!A]
 ||
[B ]>


Every room blends into every other room here. The main intersection has a primary type [!] and a blending type [@].

Moment to Moment Story

 

Now that we have everything defined we should be able to define everything between mechanics and theme.

- Mechanics. Platforming, upgrades, and combat. Timeframe: half a second
- Rooms: Self-contained area for a story beat. Timeframe: one moment, 90 seconds
- Features: A small series of events with a cohesive experience. Timeframe: 3-7 moments
- Levels or Zones: A general area with a common set of features, difficulty progression, and significance in the overall story. Timeframe: 5 minutes to 2 hours.
- Theme. Story and lore, overall playthrough. Timeframe: 20 minutes to 300 hours

With these extra structures in place, what the story of The Backtracking T look like with a real set of assets?


- Test player controls. Examine your surroundings. Find a door that needs a round object of some kind and some kind of unscaleable mountain.
- Leave the forest and traverse the desert. It's treacherous, so keep track of the sandpits.
- Find the mystic gem. Quickly backtrack and dodge the sandpits, then put the orb in the door.

- Find your way through the cave, dodging bats and slick floors. Grab the climbing claws.
- Dodge and smash all the bats on the way out. The place is still quite treacherous, so it takes time, but less so because you can scale walls.

- The climbing claws let you climb the mountain! There are harpies, so you get knocked off multiple times and have to start over
- The top of the mountain has a harpy queen. She agrees to give you medicine for a mystic orb. Down you go and up you go, but quicker this time.
- Gain the medicine, the game ends.

This story takes 8 moments to complete. Each moment is a miniature arc in the story. The player can relate to each part, find a particular memory to differentiate it, and then describe in their own words what happened. The middle arc is the least defined of the group, but the middle of a video game can vary in length quite a bit based on the differences in player skill, experience, and knowledge of your game.

This is a far cry from the previous story of "go left, find the key, go right, find the key, go up, beat the game". Even better, the game can have bad mechanics, no story, look terrible, and have no sound. The chance you would remember this game as being a bad game would be high, but it would still hold your interest long enough to finish it. THAT is the important part.

By restricting the rules into a set of features, the designer is forced to think about each one of those features. Each one needs an emphasis and a connection to the rest of the world. By combining theme and mechanics, we have what lies in the middle.

Conclusion

Make sure you include the middle when procedures are written. Players do not live in the minute or on the theme. Grand overarching epics of greatness and wonder still need time to pass. Minute mechanics can be wonderful in an instant, but out of place with other things. Most importantly, stories are not constructed out of the largest or the smallest pieces. They lie somewhere in the middle.

We live in the moment. Make sure your game knows what a moment is.

No comments:

Post a Comment

Self Reflection, Avatar Reflection

It started as a joke. One day I decided that my game development was going poorly because I was too attached to my characters. If I messed a...