Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError: 'mewtwomegax' #3

Open
fwqefwqef opened this issue Apr 22, 2019 · 5 comments
Open

KeyError: 'mewtwomegax' #3

fwqefwqef opened this issue Apr 22, 2019 · 5 comments
Labels
bug Something isn't working

Comments

@fwqefwqef
Copy link

fwqefwqef commented Apr 22, 2019

The bot crashes during the game if the bot uses a team with 2 or more of the same pokemon, specifically when it brings out said pokemon. Obviously, this is not a problem in metagames like OU where there is a species clause, but it is a problem for other metas like Balanced Hackmons where there is no species restriction. Sadly, I do not have much experience with python so I am having trouble fixing the issue..
Replays:
me vs the bot with 6 Mega-Mewtwo-X:
https://replay.pokemonshowdown.com/gen7balancedhackmons-897012029
error: (sorry for the Won currency signs, it is supposed to be \ but Korean Language)
keyerror mmx

me vs the bot with 2 Mega-Mewtwo-X: https://replay.pokemonshowdown.com/gen7balancedhackmons-897009410
(error is identical: everything seemed to be running fine until the Keyerror made the bot crash)

me vs the bot with no duplicate pokemon (Replaced Mega-Mewtwo-X with Mega-Mewtwo-Y):
https://replay.pokemonshowdown.com/gen7balancedhackmons-896857312
As you can see, the bot does not crash and battles until the end as expected.

@pmariglia
Copy link
Owner

pmariglia commented Apr 23, 2019

Hey, thanks for bringing this up.

I actually had this come up during development - I was just mostly testing the other metagames and ignored it (bad choice).

This happens because of a poor design choice I made early on. Each side has an attribute called reserve which is a Python dictionary. The keys for this dictionary are the Pokemon names and, as you can imagine, this does not allow for Pokemon with duplicate names to exist. The KeyError itself is a by-product that occurs when trying to find the transposition for switching twice in a row.

I will fix this - I'll just need to investigate the best way to go about refactoring the representation of the reserve pokemon.

@pmariglia pmariglia added the bug Something isn't working label Apr 23, 2019
@fwqefwqef
Copy link
Author

Hello, is this bug fixed yet? I made my own version way back to address this issue but it's not updated for gen8 so I was wondering if I needed to make changes again if I install the latest version.

@fwqefwqef
Copy link
Author

image
I guess not? ahaha

@pmariglia
Copy link
Owner

Ahh sorry about that, I started to look into this and realized it was far more work than I had originally thought. There's a lot of code in the engine built around the assumption that there can only be one of each Pokmon on each team.

I still have this on a to-do list of mine, it has just dropped in priority and I'm not sure when it will (if ever) be addressed.

@ghost
Copy link

ghost commented Jan 22, 2021

can't you give the pokemon ids? like example (megamewtwo0, megamewtwo1, rotom0, regigas0, suntfisk0, mantine0). When needed it can remove the id and use it so it will avoid it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants