Match Jimmy controller arithmetic and facing to original probes
This commit is contained in:
1 parent
42ea2b8cd5
commit
0e2f426d42
60 files changed
+6027
-48
No files matched your search
@@ -0,0 +1,511 @@
|
||||
"""Jimmy special material dispatch: source guards and copied-original observations."""
|
||||
from pathlib import Path
|
||||
import hashlib,json,sys,unittest,tempfile
|
||||
ROOT=Path(__file__).resolve().parents[1]
|
||||
sys.path.insert(0,str(ROOT/'tools/binary'))
|
||||
from jimmy_special_contact import collect,classify,generate
|
||||
# Original-code observations are committed here; generated logs remain ignored.
|
||||
FIXTURE=json.loads(r'''{
|
||||
"source_sha256": "f5281076e1a2492f2d61f87aae3f4544b6d0f535ebe33f9fbb6f78710fe1aea8",
|
||||
"ranges": [
|
||||
{
|
||||
"va": "0x43aa40",
|
||||
"file_offset": "0x3aa40",
|
||||
"length": 1443,
|
||||
"sha256": "2acd114eb62fe67490d9301bc8e68f196830be74eb9076f52f79111467344a78"
|
||||
},
|
||||
{
|
||||
"va": "0x42a7e0",
|
||||
"file_offset": "0x2a7e0",
|
||||
"length": 140,
|
||||
"sha256": "b999b3f9eb20ea2be18843048f8695e34e014e54b989e45f71d4113d9a81cf18"
|
||||
},
|
||||
{
|
||||
"va": "0x42a8d0",
|
||||
"file_offset": "0x2a8d0",
|
||||
"length": 72,
|
||||
"sha256": "88a303b3ae7cca7fc4c3935848077bbaf5393f83ed184b8e042e67803c3c4863"
|
||||
},
|
||||
{
|
||||
"va": "0x43a900",
|
||||
"file_offset": "0x3a900",
|
||||
"length": 320,
|
||||
"sha256": "73185486b7c1f3b972757db81837c495491144623f2944a82d564bb0d72626f4"
|
||||
},
|
||||
{
|
||||
"va": "0x43aff0",
|
||||
"file_offset": "0x3aff0",
|
||||
"length": 1456,
|
||||
"sha256": "5c641e54e5e854c965e652aa2a63d3249de8d0ebe6a3317caeaa5f5ebdac47c6"
|
||||
}
|
||||
],
|
||||
"bindings": [
|
||||
{
|
||||
"table": "0x4a3bdc",
|
||||
"slot": "0x160",
|
||||
"target": "0x42a7e0"
|
||||
},
|
||||
{
|
||||
"table": "0x4a3bdc",
|
||||
"slot": "0x164",
|
||||
"target": "0x42a8d0"
|
||||
},
|
||||
{
|
||||
"table": "0x4a373c",
|
||||
"slot": "0x374",
|
||||
"target": "0x42a660"
|
||||
},
|
||||
{
|
||||
"table": "0x4af6c4",
|
||||
"slot": "0x374",
|
||||
"target": "0x43aa40"
|
||||
}
|
||||
],
|
||||
"scope": "Copied43AA40 only, synthetic actor/material records, no-op160/164 damage callbacks and miss-only rays. No successful climb, damage, body or game entrypoint.",
|
||||
"cases": [
|
||||
{
|
||||
"input": [
|
||||
-1.0,
|
||||
4.0,
|
||||
0.0,
|
||||
0.0,
|
||||
1.0,
|
||||
1.0
|
||||
],
|
||||
"observed": [
|
||||
0,
|
||||
0,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"input": [
|
||||
59.0,
|
||||
4.0,
|
||||
0.0,
|
||||
0.0,
|
||||
1.0,
|
||||
1.0
|
||||
],
|
||||
"observed": [
|
||||
0,
|
||||
0,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"input": [
|
||||
60.0,
|
||||
4.0,
|
||||
0.0,
|
||||
0.0,
|
||||
1.0,
|
||||
1.0
|
||||
],
|
||||
"observed": [
|
||||
0,
|
||||
0,
|
||||
2
|
||||
]
|
||||
},
|
||||
{
|
||||
"input": [
|
||||
69.0,
|
||||
4.0,
|
||||
0.0,
|
||||
0.0,
|
||||
1.0,
|
||||
1.0
|
||||
],
|
||||
"observed": [
|
||||
0,
|
||||
0,
|
||||
2
|
||||
]
|
||||
},
|
||||
{
|
||||
"input": [
|
||||
70.0,
|
||||
4.0,
|
||||
0.0,
|
||||
0.0,
|
||||
1.0,
|
||||
1.0
|
||||
],
|
||||
"observed": [
|
||||
0,
|
||||
0,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"input": [
|
||||
109.0,
|
||||
4.0,
|
||||
0.0,
|
||||
0.0,
|
||||
1.0,
|
||||
1.0
|
||||
],
|
||||
"observed": [
|
||||
0,
|
||||
0,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"input": [
|
||||
110.0,
|
||||
4.0,
|
||||
0.0,
|
||||
0.0,
|
||||
1.0,
|
||||
1.0
|
||||
],
|
||||
"observed": [
|
||||
0,
|
||||
1,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"input": [
|
||||
119.0,
|
||||
4.0,
|
||||
0.0,
|
||||
0.0,
|
||||
1.0,
|
||||
1.0
|
||||
],
|
||||
"observed": [
|
||||
0,
|
||||
1,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"input": [
|
||||
120.0,
|
||||
4.0,
|
||||
0.0,
|
||||
0.0,
|
||||
1.0,
|
||||
1.0
|
||||
],
|
||||
"observed": [
|
||||
1,
|
||||
0,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"input": [
|
||||
129.0,
|
||||
4.0,
|
||||
0.0,
|
||||
0.0,
|
||||
1.0,
|
||||
1.0
|
||||
],
|
||||
"observed": [
|
||||
1,
|
||||
0,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"input": [
|
||||
130.0,
|
||||
4.0,
|
||||
0.0,
|
||||
0.0,
|
||||
1.0,
|
||||
1.0
|
||||
],
|
||||
"observed": [
|
||||
0,
|
||||
0,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"input": [
|
||||
179.0,
|
||||
4.0,
|
||||
0.0,
|
||||
0.0,
|
||||
1.0,
|
||||
1.0
|
||||
],
|
||||
"observed": [
|
||||
0,
|
||||
0,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"input": [
|
||||
180.0,
|
||||
4.0,
|
||||
0.0,
|
||||
0.0,
|
||||
1.0,
|
||||
1.0
|
||||
],
|
||||
"observed": [
|
||||
0,
|
||||
0,
|
||||
1
|
||||
]
|
||||
},
|
||||
{
|
||||
"input": [
|
||||
181.0,
|
||||
4.0,
|
||||
0.0,
|
||||
0.0,
|
||||
1.0,
|
||||
1.0
|
||||
],
|
||||
"observed": [
|
||||
0,
|
||||
0,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"input": [
|
||||
120.0,
|
||||
3.0,
|
||||
0.0,
|
||||
0.0,
|
||||
1.0,
|
||||
1.0
|
||||
],
|
||||
"observed": [
|
||||
0,
|
||||
0,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"input": [
|
||||
120.0,
|
||||
3.0000999,
|
||||
0.0,
|
||||
0.0,
|
||||
1.0,
|
||||
1.0
|
||||
],
|
||||
"observed": [
|
||||
1,
|
||||
0,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"input": [
|
||||
120.0,
|
||||
2.0,
|
||||
0.0,
|
||||
0.0,
|
||||
1.0,
|
||||
1.0
|
||||
],
|
||||
"observed": [
|
||||
0,
|
||||
0,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"input": [
|
||||
120.0,
|
||||
4.0,
|
||||
1.0,
|
||||
0.0,
|
||||
1.0,
|
||||
1.0
|
||||
],
|
||||
"observed": [
|
||||
1,
|
||||
0,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"input": [
|
||||
110.0,
|
||||
4.0,
|
||||
2.0,
|
||||
0.0,
|
||||
1.0,
|
||||
1.0
|
||||
],
|
||||
"observed": [
|
||||
0,
|
||||
1,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"input": [
|
||||
60.0,
|
||||
4.0,
|
||||
1.0,
|
||||
0.0,
|
||||
1.0,
|
||||
1.0
|
||||
],
|
||||
"observed": [
|
||||
0,
|
||||
0,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"input": [
|
||||
180.0,
|
||||
4.0,
|
||||
1.0,
|
||||
0.0,
|
||||
1.0,
|
||||
1.0
|
||||
],
|
||||
"observed": [
|
||||
0,
|
||||
0,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"input": [
|
||||
120.0,
|
||||
4.0,
|
||||
0.0,
|
||||
1.0,
|
||||
1.0,
|
||||
1.0
|
||||
],
|
||||
"observed": [
|
||||
0,
|
||||
0,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"input": [
|
||||
120.0,
|
||||
4.0,
|
||||
0.0,
|
||||
2.0,
|
||||
1.0,
|
||||
1.0
|
||||
],
|
||||
"observed": [
|
||||
0,
|
||||
0,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"input": [
|
||||
120.0,
|
||||
4.0,
|
||||
0.0,
|
||||
3.0,
|
||||
1.0,
|
||||
1.0
|
||||
],
|
||||
"observed": [
|
||||
0,
|
||||
0,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"input": [
|
||||
180.0,
|
||||
4.0,
|
||||
0.0,
|
||||
0.0,
|
||||
0.0,
|
||||
1.0
|
||||
],
|
||||
"observed": [
|
||||
0,
|
||||
0,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"input": [
|
||||
120.0,
|
||||
4.0,
|
||||
0.0,
|
||||
0.0,
|
||||
1.0,
|
||||
0.0
|
||||
],
|
||||
"observed": [
|
||||
1,
|
||||
0,
|
||||
0
|
||||
]
|
||||
},
|
||||
{
|
||||
"input": [
|
||||
60.0,
|
||||
4.0,
|
||||
0.0,
|
||||
0.0,
|
||||
1.0,
|
||||
0.0
|
||||
],
|
||||
"observed": [
|
||||
0,
|
||||
0,
|
||||
2
|
||||
]
|
||||
}
|
||||
],
|
||||
"files": {
|
||||
"tools/binary/jimmy_special_contact.py": "bf0d690aa5dd79265718e46ff5bbeca86c7ca0e71a2b894e4ef0515f7cbd8cf1",
|
||||
"tools/binary/jimmy_special_contact_probe.c": "553e77b6a175cd42a4fbdd98222dcbffed0cf26d4f516a09f982d264c213be95",
|
||||
"tools/binary/grappler_scalar_probe.c": "c51cc1ecefaf7a90e69a40624fd0e8cd7e01500359c4e67aee6213bb36f4a810",
|
||||
"artifacts/jimmy-special-contact/jimmy_special_contact_probe.exe": "4a759864c4ea3e9e478af28a6ef4f70f7e48da4102fb6dad3418fb9b02d1c019",
|
||||
"artifacts/jimmy-special-contact/probe/wine.log": "e680314e9dd8098aa2f4ce3650f0be21072d6ae0e120f5b92b7d3d029a166aa0"
|
||||
}
|
||||
}
|
||||
''')
|
||||
|
||||
class JimmySpecialContacts(unittest.TestCase):
|
||||
def test_source_ranges_bindings_and_offsets(self):
|
||||
source=collect(ROOT.parent/'Original')
|
||||
for key in ('source_sha256','ranges','bindings'):self.assertEqual(source[key],FIXTURE[key])
|
||||
for row in source['ranges']:self.assertEqual(int(row['file_offset'],16),int(row['va'],16)-0x400000)
|
||||
|
||||
def test_twenty_seven_original_dispatch_observations(self):
|
||||
self.assertEqual(len(FIXTURE['cases']),27)
|
||||
for case in FIXTURE['cases']:
|
||||
material,elapsed,mode,missing,support,controlled=case['input']
|
||||
policy=classify(None if missing else int(material),elapsed,int(mode))
|
||||
actual=[int(policy=='damage160'),int(policy=='damage164'),
|
||||
2 if policy=='fence_candidate' else 1 if policy=='ladder_candidate' and support else 0]
|
||||
self.assertEqual(actual,case['observed'],case)
|
||||
|
||||
def test_generated_probe_cannot_target_originals_or_symlinks(self):
|
||||
original=ROOT.parent/'Original'
|
||||
for target in (original,original/'generated',ROOT.parent):
|
||||
with self.assertRaises(ValueError):generate(original,target)
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root=Path(directory);(root/'jimmy_special_contact_probe.c').symlink_to(original/'Neutron.exe')
|
||||
with self.assertRaises(ValueError):generate(original,root)
|
||||
|
||||
def test_source_provenance(self):
|
||||
for file,digest in FIXTURE['files'].items():
|
||||
self.assertEqual(len(digest),64)
|
||||
if file.startswith('tools/'):
|
||||
self.assertEqual(hashlib.sha256((ROOT/file).read_bytes()).hexdigest(),digest)
|
||||
|
||||
if __name__=='__main__':unittest.main()
|
||||
Reference in new issue
Block a user