Sponsored By

Designing Trudy's AI

A high-level look at the design of unit behaviour in our tactics game Trudy's Mechanicals.

Radek Koncewicz, Blogger

February 16, 2011

3 Min Read

When I initially sat down to design Trudy's combat, I wanted each unit to have a unique feel. Different attributes and abilities were a good start, but to truly achieve this, all entities had to behave in a distinct fashion.

To begin, I brainstormed a variety of scenarios I wanted to see in-game. These ranged from the somewhat common (an area-effect unit preferring to target foes clumped together) to the more original (a Steampunk robot trying to activate random machinery and only attacking when provoked).

Once I had a list of these, I came up with some character types that would facilitate each case.

Below are three examples of our finalized units, along with a short description and their AI routines. The AI is a bit simplified from the code, but shows a sorted priority of possible behaviours.

The Corsair

Corsair


The Corsair is quick and agile, preferring to take out enemies from afar. Due to his mercenary nature, he has a tendency of sidetracking to grab extra treasure and retreat from a fight if it gets too dangerous.

  1. If badly wounded, randomly alternate between the following actions:

    • Retreat to closest exit.

    • Head for a healing station, if available.

    • Take pot-shots at closest enemy in range.

  2. If defending, take pot-shots at first enemy that approaches.

  3. Grab any nearby treasures.

  4. Man any nearby turrets.

  5. Use saw-blade if upgraded and surrounded by 2 or more enemies.

  6. Attack closest enemy that's weak to the flintlock rifle.

  7. Attack closest enemy that's low on health.

  8. Pursue closest enemy until in flintlock range.

The Bruiser

Bruiser

The big and burly Bruiser is slow to act, but capable of travelling great distances once he's rolled up into a ball. As the muscle of the Underworld, the Bruisers pride themselves on their reputation and never run away from a fight.

  1. If badly wounded, randomly alternate between the following actions:

    • Put up defenses and wait.

    • Retreat to closest alarm station to call for backup.

  2. Don't move if current position blocks projectile attackers from hitting team members.

  3. Roll into closest enemy by a wall in order to push them back and cause extra damage.

  4. Roll into any nearby enemy.

  5. If upgraded, follow up a rolling attack with a ground slam for extra damage.

  6. Activate closest alarm station if requiring backup.

  7. Retreat from flying units that can't be targeted with the roll attack.

  8. Pursue non-flying enemies out of range until adjacent to them.

The Sewer Slug

SewerSlug

The Sewer Slugs mutated in the slop cocktails of the Underworld, slowly filling with acid and becoming living batteries. Although they're naturally docile, they're considered a dangerous nuisance as they don't avoid human habitats.

  1. If dying, explode in an acidic burst that showers the surrounding enemies in corrosive fluids.

  2. If badly wounded, randomly alternate between the following actions:

    • Retreat to closest nest if flying-charge is ready.

    • Use self-healing ability.

  3. If not attacked, simply move between closest nest and hatchery.

  4. Fire electric goo on closest enemy to damage and stun them for one turn.

  5. If flying-charge is ready, move toward closest enemy.

  6. If flying-charge is not ready, pass to regain it.

This highly autonomous behaviour means that there's no "field general" controlling the entirety of the opposing force. Instead, the combat takes on a gang-skirmish feel where each unit follows its own whims.

For quick, small scale battles where the units are all predefined, we found this to be a generally more fun approach.

Radek Koncewicz is the CEO and Creative Lead of Incubator Games, and also runs the game design blog Significant-Bits.  

Read more about:

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

You May Also Like