Blogs

Artificial Intelligence (AI) in Rooftop Renegade

author george martin

George Martin

Monday 13 May 2019
gunners

image caption A group of Grunts ready to give chase!

Hello there! Melonhead’s friendly neighbourhood programmer here, ready to share a tale about the creation of our gunner’s AI (Artificial Intelligence). When I first started on this project AI wasn’t even in my mind. When we got our first build together at the 2018 Adelaide Global Game Jam it was exclusively a multiplayer experience. A party mode with gunners being controlled by other players and that was that. However, as we kept working on the project it became difficult to have someone else in the team playing as a gunner to check how playing the runner felt and without the hazards being destroyed it didn’t convey the same feel.

The origins of single player

In order to simulate having other players in the game while testing, our designer Patrick introduced a trigger box that sat around each hazard. This box when touched by the player would cause the hazard to generate a random value, with the result telling the hazard how to respond; either do nothing or self-combust in a dramatic fashion, as if it had been shot by a player. The more we tested the game ourselves in this developer exclusive single-player mode, we thought to ourselves “what’s stopping the game from having a single-player mode?” Player’s enjoyed just being a runner, why not let them? However, the hazards alone destroying themselves didn’t feel the same as having a player to blame for the untimely destruction of a hazard. This was when we created Jean; a character that, at the time, would only exist in single player. He would shoot at the hazards and receive many a curse for it even amongst the melonheads.

representation of trigger volumes

image caption Visual representation of trigger volumes (in pink) placed behind each hazard.

How I cheated AI

I had never created AI before, and when we debuted the single-player mode at AVCon, Jean was entirely for show. While to those playing the game, it looked like our antagonist was shooting hazards in their path and destroying them, behind the scenes it worked very differently. All that changed between our developer mode and this single-player experience was before the hazards self-detonated they would tell Jean to aim and shoot a harmless beam towards them before detonating themselves as they always had. Jean was only following orders from the hazards in the level and received all the blame.

A new problem

After AVCon wrapped up, we decided that a full single-player experience was a great idea and we began discussing other characters we could introduce as well as combinations to go up against. I then realised that my cheated way wouldn’t work. If it was for any character other than our sniper, they would potentially need more than one shot to destroy the hazards. The way it was set up also limited us to a single gunner when in single player. Both things needed to change so I delved back into the character and decided the best solution was to give the gunner a brain of its own.

The solution

I remade the whole system from scratch. I kept the trigger boxes around the hazards but gave them a new purpose. They now told the gunner when the player was close to the hazard and the gunners could make the choice of shooting it for themselves. This means the hazards no longer destroyed themselves and the gunner would now shoot projectiles the same way they would if controlled by a player.

This new system can now scale with any number of characters we make for party mode inheriting their traits like damage and fire rate. The new system can also set the number of gunners in a level, and which character they each are. As a runner approaches a hazard each gunner individually takes note and decides if they will shoot it based on predetermined chance or wait for another opportunity. To give a bit more warning before a hazard is destroyed, we added a crosshair that shrinks onto the target before the gunner starts shooting.

hazard being destroyed

image caption Svet entering the trigger volume and the AI destroying the respective hazard.

These changes to the gunner have gone somewhat under the radar but were first debuted at the recent playtest at greenlight comics. It may not have looked much different from what we had at AVCon but know the gunner is a lot smarter now. Keep an eye out for them in future levels, they’ll be back and in greater numbers.

Signing off,
George Martin

Join the mailing list

where to find us

Adelaide SA 5000

hours

  • Monday to Friday: 9am – 5pm
  • Sat/Sun & public holidays: closed

join the mailing list

© 2022 Melonhead Games