Sponsored By

Featured Blog | This community-written post highlights the best of what the game industry has to offer. Read more like it on the Game Developer Blogs.

Building AI to Fight on the Beat of BPM: Bullets Per Minute

As the game launches on PC, we sit down with developers Awe Interactive find out how AI design and level generation are built to support this rhythm-focussed first-person shooter.

Tommy Thompson, Blogger

September 11, 2020

14 Min Read

'AI and Games' is a crowdfunded YouTube series that explores research and applications of artificial intelligence in video games.  You can support this work by visiting my Patreon page.

Bullets Per Minute is a brutal and fast-paced shooter that has players blasting through hellish dungeons in sync with some thumping rock opera. Building a rhythm game where players need to fight on the beat but are still able to lay wastes to hordes of monsters presents an interesting problem not just in developing player mechanics, but how the enemy AI design and behaviour fits into the core gameplay systems. In an interview with developers Awe Interactive, we find out about the games inner workings. So start banging your head to the beat as we find out not only how the game works, but also how AI and Games inadvertently helped give birth to Bullets Per Minute.

BPM: Bullets-Per-Minute


BPM: Bullets Per Minute is a fast-paced first-person shooter that is also a roguelike. Each instance of the game is procedurally generated with unique map configurations that keep players on their toes with each playthrough as they fight through monstrous hordes inspired by Norse mythology. But, the core mechanic of the game is that players play to the rhythm: firing weapons, dashing and reloading all occur in sync with the music, with bigger rewards and higher scores accrued for clearing rooms while every action lines up to the beat. Announced in April of 2020, the game reaches PC in early September, with console versions planned for 2021. During the closing weeks of development, we sat down with Dave Jones - BPM's game director and programmer - and Josh Sullivan - who handles level and sound design - to find out more about the origins of the game, how the AI works for the enemy characters as well as how the level generation processes used to keep each and every run of BPM unique

The concept of BPM pulls from many existing games, but melds them together in a way that players have never experienced before, but is immediately obvious when you see it for the first time.

"So BPM is very much if you just imagined what would happen if you crashed the roguelike elements of Binding of Isaac, the rhythm mechanic of Crypt of the Necrodancer and the aggressive 90's action of DOOM. It originated in one day from watching documentaries. One was your deep dive on the DOOM AI, the other was the No Clip DOOM making-of and I was binging these documentaries in one day and on the same day I walked past my friend's desk and he was playing Crypt of the Necrodancer and Binding of Isaac basically back-to-back. He did it every day. It just immediately clicked to me that DOOM and Crypt of the Necrodancer could be the same game? laughs Like you could make a game that is 'shoot on the beat' instead of 'swing your sword' on the beat. And everything, every gameplay feature was just kind-of obvious. Y'know the fact that we've got some guns that fire on half-notes like BANG BANG BANG and then we have some that fire on quarter notes. This kind of thing is just there when you're exploring the idea in your head."

Dave Jones

Fighting on the Beat

The enemies in BPM - like any other shooter - need to provide an interesting and diverse challenge for players to fight against. But what is most interesting, is that each character is constrained to only think and act on the beat. The game is built around the principle of a beat, a basic unit of time in the music. Each action by the player or an enemy - with exception of movement - is coordinated to synchronise with the beat. Specific actions are designed to only execute on the whole note - which are the larger chevrons on the crosshair, or in some cases on the half-notes, which are the smaller chevrons and even the quarter notes in between. This changes with each action based on their cooldown timer.

"So as you play the game you'll see chevrons coming into the crosshair. And the big ones are like major actions and the small ones are like minor actions. As a player, you can do any action on the on-beat or the off-beat which is like every whole note or every half note, but different things have different cooldowns. So for instance, the shotgun has a half-note cooldown so you can fire it ever half-note. But you need to pump it every half-note, so effectively it has a fire rate of one. So you have to go BANG-CHICK BANG-CHICK BANG-CHICK BANG-CHICK every single time you fire that gun. Whereas the pistol you can fire it on every single half-beat. The rocket launcher you can fire it on every beat, but it has a cooldown so you can't fire it until a full beat has passed."

Dave Jones

In addition, some of the larger and more aggressive enemies - including the bosses - force specific behaviours on the beat. Such as dodging a move that takes up half the screen or jumping off the ground as they apply an area-of-effect attack. When this is combined with the fairly large range of enemies, from spiders to bats, flies, slugs, scorpions, ground thumper people, spider-people and more - all of which synced up to and coordinated around the whole and half notes of the music, the two burning questions on my mind, are how does it work? And how do you coordinate that so it doesn't turn into a chaotic mess?

BPM is built in Unreal Engine 4 and while the engine provides a behaviour tree system for building character behaviours, it isn't used in this game. BPM does something a little different; the game relies on a custom architecture where each enemy is given the opportunity to process information at different time intervals.

"So all the enemy attacks are always to the beat. Every single decision they make is to the beat. There's nothing they don't do on the beat, apart from turn to look at you essentially. Or move on their path they've decided. So every beat, they'll decide their path, they'll decide their action. But sometimes they might be a more erratic enemy that decides what they're doing every half-beat. So we have things like our first boss Draugr, and so, for instance, he does sixteenth attacks when he charges up. So he'll charge up his hands then go like *PEW PEW PEW PEW PEW PEW PEW* [laughs]. And every beat, there is octuple, quadruple, double, whole-note, half-note, quarter-note, sixteenth-note and thirty-second note. And every AI, every second, every time one of those events happens will run that logic in that part of them. So if they do something on the 16th, they'll look at their 16th logic."

Dave Jones

