Add deterministic AdventureBot group formation manager
clang PCH / build (push) Waiting to run
GCC PCH / build (push) Canceled after 0s

This commit is contained in:
Nico committed 2026-11-01 01:20:37 +01:00
1 parent 856832e7bd
commit be049baacc
11 files changed
+386

No files matched your search

@@ -0,0 +1,58 @@
#!/usr/bin/env python3
from pathlib import Path
import subprocess
import tempfile
root = Path(__file__).resolve().parents[2]
source = (root / "src/server/game/World/AdventureGroupMgr.cpp").read_text()
# The integration-heavy manager remains native C++, but these assertions keep
# its safety boundaries visible when the surrounding group code is refactored.
for required in (
"ManagerWindow(plan.Deadline,now)",
"ManagerLevelCompatible(member->getLevel(),present->getLevel())",
"!BotLed(p)",
"Complete(p)",
"ProfessionCompatible(leader,member,Activity(targetPlan))",
"CanInvite(leader,member)",
"NeedsRole(leader,member)",
"sourceSize>=targetGroup->GetMembersCount()",
"Never hand forced leadership to a real player",
"GROUP_MANAGER_TRANSFER",
'op=="preview"',
'op=="run"',
):
assert required in source, required
code = r'''
#include "AdventureGroupPolicy.h"
#include <cassert>
int main()
{
using namespace AdventureGroupPolicy;
assert(ManagerLevelCompatible(60, 55));
assert(!ManagerLevelCompatible(60, 54));
assert(ManagerLevelCompatible(84, 79));
assert(!ManagerLevelCompatible(84, 78));
assert(ManagerLevelCompatible(85, 85));
assert(!ManagerLevelCompatible(85, 84));
assert(!ManagerLevelCompatible(80, 85));
assert(ManagerWindow(1600, 1000));
assert(ManagerWindow(1300, 1000));
assert(!ManagerWindow(1601, 1000));
assert(!ManagerWindow(1000, 1000));
assert(!ManagerWindow(999, 1000));
}
'''
with tempfile.TemporaryDirectory() as directory:
directory = Path(directory)
cpp = directory / "test.cpp"
exe = directory / "test"
cpp.write_text(code)
subprocess.run([
"c++", "-std=c++17", "-I" + str(root / "src/server/game/World"),
str(cpp), "-o", str(exe)
], check=True)
subprocess.run([str(exe)], check=True)
print("Formation manager window, level-85 isolation and native safety gates passed.")
@@ -69,6 +69,7 @@ code+=r'''
void AdventureGroupMgr::UpdateBrowser(Player*){}
bool AdventureGroupMgr::Merge(Player*,AdventureGroupPlan const&){return false;}
bool AdventureGroupMgr::NeedsRole(Player*,Player*){return true;}
void AdventureGroupMgr::MaybeRunFormationManager(time_t){}
bool AdventureGroupMgr::Complete(Player*p){auto group=p->GetGroup();if(!group)return false;auto plan=sAdventureBehaviorMgr->GroupPlan(p);return group->GetMembersCount()==(plan.Capacity?plan.Capacity:AdventureGroupPolicy::Capacity(plan.Forming?plan.NextIntent:plan.Intent));}
'''
code+=fun('float Sociability(')+'\n'+fun('bool ProfessionCompatible(')+'\n'+fun('bool Ready(')+'\n'+fun('std::string Activity(')+'\n'+fun('unsigned Capacity(')