Thursday, November 26, 2015

rpg - Strategies for monster targeting AI in a turn-based combat system


I am making a Final Fantasy-style battle system.


I have a random generator that select the monsters move when it is their turn; different moves have different chances to be performed. I also have reactions and conditional actions for the monster to create simulated intelligence... but what I can't figure out is targeting.


I could just choose randomly between the five player characters, but I was looking for something that would make the game more challenging by adding some kind of strategy to the monsters' actions.


I code in C++.



Does anyone have an idea how to implement a system for the monster to choose who to attack besides completely random?



Answer



My answer from this question would fit here.


To adapt for your problem: A monster would look to assign a score to each enemy. Pass the enemy to each of a collection of behaviour classes, which each return an integer score. Add all these scores together, and assign the final score to the enemy. Attack the enemy with the highest score.


This has the scope for different monsters having different behaviours, evaluating targets in different ways, and the personality extension I mentioned in the other answer could be modified at run time to alter target choice based on the monster's situation: maybe he becomes more aggressive as his health lowers?


From chaos' answer, you could keep a sticky target by remembering the score of the last target, and any new target would have to beat that score by some extra %.


Examples of the behaviours might be:



  • defenseless target behaviour: returns high scores for targets that are particularly susceptible to this monster's attacks - eg a mage vulnerable to red magic in a battle with a fire demon.

  • weak target behaviour: returns high scores for targets that are close to death


  • decapitation behaviour: returns a high score for the player or leader of the group

  • splash damage behaviour: if your game is a strategy-style rpg, that can make attacks across various team members, this behaviour could return high scores for targets that affect large numbers of bystanders, eg if a target is in the center of a tight group.


All of these behaviours are based on snapshots of the current game state, and require no long-term planning and little state on behalf of the monster.


More ideas: if your monster has multiple attacks, run this whole alg once for each attack, and pick the target/attack pair with the highest score. This was how I made enemy infantry select weapons on one big-budget FPS.


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...