Artificial Intelligence in Turn-Based RPGs
#1
So I've been trying to write up some AI for my RPG Maker XP project. It will be used by both actors and enemies, so I am writing it as generic as possible. It got me thinking about what makes a good AI in an RPG, and what are the basic tactics one uses to play an RPG.

So, what do you think makes a good AI? Consider the AI for trainers in the portable Pokemons vs the AI in Pokemon Stadium. In the normal Pokemon games the AI trainers are reluctant to switch pokemon, while in Pokemon Stadium they switch freely. Why? Also, is cheating an acceptable way for an AI to cover its flaws?

To write an AI for an RPG, it would be helpful to understand how an RPG is played. What are some tactics you use when playing RPG Maker games, or any turn-based RPGs? A tactic I discovered is "the healer must heal someone whose health is lower than the attack power of all remaining enemies combined (in other words, heal the guy who could die next turn if he is ganged up on)."
Reply }
#2
I can tell you about my approach as I am in the process of writing the AI for Hartacon Tactics. I'm not saying it is the best one, and probably it will not suit any game.
What I do is I compare all possible actions, which in my case include also movement around the map, giving them a score.

The score can be based upon several criteria, such as:
A - how much critical damage will the action cause
B - how much critical life will the action restore
C - how many enemies are likely to be killed
D - the altered states that will be inflicted
E - how many critical MP will be consumed
and so on.

The concepts of critical damage/life/MP can be explained like this: if a character has 1000HP a damage of 50HP is not critical, if the character has 60HP, the same amount of damage of 50HP is very critical. This is the logic, you need to put this in math form.
Of course actions that cause higher critical damage get higher scores, actions that use higher critical MPs get lower scores.

The trick is to find the correct weights to apply, i.e. 100pts for (A) and (B), 50pts for (C), 25 for (D) and (E).
[Image: facebook_icon.png] [Image: youtube_128x128-120x120.png] [Image: deviant.png] [Image: save-point.png]
Reply }
#3
You bring up a very good point. HP/MP needs to be more carefully managed when it is low. And killing enemies is more important than doing damage.

For a simple turn-based system, I can imagine the most complete AI could just try all attacks on all enemies and choose the one that causes the most harm. 'Harm' being how close it brings them to death, as opposed to straight damage so it deal with the case of a high-HP low-DEF enemy. It gets a little more complicated when stat-ups/downs come into the equation.

How effective ARE stat-ups/downs anyways? It safe to say that stat-manipulating skills are best used at the beginning of a battle, but at what point would a battler be better off attacking instead?
Reply }
#4
I hate stat-changing skills because they eat up a turn that could be used to deal damage. Make sure your stat skills change stats enough to justify using them in the first place.
Charlie has a very good basis for an "intelligent" AI, thumbs up for that. Would you consider adding a little "random" into it too? Otherwise the AI will be a completely efficient killing machine and very tough to beat - a human doesn't always make the most effective choice. You could decrease this random factor for powerful bosses and increase it for "stupid" enemies like animals, berserkers etc.

You also want enemies to gang up on weaker characters, or characters who give the player a tactical advantage. If a healer is in range, hit them, and hit them hard.
Reply }
#5
Stat-changing skills could be considered as alterations of state. One could give them a score considering the effect (additional damage and what not) through a certain number of turns.

A random factor would effectively account for, let's say, the AI's proficiency. Good idea.
[Image: facebook_icon.png] [Image: youtube_128x128-120x120.png] [Image: deviant.png] [Image: save-point.png]
Reply }
#6
Right how I just have the AI run all options, and choose the one that is most effective (based on damage + states applied - states removed). The problem with this is it might make the AI "too good", and allow it to avoid things it shouldn't know about (It's not fun if you equip a Null Poison and then none of the enemies use Poison anymore.) Any ideas about avoid this? Or is it not worth worrying about?
Reply }
#7
What do you guys think about A.I programed to counter certain actions in battle? For example a boss who hates magic and will attack anyone casting spells on it with a silencing skill?
(02-06-2014, 01:11 AM)MechanicalPen Wrote: Right how I just have the AI run all options, and choose the one that is most effective (based on damage + states applied - states removed). The problem with this is it might make the AI "too good", and allow it to avoid things it shouldn't know about (It's not fun if you equip a Null Poison and then none of the enemies use Poison anymore.) Any ideas about avoid this? Or is it not worth worrying about?
Perhaps you'd want to avoid developing A.I so advanced that becomes invincible. I mean, it's good for bosses and other major enemies but not so much for random encounters. Unless you're planning to give players a very hard time, that's it.
Reply }
#8
Just add in a random factor (2 potential paths - one time it will run the AI normal function and the other it will pick randomly). Harder enemies could run the script more often while weak enemies or "crazed" enemies would almost never run it.
Reply }
#9
Something to consider is whether the AI can, or cannot use items- If they're able to use items, how you'll balance them is A LOT different. You might want to make them a little weaker, or less aggressive in that case.

Ideally, the AI should be configurable based upon presets- so that combat in Easy, Normal, and Hard presets are more than base-stats. However, you'll end up doing a lot of combat testing, and item testing, especially as the more complex your model is, the greater chance of it breaking down- Radiant AI in Oblivion and Skyrim are GREATLY toned down.
[Image: TohsakaDono.png]
Reply }
#10
I don't like the idea of picking tactics randomly. Imagine if you were playing chess and half the time your opponent made master-level moves, half the time he made a nonsensical one. No one would mistake that opponent for a novice level player. Random choices just do not encourage good play.

Instead, what I think I'll do is add discoverablity to my AI. After all, it is exactly what RPG players do when they start a battle with an unfamiliar enemy. They try to assess the enemy based on clues the game have given them (Is this a boss or a random encounter? That monster has a flaming mane, could it be weak to water spells?)

Weaker AI can then start off making less assumptions about the players team, and stronger ones can make more (which can lead to an interesting case of the enemy mispredicting the player and giving them an edge).

The best AI can start with all actor stats, resistances, and probable skills predicted. It would not know about stat modifications due to items, or any auto-states applied to the actors. The worst AI would start with the actor's base health predicted (or even nothing!) and would have to discover the rest during battle.

Discovery is pretty simple; just compare the expected result of an attack to the real result. The comparison tells the AI whether a skill was more or less effective than expected, and can be used to modify the 'score' of the skill in the AI's selection routine. This allows a monster to use a Poison skill, notice the entire party was immune, and not try it again the rest of the battle.
Reply }


Possibly Related Threads…
Thread Author Replies Views Last Post
   State resistance based on number of turns or effect magnitude instead of chance DoubleX 1 3,572 07-24-2020, 05:05 AM
Last Post: DerVVulfman
   skill in RPGs unwashedmendicant 5 8,520 06-04-2017, 08:07 AM
Last Post: MetalRenard
   Multiplayer Turned Based Battles? thephantom 4 6,940 04-22-2015, 05:49 AM
Last Post: thephantom
  RM-Based Windowskin Generator Project PK8 4 9,891 05-09-2012, 05:17 PM
Last Post: PK8



Users browsing this thread: 1 Guest(s)