Rhythmic AI in Crypt of the NecroDancer

Crypt of the NecroDancer is an award winning indie game released in April 2015 by Brace Yourself Games. It centres around Cadence searching for her father in the titular crypt. Gameplay in NecroDancer plays differently to other roguelike games, implementing rhythm into every aspect of the game. All movement, be it by the player or enemies, is conducted in time to the main beat of the music that is playing for that level. Try to move out of time and you’ll lose your gold multiplier and your move for that beat.

So how does the AI fare for such a concept? In the below, self recorded, gameplay footage, the enemies, mini-bosses and zone boss all follow different, pre-determined patterns for their movement and attacks (where appropriate).

Certain enemies, like the slimes, move in a pattern, such as up then down and are highly predictable in their movement. The skeletons will follow the player at every beat, forcing a more intelligent approach to avoiding damage. The dragon mini boss acts different, moving once every other beat and taking a turn to charge up it’s fire ball attack. This gives the player breathing room to adjust their position ready for a safe attack and escape.

The boss, Deep Blues, plays out like a one sided chess board. Pawns move one space downwards when chosen and only attack if the player is in front of them. Knights move in their signature L shaped pattern and bishops move diagonally. Queens move slightly differently to their real life counterpart, only moving one square at a time but still pose more of a threat than standard enemies, along with the singular King enemy.

So how does it work?

Each enemy is given the basic requirements to work with the core rhythm mechanic. Each entity will follow a beat count and it’s movement pattern will follow this. For example, certain enemies move every beat whilst others move every two or three. Let’s look at the slime variants. The green slime enemies never move but each turn animate to bounce up and down. The blue slime type move up or down a space every other beat. The gold slime type moves in a diagonal square, moving each beat. Other, more advanced enemies however, follow the player in a variety of different ways, such as moving only when the player is moving away from them or having the player in their line of sight and moving in a straight line every beat until it collides with something.

For the most part, it is a case of the AI controller determining if there is an appropriate space for the next step of that entity’s behaviour to fill and occupying it or, if in range, attacking the player. Enemies that only follow the player, once found, have different rules by using path-finding algorithms to determine their next move towards the player.

Overall Thoughts

At an objective level, the AI included in NecroDancer is simplistic, with few constraints. This however, is by design. Having to follow the beat of the music already offers enough of a challenge to players and where the AI is simple, the game makes up for by including enough variety in it’s enemy types. By offering variation instead of complexity, the game is a more enjoyable and fun experience with a simple enough implementation of AI programming. Challenge is presented not by unfair difficulty but by clever use of mechanic implementation to create unique game play value. By doing that, any game’s AI could be simple yet challenging.

Leave a comment