• Do not use Discord to host any images you post, these links expire quickly! You can learn how to add images to your posts here.
  • Eevee Expo's webhost has been having technical issues since Nov. 20th and you might be unable to connect to our site. Staff are also facing issues connecting, so please send a DM to Cat on-site or through Discord directly for faster service!
Consistent non-random AI - Revised!

v20.1 Consistent non-random AI - Revised! 2.0.4

This resource pertains to version 20.1 of Pokémon Essentials.
Pokémon Essentials Version
v20.1 ➖
What if I tell you that current Essentials AI is actually at its core quite decent? I know some of you have been through too much grief to even humor the thought.
Its move effect scores account for most basic scenarios so if it could just reliably make use of those scores, it would do the job you want it to do most of the time.

And therein lies the problem.
For some reason even at the highest skill levels the AI is set to work with an RNG-based system so even if it had a higher chance to click the proper move, that chance is far from what you would want.

Through this plugin i have eliminated the random aspect of the AI decision making. When a move, or a pokemon switch is determined to be the best choice in the decision making process, it will choose that one, no questions asked.
A lot of sections of the AI have been massively reworked, and there has been a lot of code made from scratch. Here are the most notable changes:
  • Added a lot more move function specific code in AI Move EffectScores. AI should now have massively improved and consistent decision making for most moves.
  • Improved priority move related AI using Reborn's priority moves AI as a base
  • Reworked the process of selecting the proper damaging move. Most damaging moves whose power depends on other factors are now handled in pbGetMoveScoreDamage instead of pbGetMoveScoreFunctionCode and will be chosen based on their calcualted resulting damage rather than arbitary scoring.
  • Different logic for moves with imperfect accuracy that doesn't impact decision making so drastically,
  • Various factors that would affect the score of damaging moves had their score modifiers turned from additive to multiplicative for better accuracy.
  • A completely made from scratch AI on selecting the next pokemon to bring into battle that decides based on approximate incoming and outcoming damage calculation, speed comparison, and a lot of other factors. To achieve that a fake battler is created for every party member not yet into battle, and the one that gets the best outcome in a clash with the current opposing pokemon is chosen.
  • Reworked AI for usage of healing items in battle. Instead of arbitary scoring based on isolated factors and rng, it now basically uses logic similar to recovery moves for healing items, and similar to set-up moves for X items, with the proper damage and other calculations to assist in decision making.
  • New code for the purpose of calculating if a pokemon will survive another pokemon's moves after taking into account damage calculation, abilities, items, priority moves on the following turn, and other factors.
  • Code that helps AI access the biggest threat in doubles+, and prioritise targeting it.
  • Integration of the new elements from the Generation 9 Pack v2.0 for compatibility.
  • Emulation of "mind games" for sucker punch and wide guard.
More techical info:
Obviously when you make the AI calculate more and more factors for its decisions, eventually the processing time for the decision making grows long enough that it is felt by the player during battle, especially in doubles, where slower PCs had to wait quite some seconds every turn for the AI to finish deciding.
The main culprit of this was just how many times the AI had to go through the entirety of pbRoughDamage (a pretty lengthy method) for every single little thing. We are talking about countless iterations.
To solve this, the AI now calculates all possible damages between every pokemon in the battle once at the start of the turn, and saves them in a hash through the registerDamagesAI method. And so instead of recalculating it every time, it just grabs the appropriate calculation of x move vs y opponent from the hash.
Things that I hope to tackle in an unknown future:
-Improving decision making in doubles. Naturally the more factors are in the battle at the same time, the more complex the AI processing becomes. I am very satisfied with singles right now, but doubles definitely has space for improvement.
-Mega Evolution related AI, especially calculation of damages after mega evolution for a pokemon that isn't mega evolved yet. More ambitious goal: choose to not mega evolve if it's more beneficial to stay in current form, or to hold the mega evolution for later.

There is always space for improvement. through feedback i can try make tweaks where needed in the future to make this AI play better (see: try making some gimmick strategies to work better).

================
This is a very early iteration of this plugin for games that use Essentials v18. It doesn't have all the improvements I added in v2.0 and I don't know when i'll get around to doing that, but it's still serviceable. Plugins weren't a thing back then so just make a new script page near the bottom of your scripts, and dump the contents of this file in there.
THIS IS FOR ESSENTIALS V18 ONLY
================
Credits
DemICE
Author
DemICE
Downloads
906
Views
3,860
First release
Last update

Ratings

4.67 star(s) 3 ratings

More resources from DemICE

Latest updates

  1. One important and one less important AI fix

    v2.0.4 Fixes AI using Fake Out after the first turn. Fixes AI not having a low enough score to...
  2. Update only useful for those NOT using the Generation 9 Pack

    I realized I was using certain methods in the AI that were only defined in the Generation 9...
  3. Fastest follow up hotfix update ever. Let's not make it a pattern...

    v2.0.2 Cleaned up remnant code from Ashen Frost that I had missed that was causing AI crashes...

Latest reviews

The script works really well. Among other things, I did a comparison battle between the standard AI and the new one and I can confirm that it plays much better. Especially in combination with the Improved Battle AI, which I also find very cool.

But there is certainly still room for improvement in many small things. To name one example: The AI chooses Counter as its best move, even if I don't attack with any physical attack for five turns in a row. However, this can also happen in Standard Essentials, so it's not a big deal.

In any case, thanks for this great script and I appreciate the work behind it.
Back
Top