Home Creators Posts Import Register Favorites Logout

Content

...and how it was solved in under half an hour.
mostly.

ok so back when i was asking for questions to take up time during story stuff HachiKenHachirio asked this: 

I would like to know how the AI works. Also, very curious how you'll trick out the AI to deal with field effects.

so i'll go over this very briefly and explain how it works with the changes we've made.

first, the looks at the battlers and learns some things about them like what type they are, how much health they have, what moves they have (for their own) and what moves the player has used (if it's a high skill trainer) and also how effective those moves were against their current pokemon

then it's going to look at their own moves one by one and figure out about how much damage each one would do. this is done by a rough-damage method that is basically a theoretical recreation of the actual damage method used in calculation. it thinks about all of those things (including field effect damage, but only if it's the best skill level) and then converts it to value of how much % health it will do to an enemy and keeps that value as a baseline for how good the move is. the second biggest problem with E16 AI is that this theoretical method was incomplete and did not account for many things. it's been completed now.

then for moves that do not do damage it's going to pull an arbitrary value that we've assigned to it based on the utility of the move. for moves like growl, helping hand, etc, it's ~10. for moves like spore, recover, it's more like 50-70. this becomes the base value instead.

so now it has a basic understanding of how good its moves are. next it'll check each of their function codes and score them based on other things. function codes are the things that make moves do Things, such as there's one for burning, one for flinching, one for burning and flinching both, one for swords dance, one for tail glow, one for rototiller, one for fucking quash why does this garbage move exist get out of my game tbh
anyway.
each function code has specific AI that tells it when to aim for that effect. it checks the codes for its 4 moves and then tallies up how good an idea it is as a new score. it modifies that based on some other things like accuracy and if this move will kill a partner pokemon too. 

finally it thinks about switching. i've posted our shouldswitch and switchto methods here already but basically it's checking various things like the match up, expected incoming attack, stat conditions etc and tallying up a score comparable to the moves' score to decide if we need to get outta dodge. then depending on if the switch score is much higher than a move's score, it'll do so and decide who to switch to. 

...so that's it in sum.

so the biggest problem with move AI in E16? well, let's go back to the function code section. because that's what's left to do for 17. just that. the function code section, like the rough damage section, is incomplete in essentials base AI. it was never finished. i'll finish it next episode. i'll take a good bite out of it this time.
but that's not the reason E16 ai makes dumbass moves like preferring resisted thunderpunch over a STAB move.

that's the biggest problem-- the code that already exists from essentials for the function codes, is bad. i'll redo all of it but i fixed the bad part in one sweeping motion a couple days ago.

basically, we've got our baseline score as a % of remaining health, right? so that score is going to be in the like, 5-110 range, at most.
let's take our function code for paralysis, with the thunder punch example above.

the code is something like, for example  (im making this up),

if the opponent can be paralyzed, +10, and if we're slower than it and would be faster after it being paralyzed, + another 20 

...there's a lot more factors etc but that's the roughest state. 

okay so say our enemy pokemon has two moves, thunder punch which would do about 5% of the player's HP cuz it's resisted, and some neutral hitting move that would do around 30%. the AI should totally use the neutral hitting move because there's no counting on the 10% paralysis chance to go through. but the 5% will get +30 total from the function scoring meaning the score is 35 to 30 and the enemy will prefer thunderpunch. 

...that is an extreme example of what is happening. usually when opponents use a dumb move it's a move with a secondary effect like paralysis or flinch and the AI is greatly over-valuing the use of those secondary effects.

so how to fix this in under half an hour? multiplicative instead of additive scoring. notepad++ ctrl+f replace "score+=10" with "score*=1.1" for instance. instead of +30 our 5% thunder punch gets *1.3 which is like, 7. 7 vs 30 score? better use the 30.  meanwhile say our thunderpunch is 25% instead of 5. 25 * 1.3 = 33. turns out thunderpunch is better after all! this was quick to do for all currently-existing function codes. 

anyway that's still very rough and doesn't help with things that are Very Good like Nuzzle so all of it is still going to be done over this episode or next-- but this carries us over during E17 to improve the things we don't get to. 

and also i've been wanting to do this for ages. god damn. why was it not this way in the first place : |


Comments

Michael Hamann

Ame's Intelligence Changing Heuristics Alternating Neurological Gibberish Extermination Session

Hachilio Murray

Damn, your nickname for me is so much cooler than my own name >< Also, since utility is kind of a separate thing from damage calculations, you could apply this. You mentioned yourself how you set up a arbitrary values for moves like growl, spore, thunder wave, etc. So a move like nuzzle is like a weak attack + thunder wave. In this case utility makes sense to be addition. The fact thunder punch shouldn't be damage + paralyze is purely the chance factor. You could introduce the chance factor to reduce the addition term. In a way, multiplication seems too limiting, probably favoring a AI that just wants to deal max damage, only favoring moves with side effects until multiplication factors are very high. Consider volcarona "fiery dance" or "heat wave". The chance to hit doubles vs the chance to raise SpAtk. Most players would choose fiery dance in singles for the utility effect. In this reasoning it intuitively damage + utility*chance of utility. However, for doubles, the extra attacking power could prove more beneficial than the utility. Also, something you didn't mention is the effect of items and abilities on the function scoring? Does the scoring of utility depend on the match up? If my opponent is much stronger than I am, I would favor moves that make the opponent weaker. If my opponent is weaker than I am, I would favor utility to make me stronger.

Hachilio Murray

To use your example: Say Paralyze gets 50% bonus You have a move that does 5% and 10% chance to paralyze = 5+50*0.10 = 10 Move that does 25% and 30% chance to paralyze = 40%. The latter being much more favorable than any 30% attacking move without extra benefit The move nuzzle might do 5% damage, but the total score is 5+50*1.00 = 55%

Jáchym Toušek

E17 AI hype!! I'm really looking forward to the gym leader battles. They just might finally be as strong as the story would suggest.