Minimap goodness

I added a minimap to the game. It was originally just to help me with debugging but it’s actually pretty useful for normal game play. The minimap allows you to see the whole map at once. This lets you find errors with terrain generation, pathfinding anomalies and all sorts of general wonkiness that you might otherwise miss.

For example, here’s a minimap view of a few survivors pathfinding to random waypoints. There’s something wrong going on, though. Try to see if you can find it!

I’ve now got it specifically set to not clear each frame which causes a noticable trail affect. This allows us to see everywhere the survivors have moved instead of only where they’re currently at. Can you see the problem, now?

The little buggers are pathing through walls! That’s no good. I do plan to eventually add ghosts (to be discussed in a future monster post!) but now isn’t the time. I wasn’t aware of this issue previously, so without the minimap, who knows how long it would of taken to discover?

The source of this problem was the path map. I accidentally created it using (y, x) coordinates instead of (x, y). That means it was basically flipped or mirrored. Or, in other words, the path map did not align with the terrain map. Here is an example of what that looks like. The left example is the messed up path map.

The beings use this path map for path calculations. The terrain map is just so I know where to draw what. It otherwise has no bearing on gameplay. This is what was causing them to path through walls. They were actually doing exactly what they’re supposed to do. It was my fault for feeding them the wrong information.

Also, just for the heck of it, here’s a bunch survivors moving around while the bug is still active. This makes it far more obvious. It also makes it look like a busy subway map! The minimap is a incredibly useful tool and I strongly suggest other developers implement it for visual debugging.

Here’s the same trail affect using a corrected path map. Much better!

Let me show you some other fun stuff I shoved into the minimap! Here is a heat map. This first video is just the heat map on its own.

This is the heat map overlaid on the terrain map.

Every time a survivor moves they add a 20 to their location in the heat map. Every turn all the values in said array are reduced by 1. The more beings that visit the same tile the hotter it gets as that locations value doesn’t have enough time to fade away. This allows you to see the most active portions of your map.

The side walks near the middle of the map are obviously the most traveled areas followed by building corners. The least traveled areas are the map edges and building interiors. This remains true no matter how many times I randomize the map as shown in the video. The last example in the video was actually the worst. The buildings were so big that their weren’t many roads to use. This also caused a noticeably lag spike.

This heat map could actually help me with fine tuning the map generator. Everyone is sticking to the roads because they’re really the only path from point A to B. The buildings never connect to a neighboring building so they’re all dead ends. That’s just asking for disaster in a zombie apocalypse! Moving through buildings, across roofs and other less visible or otherwise alternate paths is a common trope in zombie media. I need to give buildings more doors, add alleyways between buildings, convert some buildings to empty plots and more to better support that. I’ll show you the results of these improvements in a later post!

The heat map could also be used for game play purposes. I could have cautious survivors avoid pathing through areas with a lot of zombie activity. I could also have zombies move towards areas with high survivor activity. Maybe animals want to avoid any activity all together! There’s a lot of potential uses.

The minimap works by drawing everything on a 1×1 pixel level instead of 12×12 ascii tiles. That allows me to see an entire level at a glance even if its pretty big. I can fit up to a 720×720 sized map on a 1280×720 screen using the minimap. That’s 518400 tiles! I can only fit a 60×60 area of the map on screen at the current 12×12 ascii font size so you can see why the minimap is handy. That’s 3600 compared to 518400 visible tiles.

If you were wondering, this is what a 720×720 minimap looks like.

It’s also stupidly fast since I’m using pygame surfarrays to just straight up blit the numpy terrain array. That means I don’t have to manually loop over every single tile and draw them. I can’t do any efficiency calculations, such as drawing only tiles that are within the camera viewport, as we’re purposely drawing the whole map. Even for the default map size, which is a moderate 200×200, that’s 40,000 tiles! I did a test to see how slow individually drawing all those would be and it knocked my frame rate down to unplayable single digit numbers.

Here is a standard minimap in its native habitat. That’s pretty hard to see, huh?

I realized that, too. I’m going to add some controls that will let the player scale the minimap by pressing the + and – keys. Later I’ll be adding a more traditional full screen style overview map that the player can zoom much closer to and also drag their view around. I’ll probably let them doodle on it, too. That way they can mark supply caches, zombies hordes or just draw dicks. Implementing this feature will make it easy to later add support for other beings having maps that the player can loot and analyze for information. Maybe you can find treasure maps, paths to hidden safehouses, directions to settlements and more. That’s all for another day, though. I need a writing break!

1 thought on “Minimap goodness

  1. Pingback: The undead masses | The Rougitects Blog

Leave a comment