hsahovic / poke-env

A python interface for training Reinforcement Learning bots to battle on pokemon showdown
https://poke-env.readthedocs.io/
MIT License
297 stars 103 forks source link

A whole bunch of useful improvements #569

Open cameronangliss opened 4 months ago

cameronangliss commented 4 months ago

This PR is a bag of miscellaneous improvements, including:

  1. A new Player method called battle_against_multi which allows you to play one Player instance against a list of Player instances without having to play everyone against everyone as is done in cross_evaluate. Also, cross_evaluate is simplified by using battle_against_multi internally.
  2. Some methods of Player are made static that don't need the self value, allowing users of poke-env to use those methods in their own static methods.
  3. accept_open_team_sheets is possible to turn on for OpenAIGymEnv instances as well as Player instances now.
  4. The team being used by a Player instance is now re-rolled at the beginning of every game played if a TeamBuilder is specified.
  5. There is no longer a timeout for connecting the websocket in the Showdown client.
  6. A small bug in the name of the effect TYPECHANGE was fixed.
  7. A bug in the choose_move method of SimpleHeuristicsPlayer was fixed where a decision wouldn't be made if the active pokemon on either side is None.
codecov[bot] commented 4 months ago

Codecov Report

Attention: Patch coverage is 90.90909% with 3 lines in your changes missing coverage. Please review.

Project coverage is 85.48%. Comparing base (f458350) to head (6ec5ab0). Report is 70 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #569 +/- ## ========================================== + Coverage 83.38% 85.48% +2.10% ========================================== Files 39 42 +3 Lines 3918 4314 +396 ========================================== + Hits 3267 3688 +421 + Misses 651 626 -25 ```
cameronangliss commented 4 months ago

@hsahovic this is ready to go whenever you're ready to take it!

cameronangliss commented 4 months ago

Just as a note, I could be doing reset_battles on self and opponent in the _battle_against method, and that's probably the thing that makes most sense given that the function now returns the win and lose rates, but I didn't want to make a compatibility issue with the previous functionality. @hsahovic let me know if you care about compatibility with this method or not, and if not I can put reset_battles in there. Currently it's in _battle_against_multi.

cameronangliss commented 3 months ago

After using this diff myself for a little while, I decided that it would be better to just to reset_battles in the battle_against method. I just put that change in.

hsahovic commented 3 months ago

I agree that the current way results are handled by player objects can be improved, but i don't think starting battles should erase the previous results. These two actions should be covered by different methods in the API. I'm open to a proposal for a better structure around it, but i'm not sure this is it. Let's chat on discord? Your PR seems to contain other changes - do you want to open separate PRs for them?

cameronangliss commented 1 month ago

@hsahovic sorry, I've been MIA for a little while, but I've cleaned this PR up and it's ready for review :)