Skip to content

Remove redundant availability checks#676

Open
MohamedMostafa259 wants to merge 2 commits into
huggingface:mainfrom
MohamedMostafa259:patch-1
Open

Remove redundant availability checks#676
MohamedMostafa259 wants to merge 2 commits into
huggingface:mainfrom
MohamedMostafa259:patch-1

Conversation

@MohamedMostafa259
Copy link
Copy Markdown

This PR cleans up redundant logical checks in the LLMAgentBase action selection

Changes Made:

  • Removed redundant list lookups: Removed and chosen_move in battle.available_moves and and chosen_switch in battle.available_switches inside choose_move(). The helper methods _find_move_by_name and _find_pokemon_by_name already exclusively return objects from these lists, making the secondary checks unnecessary.

Copilot AI review requested due to automatic review settings April 22, 2026 10:49
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the tutorial excerpt for LLMAgentBase.choose_move() to remove redundant “availability” membership checks that are already guaranteed by _find_move_by_name / _find_pokemon_by_name, keeping the example logic simpler and more consistent with the helper methods.

Changes:

  • Removed and chosen_move in battle.available_moves from the choose_move decision branch in the English tutorial.
  • Removed and chosen_switch in battle.available_switches from the choose_switch decision branch in the English tutorial.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 164 to 170
move_name = args.get("move_name")
if move_name:
chosen_move = self._find_move_by_name(battle, move_name)
if chosen_move and chosen_move in battle.available_moves:
if chosen_move:
action_taken = True
chat_msg = f"AI Decision: Using move '{chosen_move.id}'."
print(chat_msg)
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

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

The redundant availability checks were removed in the English unit, but the same code excerpt in other locales (e.g., units/es, units/fr, units/zh-CN) still includes chosen_move and chosen_move in battle.available_moves / chosen_switch and chosen_switch in battle.available_switches. If these units are meant to stay in sync, update the translated building_your_pokemon_agent.mdx files to match this logic to avoid inconsistent guidance.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Ok, I've edited the other locales that contain the bonus-unit3 directory: es, fr, zh-CN

@MohamedMostafa259
Copy link
Copy Markdown
Author

Ok, I've edited the other locales that contain the bonus-unit3 directory: es, fr, zh-CN

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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