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:
- Players with less than 25% health get 15 points.
- Players that can be killed by this enemy (health < attack) get 25 points.
- If enemy attack multiplied by their bravery was greater than the player defence, there’s a 10 point bonus.
- Closer players are given higher scores.
- 10 points are added for each enemy the player has killed.
- 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!
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:
- Take healers and mages into account, especially ones with multiple hit spells.
- Look at what other enemies are doing.
- 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.
- 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.
- Magic and support. Perform attack spells on the heavy hitters, or boost the defence of healers and "tanks".
- 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.