"""Execute the production finite loot planner with deterministic rolls/resource gates.""" from policy_harness import ROOT, body, run plan=body(ROOT/'addons/core/Scripts/Game/ERR/00_Core/ERR_CrashLoot.c','static void Plan(') plan=plan.replace('array items','array& items').replace('Math.RandomInt','Roll').replace('ERR_EnemyLoadoutCatalog.FIM','FIM') run(r''' #include #include #include using ResourceName=std::string; template struct array:std::vector{void Clear(){this->clear();}void Insert(T v){this->push_back(v);}}; bool west=true,east=true,launchers=true; int roll=0; int Roll(int,int){return roll;} ResourceName FIM="AA"; bool RifleAllowed(bool w){return w?west:east;} bool Allowed(ResourceName){return launchers;} ResourceName Rifle(bool w){return w?"W":"E";} ResourceName Magazine(bool w){return w?"WM":"EM";} ResourceName RPG(){return "RPG";} ResourceName Rocket(){return "ROCKET";} '''+plan+r''' int main(){ array items; // Zero chances never grant launchers, even on the lowest roll. Plan(3,4,0,0,items);assert(items.size()==15); for(int i=0;i<3;i++){assert(items[i*5]=="W");for(int j=1;j<=4;j++)assert(items[i*5+j]=="WM");} // Disabled rifle family falls back only to an allowed paired loadout. west=false;Plan(6,8,100,100,items);assert(items.size()==58); for(int i=0;i<6;i++){assert(items[i*9]=="E");for(int j=1;j<=8;j++)assert(items[i*9+j]=="EM");} assert(items[54]=="RPG"&&items[55]=="ROCKET"&&items[56]=="ROCKET"&&items[57]=="AA"); // Unavailable/blocked optional resources cannot be forced by 100% chances. launchers=false;Plan(1,1,100,100,items);assert(items.size()==2); east=false;Plan(6,8,100,100,items);assert(items.empty()); // A roll equal to the configured percentage is excluded. launchers=true;roll=25;Plan(1,1,25,25,items);assert(items.empty()); roll=24;Plan(1,1,25,25,items);assert(items.size()==4); } ''') print('PASS: finite paired rifle/ammo plan, maximum capacity, zero/100% endpoints, disabled families and unavailable launchers')