EasyRPG / Player

RPG Maker 2000/2003 and EasyRPG games interpreter
https://easyrpg.org/player/
GNU General Public License v3.0
1.01k stars 191 forks source link

Implement the RPG_RT Autobattle algorithm #1586

Closed fmatthew5876 closed 4 years ago

fmatthew5876 commented 5 years ago

Figure out and implement the RPG_RT auto battle algorithm.

Using it for the AutoBattle command is a bit controversial. Using it for an actor with AutoBattle flag set however is not. If a game dev created an actor with auto battle, the game experience probably demands that actor does more than just attack random enemies. There can also be some smarts from RPG_RT we can reuse event if we don't want to change the AutoBattle command to use skills.

I did some testing and one thing I saw. I had an actor with no skills set on autobattle. He would always attack the first enemy. This is better AI than attacking randomly, as at least he works on killing 1 at a time instead of randomly spreading the damage.

Also I noticed he would attack a different enemy only if his weapon would kill that enemy in a single hit. Adjusting the enemy HP would change which target he chose.

That's all I've got for now.

fmatthew5876 commented 5 years ago

@CherryDT

Any help with this one?

CherryDT commented 5 years ago

Hero AI:

How secondary scores are assigned:

Only valid targets are considered.

MP modifier:

Above, there is an "MP modifier" mentioned. The MP modifier is the value of 0.25 * (MP Cost / Max MP). The case of 0/0 is handled as 0.

Subtracting the MP modifier can never make the score become negative, it will become zero in that case.

How primary scores are assigned:

Auto-battle from the battle menu just works as if all characters had the auto-battle option set.

Monster AI

*: An action is invalid on a target if the target is dead (unless it's a skill that can revive), if it's a reviving skill and the target is alive, if it's a skill that would heal a status and the target doesn't have this status, or if it's a skill that would increase elemental resistance and the target's resistance for that element is already increased. If a skill has multiple effects, it is invalid if all of them fall into one of the invalidness definitions above. (For example, a skill that heals a status and heals HP would always be valid, even if the status is not inflicted. The HP heal is unconditionally valid regardless of actual HP, since it's not in the list of invalid things above.)

Ghabry commented 5 years ago

So this means the AI is not cheating?

CherryDT commented 5 years ago

No, it is, because this...

Score = Ratio (i.e. 0 to 1 - never >1!) of HP the attack would deduct from the target, compared to current HP

...uses information (an enemy's current HP) which would normally not be available to the player (at least not easily, only if the player knows the enemy's max HP and kept track of the damage dealt).

fmatthew5876 commented 5 years ago

When determining how much the effect of the attack would be.. Am I right to assume the autobattle algo ignores random variance?

CherryDT commented 5 years ago

Basic attacks don't have variance as far as I know, and for skills, the variance is part of the effect calculation.

So, that means that the "prediction" from the AI will become more inaccurate the higher the skill's variance is, because the result of the effect calculation during AI decision-marking and the one during actual execution of the action can be wildly different... (Which is good, otherwise it would be even more cheating. However, I agree that it would sort of make sense to then not apply the variance at all during decision-making.)