29 lines
1.3 KiB
Python
29 lines
1.3 KiB
Python
"""Execute the production coordinate policy; native probe checks marker storage."""
|
|
from policy_harness import ROOT, body, run
|
|
source=ROOT/'addons/core/Scripts/Game/ERR/ERR_DiscoveryMap.c'
|
|
policy=body(source,'static int Coordinate(').replace('Math.Round','std::round').replace('Math.Floor','std::floor')
|
|
run('''#include <cassert>
|
|
#include <cmath>
|
|
'''+policy+'''
|
|
int main(){
|
|
assert(Coordinate(6123.25f,1)==6250);
|
|
assert(Coordinate(7345.75f,1)==7250);
|
|
assert(Coordinate(6123.25f,2)==6123);
|
|
assert(Coordinate(7345.75f,2)==7346);
|
|
// Cell boundaries, negative world coordinates and deterministic repetition.
|
|
assert(Coordinate(0,1)==250 && Coordinate(499.99f,1)==250);
|
|
assert(Coordinate(500,1)==750 && Coordinate(-0.01f,1)==-250);
|
|
assert(Coordinate(-500,1)==-250 && Coordinate(-500.01f,1)==-750);
|
|
for(int i=-20000;i<=20000;i++){
|
|
const float actual=i+0.25f;
|
|
const int rough=Coordinate(actual,1);
|
|
assert(std::abs(actual-rough)<=250);
|
|
assert(rough==Coordinate(actual,1));
|
|
assert(Coordinate(rough-249.9f,1)==rough);
|
|
assert(Coordinate(rough+249.9f,1)==rough);
|
|
assert(std::abs(actual-Coordinate(actual,2))<=0.5f);
|
|
}
|
|
}
|
|
''')
|
|
print('PASS: actual discovery coordinates disclose stable 500m cell center until identified, then exact point, including negative/boundary coordinates')
|