code wiki / (root) / nx_multi_pair_test.nx

nx_multi_pair_test.nx source

↩ module page · 80 lines · 3279 B

1import "nx_syscalls.nx" 2import "nx_v7_bundle.nx" 3import "nx_multi_bundle.nx" 4import "nx_pair_synchrony.nx" 5import "nx_pose_classify.nx" 6 7func main() -> i64 { 8 // T1: alloc multi-bundle for 2 characters. 9 let multi: *i64 = nx_multi_bundle_alloc(2) 10 if multi == (0 as *i64) { return 1 } 11 nx_multi_bundle_set_count(multi, 2) 12 if nx_multi_bundle_count(multi) != 2 { return 2 } 13 14 // T2: get per-character bundle pointers. 15 let a: *i64 = nx_multi_bundle_char(multi, 0) 16 let b: *i64 = nx_multi_bundle_char(multi, 1) 17 if a == (0 as *i64) { return 10 } 18 if b == (0 as *i64) { return 11 } 19 if a == b { return 12 } 20 21 // Image #55: two characters in same pose, mirrored across scene midline. 22 // Character A: face on left, char B: face on right; both LEANING_FORWARD. 23 nx_v7_bundle_set_face(a, 60, 30, 140, 110) 24 nx_v7_bundle_set_torso(a, 50, 110, 150, 290) 25 nx_v7_bundle_set_eye(a, 25, 5) 26 a[NX_V7_POSE_KIND] = NX_POSE_LEANING_FORWARD 27 a[NX_V7_AROUSAL_Q10] = 500 28 a[NX_V7_REPRODUCTIVE_STATE] = 1 29 30 nx_v7_bundle_set_face(b, 460, 30, 540, 110) 31 nx_v7_bundle_set_torso(b, 450, 110, 550, 290) 32 nx_v7_bundle_set_eye(b, 24, 5) 33 b[NX_V7_POSE_KIND] = NX_POSE_LEANING_FORWARD 34 b[NX_V7_AROUSAL_Q10] = 510 35 b[NX_V7_REPRODUCTIVE_STATE] = 1 36 37 // T3: pair_pose_sync_q10 = 1024 (same pose). 38 let sync: i64 = nx_pair_pose_sync_q10(a, b) 39 if sync != 1024 { return 20 } 40 41 // T4: mirror_q10 — face A at cx=100, face B at cx=500, midline=300. 42 // A offset = -200, B offset = +200 → opposite signs, magnitude equal → 1024. 43 let mirror: i64 = nx_pair_pose_mirror_q10(a, b, 300) 44 if mirror < 900 { return 30 } 45 46 // T5: identity_distinct — eye widths 25 vs 24, similar but not clone. 47 let dist: i64 = nx_pair_identity_distinct_q10(a, b) 48 if dist < 100 { return 40 } // small but non-zero distinctness 49 50 // T6: aesthetic_match — arousal 500 vs 510 (10 diff), state 1 vs 1 → high match. 51 let aes: i64 = nx_pair_aesthetic_match_q10(a, b) 52 if aes < 900 { return 50 } 53 54 // T7: scale_coh — torso heights 180 vs 180 → 1024. 55 let scale: i64 = nx_pair_scale_coherence_q10(a, b) 56 if scale != 1024 { return 60 } 57 58 // T8: composite verdict — should be SYNCHRONIZED_PAIR (matches image #55). 59 let result: *i64 = (sys_mmap(NX_PAIR_RES_FIELDS * 8 + 16)) as *i64 60 nx_pair_synchrony(a, b, 300, result) 61 let v: i64 = result[NX_PAIR_RES_VERDICT] 62 // Note: identity_distinct only 100 here; threshold is 410. So verdict 63 // falls to MATCHED (pose_sync 1024 + aes_match 967 high). 64 if v != NX_PAIR_V_MATCHED { if v != NX_PAIR_V_SYNCHRONIZED_PAIR { return 70 } } 65 66 // T9: discordant pair — different poses. 67 b[NX_V7_POSE_KIND] = NX_POSE_STANDING_FACING 68 nx_pair_synchrony(a, b, 300, result) 69 let v2: i64 = result[NX_PAIR_RES_VERDICT] 70 if v2 == NX_PAIR_V_SYNCHRONIZED_PAIR { return 80 } 71 72 // T10: increase distinctness then re-test for SYNCHRONIZED_PAIR. 73 b[NX_V7_POSE_KIND] = NX_POSE_LEANING_FORWARD 74 nx_v7_bundle_set_eye(b, 30, 6) // 25 vs 30 → 16.7% relative diff → ~830 q10 75 nx_pair_synchrony(a, b, 300, result) 76 let v3: i64 = result[NX_PAIR_RES_VERDICT] 77 if v3 != NX_PAIR_V_SYNCHRONIZED_PAIR { return 90 } 78 79 return 0 80}