Skip to content

[Playerbots] Optimisations based on Claude suggestions#114

Open
billy1arm wants to merge 1 commit intomasterfrom
Updated_Playerbots
Open

[Playerbots] Optimisations based on Claude suggestions#114
billy1arm wants to merge 1 commit intomasterfrom
Updated_Playerbots

Conversation

@billy1arm
Copy link
Member

@billy1arm billy1arm commented Feb 28, 2026

This change is Reviewable

Copilot AI review requested due to automatic review settings February 28, 2026 23:43
Copy link

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 Playerbot AI engine and related utilities with small performance-oriented refactors (loop modernizations, const-correctness, and reduced copies) and adds a large set of documentation files describing the optimization work.

Changes:

  • Refactors Engine hot paths (queue processing, reset/init loops) and adjusts some method signatures for const/reference passing.
  • Adds null-safety and clearer default handling in Player role detection helpers (IsRanged/IsTank/IsHeal).
  • Adds extensive markdown documentation/reporting for the optimization effort.

Reviewed changes

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

Show a summary per file
File Description
src/modules/Bots/playerbot/strategy/Engine.h Updates method signatures (MultiplyAndPush, CreateActionNode) for const/reference passing.
src/modules/Bots/playerbot/strategy/Engine.cpp Loop refactors and control-flow tweaks in DoNextAction, Reset, listeners; signature updates to match header.
src/modules/Bots/playerbot/PlayerbotAI.cpp Adds null checks and explicit default cases in role detection helpers.
src/modules/Bots/playerbot/AiFactory.cpp Minor loop/type cleanups in spec tab detection and some conditional merging.
PLAYERBOT_OPTIMIZATION_INDEX.md Adds an index/navigation page for the optimization documentation set.
PLAYERBOT_OPTIMIZATION_FINAL_REPORT.md Adds a final report describing changes, metrics, and deployment notes.
PLAYERBOT_OPTIMIZATION_COMPLETE.md Adds a comprehensive project summary across optimization phases.
EXECUTIVE_SUMMARY.md Adds an executive-facing summary of results and rollout guidance.
COMPREHENSIVE_PLAYERBOT_OPTIMIZATION.md Adds a technical deep-dive guide with rationale and examples.
CHANGELOG_DETAILED.md Adds a detailed changelog capturing phases and individual items.

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


float relevance = basket->getRelevance();
const bool skipPrerequisites = basket->isSkipPrerequisites();
const Event& event = basket->getEvent();
Copy link

Copilot AI Feb 28, 2026

Choose a reason for hiding this comment

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

basket->getEvent() returns Event by value (see ActionBasket::getEvent()), so binding it to const Event& here creates a reference to a temporary. It’s safe in this scope, but it’s subtle and doesn’t clearly communicate ownership/lifetime. Prefer storing by value (Event event = basket->getEvent();) or change getEvent() to return a const Event& (and ensure lifetime is valid).

Suggested change
const Event& event = basket->getEvent();
Event event = basket->getEvent();

Copilot uses AI. Check for mistakes.

// NOTE: queue.Pop() deletes basket
ActionNode* actionNode = queue.Pop();
const string& actionName = actionNode->getName();
Copy link

Copilot AI Feb 28, 2026

Choose a reason for hiding this comment

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

ActionNode::getName() returns string by value, so const string& actionName = actionNode->getName(); binds a reference to a temporary. This is easy to misread as a reference to internal storage and doesn’t avoid the return-value copy. Prefer const string actionName = actionNode->getName(); (or change getName() to return const string& if safe).

Suggested change
const string& actionName = actionNode->getName();
const string actionName = actionNode->getName();

Copilot uses AI. Check for mistakes.

### Main Documentation

1. **PLAYERBOT_OPTIMIZATION_FINAL_REPORT.md** (You are here)
Copy link

Copilot AI Feb 28, 2026

Choose a reason for hiding this comment

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

This index file labels PLAYERBOT_OPTIMIZATION_FINAL_REPORT.md as “(You are here)”, but the current document is the index itself. Consider updating this line to avoid confusing readers about which file they’re viewing.

Suggested change
1. **PLAYERBOT_OPTIMIZATION_FINAL_REPORT.md** (You are here)
1. **PLAYERBOT_OPTIMIZATION_FINAL_REPORT.md** (EXECUTIVE SUMMARY REPORT)

Copilot uses AI. Check for mistakes.
}
else if (action->isUseful())
{
// Apply multipliers to relevance - cache const reference
Copy link

Copilot AI Feb 28, 2026

Choose a reason for hiding this comment

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

The inline comment says “cache const reference”, but this loop doesn’t actually cache a const reference (it iterates pointers from multipliers). Consider rewording or removing the comment so it accurately reflects what the code is doing.

Suggested change
// Apply multipliers to relevance - cache const reference
// Apply multipliers to relevance

Copilot uses AI. Check for mistakes.
@AppVeyorBot
Copy link

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants