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

Gen 8 random battle results in no available moves #20

Closed
jzyrobert opened this issue Mar 5, 2020 · 7 comments · Fixed by #41
Closed

Gen 8 random battle results in no available moves #20

jzyrobert opened this issue Mar 5, 2020 · 7 comments · Fixed by #41
Assignees
Labels
bug Something isn't working enhancement New feature or request

Comments

@jzyrobert
Copy link

  1. Run the performance showdown fork
  2. Copy the random player tutorial but replace "gen7randombattle" with "gen8randombattle"
  3. Run it, and it hangs until manually quit.

I've added print messages to the "choose_move", and an example returned object is:
{'_battle_tag': 'battle-gen8randombattle-90', '_opponent_username': 'Player 1', '_player_role': 'p2', '_player_username': 'Player 2', '_players': [{'username': 'Player 1', 'player': 'p1', 'avatar': '2', 'rating': ''}, {'username': 'Player 2', 'player': 'p2', 'avatar': '1', 'rating': ''}], 'logger': <Logger Player 2 (WARNING)>, '_available_moves': [], '_available_switches': [], '_can_mega_evolve': False, '_can_z_move': False, '_force_switch': False, '_in_team_preview': False, '_maybe_trapped': False, '_trapped': False, '_force_swap': False, '_wait': False, '_finished': False, '_rqid': 3, '_rules': ['Species Clause: Limit one of each Pokémon', 'HP Percentage Mod: HP is shown in percentages', 'Sleep Clause Mod: Limit one foe put to sleep'], '_turn': 1, '_won': None, '_weather': None, '_fields': set(), '_side_conditions': set(), '_opponent_side_conditions': set(), '_team': {'p2: Octillery': Octillery (pokemon object) , 'p2: Manectric': Manectric (pokemon object) }, '_opponent_team': {'p1: Glaceon': Glaceon (pokemon object) }}

As you can see available_moves, available_switches are both empty.

I have also attempted to set log_level="DEBUG" for one player, and the output is debug.txt

I will attempt to debug this, but do you have any idea where this might be going wrong (maybe in the message parsing?)

@hsahovic
Copy link
Owner

hsahovic commented Mar 5, 2020

Hi Robert,

Thanks for bringing that up. I will try to reproduce your issue this evening; I'll keep you posted. From the looks of it, it might be a gen8-related issue.

@hsahovic hsahovic self-assigned this Mar 5, 2020
@hsahovic hsahovic added the bug Something isn't working label Mar 5, 2020
@hsahovic
Copy link
Owner

hsahovic commented Mar 5, 2020

The problem comes from gen8 mechanics / specifics. Right now, the project is not compatible with gen 8. However, gen8 compatibility is part of the roadmap.
It is planned as the next step after implementing an open ai gym wrapper, which is currently being built. If gen8 support is a priority for your project, feel free to reach out - it might be prioritized.

@jzyrobert
Copy link
Author

@hsahovic I'm happy to help out if required.
Do you know which part isn't compatible? I can look into it and submit a PR

@hsahovic
Copy link
Owner

hsahovic commented Mar 6, 2020

Sure, that'd be awesome!

There are two main things to do:

  • Handling new mechanics, including dynamax / gigantamax. This mainly imply work on the Battle class (parsing and allowing interactions with these mechanics through the API), Pokemon class (new attributes), but also on the Player class (mainly modifying the choose random move method for now). I think that the code to do that will be similar to what is implemented for mega-evolutions.
  • Handling new moves / pokemons. This means updating the datasets we are using. Updating pokedex.json is straightforward as it is directly extracted from Pokemon. Updating moves is a bit more tricky; I have a regex somewhere that was used in the process - I'll try to find it and post it here.

For a more precise list:

  • Things to update:
    • src/data/pokedex.json
    • src/data/moves.json
    • src/environment/Battle.battle_parse_message
    • src/environment/Battle.battle_parse_request
    • src/player/Player.choose_random_move
  • Things to add:
    • src/environment/Battle.can_dynamax
    • src/environment/Pokemon._dynamax
    • src/environment/Pokemon._dynamax
    • src/environment/Pokemon._gigantamax
  • Things to add if necessary:
    • src/environment/Battle.can_gigantamax
    • src/environment/Pokemon._gigantamax
    • src/environment/Pokemon.is_dynamaxed
    • src/environment/Pokemon.is_gigantamaxed

I am available to discuss things more in-depth / answer questions if you want - let me know if that would be helpful.

@jzyrobert
Copy link
Author

So after some testing:

  • There is only dynamax in random battles, no gigantamax (In other tiers, you can directly add gigantamaxed pokemon to your team I believe, and then dynamaxing acts like gigantamaxing)
  • I have hit this upstream issue so I'll try to fix that first, otherwise it's a bit of a hassle having to deal with index based moves rather than just being able to select the name
  • The request message does not return additional statistics for dynamax moves, so would have to query it from the own dictionary or add it to upstream.

Otherwise, the logic seems reasonable to deal with:

  • If a pokemon can dynamax, add dynamaxed moves as well as regular moves
  • If the pokemon is already dynamaxed, only present dynamaxed moves
  • When the pokemon un-dynamaxes, go back to regular moves

I'll keep working on this in my spare time, have exams soon so not for the next 2 weeks.

@szymonWojdat
Copy link
Contributor

Hi, the upstream issue that you mentioned has been fixed here. I still don't understand how does it select a max move not based off of the original move/index as you can have multiple "base" moves resulting in the same max move, eg. Trick Room and Protect turning into Max Guard. While it doesn't seem to matter that much, the difference is that max moves and base moves share PP, so it's often better to select the one with higher PP if the effect is the same for both moves.

Either way, I'll start looking into gen 8 support as well in the following days. I'll open a PR once I get something done.

@szymonWojdat szymonWojdat mentioned this issue Mar 25, 2020
11 tasks
@hsahovic hsahovic added the enhancement New feature or request label May 1, 2020
This was linked to pull requests May 2, 2020
@hsahovic hsahovic added this to In progress in Poke-env - general May 7, 2020
@hsahovic
Copy link
Owner

hsahovic commented May 8, 2020

This issue should be fixed by version 0.3.0, which includes support for gen 8 single formats :)

@hsahovic hsahovic closed this as completed May 8, 2020
Poke-env - general automation moved this from In progress to Done May 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
Development

Successfully merging a pull request may close this issue.

3 participants