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

Observations & ObservedPokemon #544

Closed caymansimpson closed 6 months ago

caymansimpson commented 6 months ago
  1. Fixed bug in Issue #541 and added a unit test to catch it
  2. Added an observation class that stores observable information as the battle goes on.

On Observation class design, it catches all temporal effects that allow us to recreate a Public Belief State (all observable information) at the time. This includes:

  1. All Showdown event strings
  2. Active Pokemon (on both sides of the field)
  3. Field effects
  4. Weather
  5. Side Conditions (on both sides of the field)
  6. Opponent's Team (important for moves like Last Respects and guessing what's in back for VGC)

With this information, you can recreate battle states for an agent to learn from, or feed into a model. Right now, there is no inference or processing on top of the raw data stored in the Observations class

codecov[bot] commented 6 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 84.03%. Comparing base (f458350) to head (547dbdb). Report is 36 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #544 +/- ## ========================================== + Coverage 83.38% 84.03% +0.65% ========================================== Files 39 42 +3 Lines 3918 4116 +198 ========================================== + Hits 3267 3459 +192 - Misses 651 657 +6 ```
caymansimpson commented 6 months ago

Actually, please don't accept quite yet! I realize that it's probably important for the AI to record the events in the last turn that leads to victory, which it doesn't right now. This is not necessary for decision-time planning, but may be helpful information for AI who learn from a game after it's played

caymansimpson commented 6 months ago

This PR ballooned and now contains many things 😅:

  1. Adding new Observation class that tracks the states of the Battle each turn. Each Observation class holds the state at the beginning of the turn and the events observed in that turn that leads to the next state
  2. Addition ObservedPokemon which can be used by AIs to track Pokemon information (and what Observation class uses)
  3. Convert save_replays functionality to use Observations
  4. Adding tera_type suppport for Pokemon
  5. A bug fix for TargetTypes to support Dynamax
  6. Added test for the details argument for Pokemon instantiation
  7. Unit tests for all the above
hsahovic commented 6 months ago

Thanks a lot @caymansimpson !