Validate independent packed addons and complete physical mortar salvos
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
"""Execute actual fixture commit/event/closure gates; not native artillery simulation."""
|
||||
from policy_harness import ROOT, body, run
|
||||
p=ROOT/'addons/ai/Scripts/Game/ERR/ERR_NativeMortarFiringProbe.c'
|
||||
policies='\n'.join(body(p, sig) for sig in ['static bool CommitFresh(', 'static bool EventBound(', 'static bool ExpiredClosure('])
|
||||
policies='\n'.join(body(p, sig) for sig in ['static bool AimFresh(', 'static bool CommitFresh(', 'static bool EventBound(', 'static bool ExpiredClosure('])
|
||||
policies=policies.replace('ERR_MortarPrediction.', 'ERR_MortarPrediction::').replace('string failure', 'Text failure')
|
||||
methods='\n'.join(body(p,sig) for sig in ['void NativeCommit(', 'void NativeClosing(', 'void NativeProjectile('])
|
||||
methods=methods.replace('ERR_MortarBattery battery','Battery* battery').replace('IEntity gun, IEntity projectile','Entity* gun, Entity* projectile').replace('string reason, string failure','Text reason, Text failure')
|
||||
@@ -19,7 +19,7 @@ struct ERR_NativeMortarEvidenceRules {
|
||||
'''+policies+'''};
|
||||
struct Entity {int GetOrigin(){return 0;}};
|
||||
struct Report {int MessageId=7;float ObservedAt=1000;};
|
||||
struct Battery {bool CommandOpen=true,Released=true,stopped=false;int SourceId=7,OrderId=1,OrderShots=0;float AimedAt=19000,FlightTime=20;struct Report report;struct Report* Report=&report;bool Stopped(){return stopped;}};
|
||||
struct Battery {bool CommandOpen=true,Released=true,stopped=false;int SourceId=7,OrderId=1,OrderShots=0;float AimedAt=19000,AimValidatedAt=19000,FlightTime=20;struct Report report;struct Report* Report=&report;bool Stopped(){return stopped;}};
|
||||
struct Items {std::vector<Entity*> values;bool Contains(Entity* p){return std::find(values.begin(),values.end(),p)!=values.end();}void Insert(Entity* p){values.push_back(p);}};
|
||||
template<class... Args>void PrintFormat(Args...args){}
|
||||
struct Probe {
|
||||
@@ -29,6 +29,10 @@ struct Probe {
|
||||
};
|
||||
int main(){
|
||||
using Rules=ERR_NativeMortarEvidenceRules;
|
||||
assert(Rules::AimFresh(1000,19000,20000)); // old actual command, genuinely recent equivalent solve
|
||||
assert(!Rules::AimFresh(-1,19000,20000));assert(!Rules::AimFresh(21000,21000,20000));
|
||||
assert(!Rules::AimFresh(19000,18000,20000));assert(!Rules::AimFresh(1000,20001,20000));
|
||||
assert(!Rules::AimFresh(1000,9999,20000));assert(Rules::AimFresh(1000,10000,20000));
|
||||
assert(Rules::EventBound(true,1,1,0,0,60999,90000)); // original fresh commit survives delayed native emission
|
||||
assert(Rules::CommitFresh(1000,1000,61000));assert(!Rules::CommitFresh(1000,1000,61001));
|
||||
assert(!Rules::CommitFresh(1100,1000,20000));assert(!Rules::CommitFresh(1000,1000,999));
|
||||
@@ -43,7 +47,7 @@ int main(){
|
||||
Probe nullEvent;nullEvent.m_Battery=&b;nullEvent.m_Gun=&gun;nullEvent.NativeProjectile(&gun,nullptr);assert(nullEvent.m_BadProjectile&&nullEvent.m_Events==0);
|
||||
Probe stoppedObserver;stoppedObserver.m_Battery=&b;stoppedObserver.m_Gun=&gun;stoppedObserver.m_Stopped=true;stoppedObserver.NativeCommit(&b,20000);stoppedObserver.NativeProjectile(&gun,&projectile);assert(stoppedObserver.m_Commits==0&&stoppedObserver.m_Events==0&&!stoppedObserver.m_BadProjectile);
|
||||
// Physical launch after report expiry is legitimate if its commit was fresh.
|
||||
b=Battery();b.Report=&b.report;b.AimedAt=60500;Probe delayed;delayed.m_Battery=&b;delayed.m_Gun=&gun;delayed.m_Step=3;
|
||||
b=Battery();b.Report=&b.report;b.AimedAt=60500;b.AimValidatedAt=60500;Probe delayed;delayed.m_Battery=&b;delayed.m_Gun=&gun;delayed.m_Step=3;
|
||||
delayed.NativeCommit(&b,60999);clockNow=62999;delayed.NativeProjectile(&gun,&projectile);
|
||||
assert(delayed.m_Events==1&&!delayed.m_BadProjectile);
|
||||
for(int fault=0;fault<10;++fault){
|
||||
@@ -52,12 +56,12 @@ int main(){
|
||||
if(fault==1)b.Released=false;
|
||||
if(fault==2)b.SourceId=8;
|
||||
if(fault==3)b.AimedAt=-1;
|
||||
if(fault==4)b.AimedAt=9999;
|
||||
if(fault==4)b.AimValidatedAt=9999;
|
||||
if(fault==5)b.FlightTime=0;
|
||||
if(fault==6)q.m_Step=2;
|
||||
if(fault==7)b.report.ObservedAt=1001;
|
||||
if(fault==8)b.OrderId=2;
|
||||
if(fault==9){clockNow=61001;b.AimedAt=61000;}
|
||||
if(fault==9){clockNow=61001;b.AimedAt=61000;b.AimValidatedAt=61000;}
|
||||
q.NativeCommit(&b,clockNow);assert(q.m_BadProjectile&&!q.m_CommitPending&&q.m_Commits==0);
|
||||
}
|
||||
b=Battery();b.Report=&b.report;clockNow=20000;Probe missing;missing.m_Battery=&b;missing.m_Gun=&gun;
|
||||
|
||||
Reference in New Issue
Block a user