Shining Online

July 23rd, 2008 09:29 Development Diary

Shining Online – How we did AI

Hind Beetle - The Atari ST Version Woah, a Shining Online update! Unfortunately there’s nothing really new in this entry, but if you want to see how the old demo worked you might be interested.

I’ve tried to extract as much useful information from the original source code as possible, but it really was a mess. Blame my youth and inexperience for that :P

How the AI worked, or “Everybody hates Ken”

If you’ve played Demo 4, you probably notice everybody gangs up on Ken. It might think it’s because of his awesome blue hair, but that’s not the case.

Every time an AI in Shining Online decides to move, it has to decide whether to attack, move or defend (and heal/support if I’d got that far ;)).

Who do we attack?

The AI would first cycle through every player on the battlefield. Each player is assigned a score to work out how dangerous they are to the current enemy and how likely they are to die.

Scores were assigned based on the following:

  1. Players with less than 25% health get 15 points.
  2. Players that can be killed by this enemy (health < attack) get 25 points.
  3. If enemy attack multiplied by their bravery was greater than the player defence, there’s a 10 point bonus.
  4. Closer players are given higher scores.
  5. 10 points are added for each enemy the player has killed.
  6. Cody has a 10 point bonus for being the team leader.

All the scores are then sorted, and the enemy has its target. However, not all targets are in range, so a little extra decision making needs to be made. If the player was out of range, but the enemy had high bravery they’d rush towards them, otherwise they’d stay still.

And that’s all there is to it!

Further Improvements

The addition of healing would have made things far more interesting, but I was far too lazy to add it.

Here’s a couple of improvement ideas for the next version:

  1. Take healers and mages into account, especially ones with multiple hit spells.
  2. Look at what other enemies are doing.
  3. Have an “order” queue that can have instructions added to it by the boss enemy. For example, if the boss felt threatened by someone, they could send minions to destroy them. This could also be used to instruct units to heal others.
  4. Don’t move into dangerous squares. Each square could have a "danger" rating assigned to it, calculated by adjacent enemies and land effects. Enemies would avoid squares with high danger values.
  5. Magic and support. Perform attack spells on the heavy hitters, or boost the defence of healers and "tanks".
  6. Personalities and vendettas. The "bravery" attribute was an attempt to do something like this, but it sucked.

The biggest problem with all this is keeping things fun. An AI enemy is playing to win, but it has to do it in a fun way. Having enemies do a pincer move or set you up for defeat can be fun to play, if it’s done in an imperfect way. This is where personalities and randomness come in, as you don’t want enemies to always react the same way.


Newer Entry: Project Update – May 23rd, 2020
Older Entry: A look at the SO Editor