[Playerbots] Optimisations based on Claude suggestions#114
[Playerbots] Optimisations based on Claude suggestions#114
Conversation
There was a problem hiding this comment.
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
Enginehot 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(); |
There was a problem hiding this comment.
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).
| const Event& event = basket->getEvent(); | |
| Event event = basket->getEvent(); |
|
|
||
| // NOTE: queue.Pop() deletes basket | ||
| ActionNode* actionNode = queue.Pop(); | ||
| const string& actionName = actionNode->getName(); |
There was a problem hiding this comment.
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).
| const string& actionName = actionNode->getName(); | |
| const string actionName = actionNode->getName(); |
|
|
||
| ### Main Documentation | ||
|
|
||
| 1. **PLAYERBOT_OPTIMIZATION_FINAL_REPORT.md** (You are here) |
There was a problem hiding this comment.
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.
| 1. **PLAYERBOT_OPTIMIZATION_FINAL_REPORT.md** (You are here) | |
| 1. **PLAYERBOT_OPTIMIZATION_FINAL_REPORT.md** (EXECUTIVE SUMMARY REPORT) |
| } | ||
| else if (action->isUseful()) | ||
| { | ||
| // Apply multipliers to relevance - cache const reference |
There was a problem hiding this comment.
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.
| // Apply multipliers to relevance - cache const reference | |
| // Apply multipliers to relevance |
|
✅ Build Mangos ONE Server 22.03.122 completed (commit 7bc56e3523 by @billy1arm) |
This change is