Skip to content

Variant rpg info#84

Closed
kadeshar wants to merge 8 commits intokadeshar:masterfrom
Celandriel:variantRpgInfo
Closed

Variant rpg info#84
kadeshar wants to merge 8 commits intokadeshar:masterfrom
Celandriel:variantRpgInfo

Conversation

@kadeshar
Copy link
Owner

@kadeshar kadeshar commented Feb 3, 2026

Pull Request

Describe what this change does and why it is needed...


Design Philosophy

We prioritize stability, performance, and predictability over behavioral realism.
Complex player-mimicking logic is intentionally limited due to its negative impact on scalability, maintainability, and
long-term robustness.

Excessive processing overhead can lead to server hiccups, increased CPU usage, and degraded performance for all
participants. Because every action and
decision tree is executed per bot and per trigger, even small increases in logic complexity can scale poorly and
negatively affect both players and
world (random) bots. Bots are not expected to behave perfectly, and perfect simulation of human decision-making is not a
project goal. Increased behavioral
realism often introduces disproportionate cost, reduced predictability, and significantly higher maintenance overhead.

Every additional branch of logic increases long-term responsibility. All decision paths must be tested, validated, and
maintained continuously as the system evolves.
If advanced or AI-intensive behavior is introduced, the default configuration must remain the lightweight decision
model
. More complex behavior should only be
available as an explicit opt-in option, clearly documented as having a measurable performance cost.

Principles:

  • Stability before intelligence
    A stable system is always preferred over a smarter one.

  • Performance is a shared resource
    Any increase in bot cost affects all players and all bots.

  • Simple logic scales better than smart logic
    Predictable behavior under load is more valuable than perfect decisions.

  • Complexity must justify itself
    If a feature cannot clearly explain its cost, it should not exist.

  • Defaults must be cheap
    Expensive behavior must always be optional and clearly communicated.

  • Bots should look reasonable, not perfect
    The goal is believable behavior, not human simulation.

Before submitting, confirm that this change aligns with those principles.


Feature Evaluation

Please answer the following:

  • Describe the minimum logic required to achieve the intended behavior?
  • Describe the cheapest implementation that produces an acceptable result?
  • Describe the runtime cost when this logic executes across many bots?

How to Test the Changes

  • Step-by-step instructions to test the change
  • Any required setup (e.g. multiple players, bots, specific configuration)
  • Expected behavior and how to verify it

Complexity & Impact

  • Does this change add new decision branches?

    • No
    • Yes (explain below)
  • Does this change increase per-bot or per-tick processing?

    • No
    • Yes (describe and justify impact)
  • Could this logic scale poorly under load?

    • No
    • Yes (explain why)

Defaults & Configuration

  • Does this change modify default bot behavior?
    • No
    • Yes (explain why)

If this introduces more advanced or AI-heavy logic:

  • Lightweight mode remains the default
  • More complex behavior is optional and thereby configurable

AI Assistance

  • Was AI assistance (e.g. ChatGPT or similar tools) used while working on this change?
    • No
    • Yes (explain below)

If yes, please specify:

  • AI tool or model used (e.g. ChatGPT, GPT-4, Claude, etc.)
  • Purpose of usage (e.g. brainstorming, refactoring, documentation, code generation)
  • Which parts of the change were influenced or generated
  • Whether the result was manually reviewed and adapted

AI assistance is allowed, but all submitted code must be fully understood, reviewed, and owned by the contributor.
Any AI-influenced changes must be verified against existing CORE and PB logic. We expect contributors to be honest
about what they do and do not understand.


Final Checklist

  • Stability is not compromised
  • Performance impact is understood, tested, and acceptable
  • Added logic complexity is justified and explained
  • Documentation updated if needed

Notes for Reviewers

Anything that significantly improves realism at the cost of stability or performance should be carefully discussed
before merging.

Copilot AI review requested due to automatic review settings February 3, 2026 20:25
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 refactors the RPG status tracking system from using a C-style union to a modern C++ std::variant. The refactoring improves type safety by replacing direct union member access with variant-based access patterns using std::get and std::get_if.