Typically an AI would process their behaviour on each valid frame of execution, given in a normal UE4 behaviour tree you process on the tick()- and with a bit of know-how you can slow down how often the Behaviour Tree ticks an update. But in this case, it's hardcoded to only allow for specific updates on the whole, half, quarter and even smaller note intervals. By limiting the AI to only acting on the note timings, it synchronises the enemies to be in line with the player. This helps manage the expectations the player would have that - given they are constrained to the beat-mechanic, it would be unfair if the AI was not.

Coordinated Chaos

Given each enemy in BPM is acting on the whole or half note, it would actually require even more coordination to ensure that it doesn't become overwhelming. Unlike other shooters where enemies have free-reign of when in a given second they can act, everything in BPM is constrained to the note system. Hence you might have a whole stack of enemies trying to attack you on the exact same beat. Thankfully, BPM adopts the same principles as DOOM (2016), by having a system that not only influences how many attacks can occur on a given note but also limits specific attack types and the number of a given unit that can attack at once. Plus it imposes constraints that prevent attacks that would force the player to do otherwise impossible or complicated actions - such as forcing a dash and jump or dashing two different directions at the same time

"So with our major events which are like dodgeables essentially - things that you have to take action to avoid - whether that's a jump or a dodge, those have limits and different enemies have different limits. So certain enemies like all of them can just chime in one beat and all throw something at you. But then other enemies might be limited to one or two: two of them can do an action at once. So you do have that kind of turntaking mentality. The way we see the game is like one massive stepsequencer. So if you were to open a music program like Fruity Loops or Ableton and you see like the whole thing divided up into this massive grid and then we see our enemies on the left and they are all the tracks. And you can only have certain combinations of what is going to happen at one time. So you'll never have a dodge attack and a jump attack on the same beat. So you might have a dodge, dodge, jump or a jump, jump, dodge but you will never have jump and dodge at the same time. And then we also have minor actions, which is basically just like a limit on how many enemies can do an attack on a certain frame. So for instance, if we spawned in thirty enemies into a room they wouldn't all shoot at once. They did at one point. But they don't now! laughs"

Dave Jones

"A lot of the enemies used to just spam projectiles at you and it wasn't really fun until we put the logic in where they would be able to choose - like the token system in DOOM - who gets to attack. If there's a room with five enemies and then compare it to a room with thirty enemies, there's still the same amount of projectiles coming at you because the system decides that and it doesn't overwhelm you."

Josh Sullivan

But even with these systems in place, there is still a need to consider whether the player can understand how and why they are being punished. Should an enemy get a shot off that hurts the player, ideally you knew that was coming your way, or at least you had the opportunity to recognise what was happening, hence spatial coordination of the enemies and preventing them from bunching up is really important. The end-result can still feel overwhelming if you're not careful, but instead of it being as a result of unbalanced play, it emerges from the challenges a player would face in any other shooter: prioritising targets based on the threat they possess and figuring out how to take them out - only this time you're kinda headbanging while you do it.

"It's similar in a way to Dark Souls where, you play it for the first time and you're terrible. And there is a learning curve and you get better at it and you realise you're getting better at it and it gets really rewarding. And in the same - definetely for me - and we've seen what other people have said and we've previewed the game, they've said the same thing: there's a learning curve, you get used to the mechanics and then it's really fun."

Josh Sullivan

Building the Dungeons

In amongst all of this is the level generation process: given each run through the realms of the Norse gods is designed to maintain novelty with each iteration. And while the level generation works effectively, the emphasis was less on creating complex and vast dungeon environments, but building something that fits the ethos of the game and its inspirations. In fact, once you know how the level generation works, you can see how clearly the principles of Binding of Isaac's level generation have been adapted to fit the purposes of BPM.

The game operates on a 32x32 grid, where each room is ultimately a square to fill that space. At each decision point, the game decides which of the room types it will generate from, with limits and probabilities imposed on specific templates. Hence while you'll typically bump into the two merchants, Huginn and Muninn, they only appear once per level and Huginn appears a lot more frequently than his slightly more metal compatriot. But while the structure and design of the in-game world is fixed to this grid notation, it still leaves a lot of room for variation in what occurs in each room. The room is but one phase of the configuration, after that it is also the specific enemies that are spawned into the space as well.

The player's current performance is fed through the level generation, influencing the statues that appear in the world that you tithe coins to for skill buffs, as well as influences odds of the Armory, Library and Bank appearing and what items are found within them. Meanwhile, mutators can appear on a given level with varying probability, with the difficulty and current level of the game influencing the odds of what you come up against. This can result in reduced gravity, icy floors, brittle enemies and darker environments. All of these systems help maintain novelty but also provide opportunities for the player to excel in a given situation.

"There's more 'wow' when you stumble across something just randomly and it's like amazing. It's just a great feeling of wonder I think when you're playing. I was on the very first level of the game and inside the armoury, there was one of the most powerful guns in the game and I managed to scrounge enough coins to buy it. And for the rest of the game, I had the best gun in the game and I was just destroying everything. And just that feeling of picking up that gun in the first level I felt so powerful. So yeah BPM is full of moments like that and it's what really makes the game for me as a player.

Josh Sullivan

Closing

BPM has at its core some interesting and well-crafted pillars from which the rest of the game can establish itself. The level generation while relatively simple is sufficiently layered to provide depth in multiple playthroughs, but the focus is really all about smashing bullets to the beat into the hordes of the underworld. The enemy movement patterns and actions are synced up to the music, but are balanced and designed to maintain diversity while keeping players on their toes. While it is early days, these elements combined with the simple yet effective core mechanic leaves plenty of scope for potential expansions or additions. But the proof will be in the pudding when players make up their own minds as they start bouncing to the beat of Bullets Per Minute.

Read more about:

Featured Blogs
Daily news, dev blogs, and stories from Game Developer straight to your inbox

You May Also Like