Documenting a possible AI bug w/ Venomoth's Shift
ticalc-travis opened this issue · 3 comments
This is a cool project. I've always wondered how the algorithms in this game work, and now I've finally been able to start answering my questions. :-)
There are a few interesting bugs/glitches documented in the disassembly, but I believe I know of another that isn't currently mentioned. I have encountered occasions in duels against a computer opponent using Venomoth's Shift whereby, if a Mysterious Fossil or Clefairy are in play somewhere, the computer will illegally change Venomoth's type to, say, Fire, even if no Fire Pokémon exists in play. Meanwhile, the UI will still prohibit the player from performing the same antic.
In the UI code for validating the Shift color selected by the player, there's a call to GetPlayAreaCardColor. This call appears to explicitly check if the card in play is a trainer card and correctly assume a type of colorless if so. On the other hand, when the AI is choosing a color, it calls a separate routine to check if its proposed color is legal, and this code appears lacks the check for a trainer card.
Since trainer cards don't have the “color” byte in the data structure, I suspect that this missing check blindly reads some arbitrary byte, resulting in the AI using Shift to switch types to something that may not actually be in play as required by the card's rules.
I'm not an ASM guru, though, so maybe someone more knowledgeable of the code might want to double-check this. But if I am correct, then maybe it would be worth adding a comment in the code to document this programming error. I could make a PR for this.
I tried this out and saw the same bug you're describing. Heather's Venomoth (the Kaleidoscope Deck) used Shift and became lightning type despite me having only Goldeen and Mysterious Fossil in play and Heather having 0 bench Pokemon.
And your explanation seems correct to me.
A PR would be appreciated :)
This has been documented in #85, very cool finding!
Cool, that looks good.