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

Level Grind : Fix leader leveling when it doesn't have any damaging moves #499

Merged

Conversation

ThibaultLassiaz
Copy link
Contributor

@ThibaultLassiaz ThibaultLassiaz commented Nov 11, 2024

Description

Fixes for Level Grind Mode

This PR addresses two issues with leader leveling in level grind mode:

  1. Starting with Unusable Moves: The mode would previously start even if the leader’s only moves were banned or had zero power, which made leveling ineffective because it couldn't kill opponent.

  2. Incorrect Move Selection in get_strongest_move_against: Previously, banned moves were excluded from the move pool using continue, causing issues where a banned move might be selected if no other valid moves were available. For instance, if the first move was "False Swipe" (banned) and the other three moves were non-damaging, the bot would incorrectly default to using the banned move. Now, if all moves are either banned or non-damaging, an error is raised, preventing unintended behavior.

Here is a Pokémon example that was causing the issue

image
(btw yes you can level grind a lvl 100 Pokémon)

Changes

Added an assert of level grind when chosing leveling leader only
Raising an error on get_strongest_move_against when no damaging move are available

Notes

Checklist

  • Black Linter has been ran, using --line-length 120 argument
  • Wiki has been updated (if relevant)

@ThibaultLassiaz ThibaultLassiaz changed the title Fix level grind lead unusable moves Fix leader leveling on level grind mode when leader doesn't have any damaging move Nov 11, 2024
@ThibaultLassiaz ThibaultLassiaz changed the title Fix leader leveling on level grind mode when leader doesn't have any damaging move Level Grind : Fix leader leveling when it doesn't have any damaging moves Nov 11, 2024
strongest_move = move_strengths.index(max(move_strengths))
max_strength = max(move_strengths)
if max_strength <= 0:
raise BotModeError("No valid moves available! Check move setup or disable restrictions.")
Copy link
Collaborator

Choose a reason for hiding this comment

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

'valid moves' might be a bit of a confusing phrase to users who don't know what we're checking for.

Maybe say "{pokemon.species.name} does not know any damage-dealing moves, or they are forbidden to use by bot configuration" instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@@ -176,3 +176,17 @@ def assert_player_has_poke_balls() -> None:
else:
if get_item_bag().number_of_balls_except_master_ball == 0:
raise BotModeError("Out of Pokéballs! Better grab more before the next shiny slips away...")


def assert_leader_can_fight(pokemon: Pokemon) -> None:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Isn't that naming a bit inaccurate, if you have to pass the Pokémon-to-check yourself? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@ThibaultLassiaz ThibaultLassiaz force-pushed the fix-level-grind-lead-unusable-moves branch from b5df19d to df53b25 Compare November 18, 2024 18:21
@ThibaultLassiaz ThibaultLassiaz force-pushed the fix-level-grind-lead-unusable-moves branch from df53b25 to d96aea0 Compare November 18, 2024 18:22
@hanzi hanzi merged commit a5a8696 into 40Cakes:main Nov 18, 2024
1 check passed
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