jojobear13 / shinpokered

Mostly-vanilla hack of Pokémon Red/Blue focused on bugfixes and trainer ai
209 stars 42 forks source link

Adjust AI's unfair advantage during switches. #252

Closed DiabloStorm closed 12 months ago

DiabloStorm commented 1 year ago

A few things I suspect: The order of operations is completely wrong in this romhack (i.e. AI is able to choose their move AFTER you switch; this is not how the game has ever worked for the player, you claim AI switching is a new feature of this hack so maybe it's implemented wrong for AI, they should be forced to use whatever move they selected and apply it to the newly switched pokemon, this isn't what's happening) or the AI has been granted the ability to change move selection(i.e. AI selects move, you switch, they choose to use a different move instead of their original choice) OR the cpu knows a switch is going to happen and what is being switched into, or some combination of the 3.)

Originally posted by @DiabloStorm in https://github.com/jojobear13/shinpokered/issues/234#issuecomment-1370366498

Player switches: AI seemingly begins turn after the switch completes. They're able to choose super effective moves against the switching-in pokemon and certainly will if they have them.

AI switches: Player has little to no idea the AI has chosen to switch, the move the player previously selected fires against the newly switched-in pokemon, player does not get the same option the AI gets to choose a better move.

DiabloStorm commented 1 year ago

No idea how to add labels after the fact.

DiabloStorm commented 1 year ago

If this comes down to that "50% blind to player switching" it shouldn't.

It's an issue with the order of operations. The AI should be forced to select and stick with a move, not able to anticipate a switch at all because that switch by the player takes place AFTER the AI has selected their move. Then the player switches and the AI should be forced to fire the move they selected.

The fact that it doesn't happen this way leads me to the conclusions above.

I would also have to assume this issue doesn't appear in a pvp gamelink battle. Instead the AI is given an advantage here, either through error or otherwise.

jojobear13 commented 1 year ago

Allow me to clarify. The switching AI, being the decision-making scoring system on when/if/what to switch, is what is new.

The ability for the AI to switch at all is in the vanilla game. Specifically, jugglers switch 50% of the time, and Agatha randomly switches on rare occasions. It is also not well-implemented, with AI only being able to switch back and forth between their active pokemon and the next pokemon in their roster. Furthermore, the AI performs their switch after the player uses a move.

The vanilla battle engine is hard-coded so that the enemy makes move selections right after a player selects a move. These "selection" procedures have a lot of other things that they do (like checking for recharge or wrap status and what not), so they cannot be moved around without rewriting a large number of battle effects. The annoying part is that player switches and items are executed before the enemy selects a move. Player switching and item-use happens during the menu-selecting process, and then the enemy selects its move once the battle menu goes away. As a result, the enemy move selection occurs based on the instantaneous state right after the player executes his actions.

Try this for fun: In vanilla red/blue/yellow, use a move to put a status on one of Brock's pokemon. He will instantly use a Full Heal out of order and in perfect response to your actions. https://v.redd.it/ca3sagllpkk71

I might be able to make it so that the SwitchPlayerMon function is called after the enemy selects its move. But this will take a bit of doing. No guarantees.

DiabloStorm commented 1 year ago

the AI performs their switch after the player uses a move.

yup.

Try this for fun: In vanilla red/blue/yellow, use a move to put a status on one of Brock's pokemon. He will instantly use a Full Heal out of order and in perfect response to your actions.

yup. This and the Lance issue you mentioned probably should be reworked. Reason? Not fun. Make "fun" the reason if nothing else. In yellow ive had him use all 5? of his full heals on both of his pokemon(so...10?). That's ridiculous of course. And he loses anyway.

I might be able to make it so that the SwitchPlayerMon function is called after the enemy selects its move. But this will take a bit of doing. No guarantees.

better than nothing. anything to tone down the current predictive way the AI functions. (yes in this case maybe it's not a prediction issue, but from the player's perspective it can seem that way when the AI gets to do things in a different order than the player would be able to.)

jojobear13 commented 1 year ago

In the meantime, until a better solution can be discovered, commit 6620fccf0dc01a447713fd612ed7f9d657895e3b heavily nerfs the omniscience of AI layer 3 (type-matching evaluation for moves).

If the player has switched, each individual move the AI evaluates has a ~90% chance to skip having knowledge of the sent-out mon's typing. This change to Layer 3 will cause it to bias things towards STAB moves and moves that complement its own stats in the event that the player switches. Example: switching Venusaur into an opposing Starmie will cause the Starmie to not immediately punish with Ice Beam. Instead, it will more likely pick a decent attacking move at random with a preference for something like Surf.

AI Layer 1 change: If the player switches, and the AI is evaluating Dream Eater, ignore the player's sleep counter. Now you can potentially interrupt the sleep-->dream eater combo by switching.