Blog 710: Fun With Level Generation

Every so often in your life you realise you’ve gone down a massive dead end, and you have to go back to go forwards. This is the point I’ve now reached with my existing level generator; to add the decorative features and traps and sensible enemy placement I need, the current approach just ain’t going to cut it.

So enjoy this video, because it’ll probably be the last visual demonstration for a few weeks.

Progress Report

A. Level Generation: 6/8

Up until now, I’ve been doing level generation pretty bass-ackwards. I’ve been choosing random shapes for rooms, carving them out of the grid, and then retroactively trying to squeeze items, decorations, enemies and patrol routes back into them.

This ultimately leads to an incoherent mess; each room is just a random collection of sub-components rather than a place with mostly-plausible layout and function.

So there goes my whole bunker generator and it’s right back to square one. Well, not completely square one — the layout generator has always been decoupled from the printer and it’s still binary-space-partitioned before all that. It’s just the thinking part that fills in the blanks that’s going to shift.

The plan is to give each partition a particular “role” or “theme” before doing anything else. This will then inform what shapes its room needs to be to fulfill that role — where the patrol route nodes need to go (if anywhere), where there needs to be a slot to contain a treasure chest, what decorations are needed to support a laser fence trap, and so on. Some room roles will simply not fit in some partitions, and that should be okay.

An unfortunate side-effect of all this is that the natural cave sections need to be discarded. They spread in irritatingly unpredicatable ways, and to be honest, the cellular automata algorithm doesn’t produce very interesting results at this resolution anyway. Natural caves will be saved for the basis of an entire level, rather than annoying sub-sections jammed in without reason.

B. Level Navigation: 1/2

Because I’ve got a very solid open/closed pathing grid, it should be possible to make a minimap (and by extension, fog of war) find all the nearby tiles that are visible to the player just by drawing radiating lines out from the hero’s position. If there’s a wall in the way, that tile is still hidden fromm sight; if not, then it’s visible and the mask peels back. I have an implementation of Bresenham’s Line Algorithm in my world shape carving code, though I’m not sure about the performance implications of drawing 20-odd lines per frame to test surrounding tiles.

It sounds plausible though, doesn’t it?

C. Item Systems: 4/4

D. Ability Systems: 2/2

E. Power-Ups: 2/3

F. Neutral Passive: 0/3

G. Enemies: 4/5 + 1

An extra piece of long-overdue bot logic was wandering behaviour. Bots were previously only capable of standing still or patrolling, but sometimes you want to just dump them into a room and have them meander about a bit. Sometimes it’s just too impractical to generate patrol routes because your room generator is so guffed.

With this new behaviour pattern they’ll stick close to a “nexus” point but will otherwise walk between random points that they can see, and stand around for a bit when they reach them.

Miiiiight also have started playing with potential cover imagery on the side.

Miiiiight also have started playing with potential cover imagery on the side.

Then I mounted the Spiderbots with stun guns to engage enemy spell casting (feature G5). Abilities for me are ostensibly split into two groups; there is the lone left-click ability that forms the primary attack, plus up to five secondary abilities as go along the QWERT keys.

As with all my game systems, the foundational tenet of my design philosophy is that it’s the same for the bots as it is for the you. They’re not playing mouse and keyboard but they’re feeding their vehicles exactly the same “orders” that you are.

Much the same as a human player (a naive one at least), the bots need to position themselves favourably in the world based on their primary ability, generally by trying to get close enough to the target. The secondary abilities are used more opportunistically; there’s a mix of “can I use this ability?” and “should I use this ability?” before they actually let rip, but they won’t change their movements to line up a perfect nuke.

At some point I’m going to need to add some mutual exclusion, so that more well-equipped bots don’t just unload everything as soon as they notice you and then do nothing else, but I’ll wait and see how the current systems pan out before diving down that rabbit hole.

H. Traps: 0/4

Having said that I’m still at 0 out of 4 features in the trap stakes, I have added air vent turbines as decorations that fulfil the role of a free-standing “wall” tile, and falling into these results in instant death. Does that count as a trap? It’s not the laser gates I’m ultimately promising, but it’s a start.

I. User Interface: 3/3 + 1

Ahhh, feature creep continues.

That fourth feature is, of course, the combo kill counter. It’s a pretty straightforward system; you kill something, the timer starts, and if you kill something else within the timer your combo level goes up and the timer resets.

Aaand it flashes up on your screen in big red text. I actually already have some rather good announcer voices recorded for this too, that I did as the first test run of my new microphone. Will this be my first foray into the addition of audio to my game?


So, still counting those features that were completed but have been cancelled, and adding those that have been appended, I have now completed 24 out of 36 features. Two steps forward, two steps back?

Bah. Once Level Generator Mk2 warms up I will kill many birds with one monstrous stone. Decorations and varied tiles will fall as part of that work and the power and control it will give me over room structure means that traps and destructible loot crates will soon follow.

That just… uh… might be in a couple weeks. Wish me luck!


And you tell me...

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s