Changes:

  • Replaced union-based storage with std::variant<Idle, GoGrind, GoCamp, WanderNpc, WanderRandom, DoQuest, Rest, TravelFlight> for RPG state data
  • Added GetStatus() method to map variant types to enum values
  • Updated all RPG info access patterns to use std::get (in switch cases) and std::get_if (for safe access with null checks)
  • Reorganized NewRpgStatus enum to place RPG_IDLE at index 0 (was previously at index 7) and removed redundant RPG_STATUS_START
  • Removed RPG_INFO macro in favor of direct variant access

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/PlayerbotAIConfig.h Reorganized NewRpgStatus enum with RPG_IDLE as the initial status (0), removed RPG_STATUS_START
src/Ai/World/Rpg/NewRpgInfo.h Replaced union with std::variant, added GetStatus() method, removed RPG_INFO macro
src/Ai/World/Rpg/NewRpgInfo.cpp Implemented GetStatus() using std::visit, refactored ToString() to use variant patterns, simplified Change* methods
src/Ai/World/Rpg/Action/NewRpgAction.h Updated method signatures to pass variant data by reference
src/Ai/World/Rpg/Action/NewRpgAction.cpp Updated all variant access to use std::get in switch statements and std::get_if for safe nullable access
src/Ai/World/Rpg/Trigger/NewRpgTrigger.cpp Updated to use GetStatus() method instead of direct status field access
src/Bot/RandomPlayerbotMgr.cpp Updated to use GetStatus() method for statistics tracking
src/Ai/Base/Value/GrindTargetValue.cpp Updated to use GetStatus() method for status checking

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

Comment on lines +75 to +85
using RpgData = std::variant<
Idle,
GoGrind,
GoCamp,
WanderNpc,
WanderRandom,
DoQuest,
Rest,
TravelFlight
>;
RpgData data;
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

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

The code uses std::variant at line 75 but the header does not appear to include . While this may work if is included indirectly through one of the other headers, it's a best practice to explicitly include all headers for types used directly in a file. Consider adding '#include ' to make the dependency explicit and avoid potential compilation issues in the future.

Copilot uses AI. Check for mistakes.
struct NewRpgInfo
{
NewRpgInfo() {}
NewRpgInfo() : data(Idle{}) {}
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

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

The PR description template was not filled in. The PR should include:

  • A description of what this change does and why it's needed
  • How to test the changes
  • Answers to the complexity and impact questions
  • Whether AI assistance was used
  • Whether the final checklist items have been verified

While the code changes appear to be a refactoring from union to std::variant, this information should be documented in the PR description for reviewers and future reference.

Copilot uses AI. Check for mistakes.
Comment on lines +79 to +83
WanderNpc,
WanderRandom,
DoQuest,
Rest,
TravelFlight
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

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

The order of types in the RpgData variant doesn't match the order of the corresponding enum values in NewRpgStatus. While this doesn't cause functional issues due to the GetStatus() method using std::is_same_v for type checking, it creates unnecessary maintenance burden and could confuse future developers. Consider reordering the variant types to match the enum order (Idle, GoGrind, GoCamp, WanderRandom, WanderNpc, DoQuest, TravelFlight, Rest) for better code clarity and consistency.

Suggested change
WanderNpc,
WanderRandom,
DoQuest,
Rest,
TravelFlight
WanderRandom,
WanderNpc,
DoQuest,
TravelFlight,
Rest

Copilot uses AI. Check for mistakes.
flight.fromFlightMaster = fromFlightMaster;
flight.fromNode = fromNode;
flight.toNode = toNode;
flight.inFlight = false;
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

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

The explicit initialization of inFlight to false is redundant since the TravelFlight struct already initializes inFlight to false by default (see line 55 in NewRpgInfo.h). This line can be removed for cleaner code.

Suggested change
flight.inFlight = false;

Copilot uses AI. Check for mistakes.
if (!dataPtr)
return false;

auto& data = *dataPtr;
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

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

Incorrect indentation: this line should be aligned with the previous lines (not indented with extra spaces). It should be at the same indentation level as line 432.

Suggested change
auto& data = *dataPtr;
auto& data = *dataPtr;

Copilot uses AI. Check for mistakes.
Copilot AI review requested due to automatic review settings February 4, 2026 23:55
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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@kadeshar kadeshar closed this Feb 8, 2026
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.

3 participants