Skip to content

Conversation

@cameronangliss
Copy link
Contributor

@cameronangliss cameronangliss commented Jan 2, 2026

Improved move tracking guided by strict integration tests, which now also validate the tracked battle state against the "active" section of the request message we receive. I also remove the dead code of EmptyMove, which is completely unused throughout poke-env.

@cameronangliss cameronangliss changed the title Track moves Fix move tracking Jan 2, 2026
@codecov
Copy link

codecov bot commented Jan 2, 2026

Codecov Report

❌ Patch coverage is 57.14286% with 93 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.88%. Comparing base (f458350) to head (1b9d418).
⚠️ Report is 241 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #816      +/-   ##
==========================================
- Coverage   83.38%   82.88%   -0.50%     
==========================================
  Files          39       47       +8     
  Lines        3918     5691    +1773     
==========================================
+ Hits         3267     4717    +1450     
- Misses        651      974     +323     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cameronangliss cameronangliss marked this pull request as ready for review January 5, 2026 21:31
Copy link
Owner

@hsahovic hsahovic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this PR! I left a couple of questions / comment - I'll merge when they are resolved.

"[from] lockedmove",
"[from] Pursuit",
"[from]lockedmove",
"[from] Sky Attack",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is sky attack still handled?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See here for what I yielded from my investigation: ada8c73. Basically, that message only seems to appear in random battles in early gens, so I added those to the strict integration tests and passed through them a few times to weed out existing early-gen bugs.

if self.active_pokemon is not None:
if (
strict_battle_tracking
and self.gen not in [7, 8]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

out of curiosity - why only these gens?

Copy link
Contributor Author

@cameronangliss cameronangliss Jan 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made the give-up for move consistency checking more specific here: 7fd69fa. The reason why we need to do this is because the mapping from moves to Z-moves or Dynamax moves is not invertible (2 distinct moves may have the same name for their z-move or dynamax move). Thus, it is impossible to track pp changes in those circumstances, so I have the code just not check that in gen 7 and 8, but only for pp consistency checking now.

self._available_switches.append(pokemon)

def _pressure_on(self, pokemon: str, move: str, target_str: Optional[str]) -> bool:
if self.gen == 7:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made the if-statement more specific and added an explaining comment: 4318f77

if pressure:
self.current_pp -= 2
else:
self.current_pp -= 1
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we bound this at 0?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

]
if not matches:
continue
move = matches[0]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we assert only one match?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants