nmarshall commited on
Commit
264d595
·
1 Parent(s): 039998a

gameplay: query linked location triggers

Browse files
crates/urt-gameplay/src/bin/support/located_radio.rs CHANGED
@@ -27,7 +27,7 @@ fn hex(v: &[u8]) -> String {
27
  fn optional(v: Option<usize>) -> String {
28
  v.map(|v| v.to_string()).unwrap_or("null".into())
29
  }
30
- fn decode_location(w: &[u32]) -> (Vec<LocationEntry>, LocationInput) {
31
  assert!(w.len() >= 19);
32
  let mut pos = 3;
33
  let mut e = vec![];
 
27
  fn optional(v: Option<usize>) -> String {
28
  v.map(|v| v.to_string()).unwrap_or("null".into())
29
  }
30
+ pub fn decode_location(w: &[u32]) -> (Vec<LocationEntry>, LocationInput) {
31
  assert!(w.len() >= 19);
32
  let mut pos = 3;
33
  let mut e = vec![];
crates/urt-gameplay/src/bin/urt-location-feedback.rs CHANGED
@@ -24,7 +24,14 @@ fn main() {
24
  let kind = args.next().unwrap();
25
  let w: Vec<u32> = args.map(|v| v.parse().unwrap()).collect();
26
  match kind.as_str() {
27
- "nearest" => println!("{}", nearest(&w)),
 
 
 
 
 
 
 
28
  "text" => println!("{}", text(&w)),
29
  "radio" => println!("{}", radio(&w)),
30
  "expire" => println!("{}", expire(&w)),
@@ -35,44 +42,24 @@ fn main() {
35
  _ => panic!("unknown contract"),
36
  }
37
  }
38
- fn nearest(w: &[u32]) -> String {
39
- assert!(w.len() >= 19);
40
- let mut pos = 3;
41
- let mut e = vec![];
42
- for _ in 0..3 {
43
- e.push(LocationEntry {
44
- point: w[pos..pos + 3].try_into().unwrap(),
45
- trigger: w[pos + 3] != 0,
46
- visible: w[pos + 4] != 0,
47
- });
48
- pos += 5;
 
 
49
  }
50
- let q = w[pos] as usize;
51
- pos += 1;
52
- let query = w[pos..pos + q].iter().map(|v| *v as usize).collect();
53
- pos += q;
54
- let n = w[pos] as usize;
55
- pos += 1;
56
- let order = w[pos..pos + n].iter().map(|v| *v as usize).collect();
57
- pos += n;
58
- assert_eq!(pos, w.len());
59
- let cache = if w[0] == u32::MAX {
60
- None
61
- } else {
62
- Some(w[0] as usize)
63
- };
64
- let out = nearest_location(
65
- &e,
66
- &LocationInput {
67
- actor: [0; 3],
68
- cache,
69
- expiry: w[1],
70
- tick: w[2],
71
- query,
72
- order,
73
- },
74
- )
75
- .unwrap();
76
  let bounds = out
77
  .queries
78
  .iter()
 
24
  let kind = args.next().unwrap();
25
  let w: Vec<u32> = args.map(|v| v.parse().unwrap()).collect();
26
  match kind.as_str() {
27
+ "nearest" => {
28
+ let (entries, input) = radio_fixture::decode_location(&w);
29
+ println!(
30
+ "{}",
31
+ location_fields(nearest_location(&entries, &input).unwrap())
32
+ );
33
+ }
34
+ "nearest-linked" => println!("{}", nearest_linked(&w)),
35
  "text" => println!("{}", text(&w)),
36
  "radio" => println!("{}", radio(&w)),
37
  "expire" => println!("{}", expire(&w)),
 
42
  _ => panic!("unknown contract"),
43
  }
44
  }
45
+ fn nearest_linked(words: &[u32]) -> String {
46
+ use urt_gameplay::spatial_index::{Bounds, SpatialIndex};
47
+
48
+ let n = words[0] as usize;
49
+ let (entries, mut input) = radio_fixture::decode_location(&words[1..=n]);
50
+ input.actor.copy_from_slice(&words[n + 1..n + 4]);
51
+ let entries = entries.into_iter().map(Some).collect::<Vec<_>>();
52
+ let mut index = SpatialIndex::new(Bounds::new([-128.; 3], [128.; 3]).unwrap(), 4).unwrap();
53
+ for op in words[n + 4..].chunks_exact(7) {
54
+ let slot = op[0] as usize;
55
+ let min = <[u32; 3]>::try_from(&op[1..4]).unwrap().map(f32::from_bits);
56
+ let max = <[u32; 3]>::try_from(&op[4..7]).unwrap().map(f32::from_bits);
57
+ index.link(slot, Bounds::new(min, max).unwrap()).unwrap();
58
  }
59
+ location_fields(nearest_linked_location(&index, &entries, (&input).into()).unwrap())
60
+ }
61
+
62
+ fn location_fields(out: LocationSelection) -> String {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  let bounds = out
64
  .queries
65
  .iter()
crates/urt-gameplay/src/location_feedback.rs CHANGED
@@ -28,6 +28,61 @@ pub fn nearest_location(
28
  entries: &[LocationEntry],
29
  input: &LocationInput,
30
  ) -> Result<LocationSelection, Error> {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  let mut out = LocationSelection {
32
  selected: None,
33
  queries: vec![],
@@ -36,35 +91,49 @@ pub fn nearest_location(
36
  };
37
  if let Some(index) = input.cache {
38
  if (input.tick as i32) < input.expiry as i32 {
39
- entries.get(index).ok_or(Error::InvalidIndex)?;
40
  out.selected = Some(index);
41
  return Ok(out);
42
  }
43
  }
44
- if input.query.len() > 1024 || input.order.len() > 1024 {
 
 
 
45
  return Err(Error::InvalidCount);
46
  }
47
  let mut actor = [0.; 3];
48
- let mut bounds = [[0; 3]; 2];
49
  for j in 0..3 {
50
  actor[j] = f32::from_bits(input.actor[j]);
51
  if !actor[j].is_finite() {
52
  return Err(Error::NonFinite);
53
  }
54
  let extent = if j == 2 { 52. } else { 40. };
55
- bounds[0][j] = (actor[j] - extent).to_bits();
56
- bounds[1][j] = (actor[j] + extent).to_bits();
57
  }
58
- out.queries.push(bounds);
59
- for &index in &input.query {
60
- if entries.get(index).ok_or(Error::InvalidIndex)?.trigger {
61
- out.selected = Some(index);
62
- return Ok(out);
 
 
 
 
 
 
 
 
 
 
 
63
  }
64
  }
65
  let mut best = 201326592f32;
66
- for &index in &input.order {
67
- let e = entries.get(index).ok_or(Error::InvalidIndex)?;
68
  let mut d = [0.; 3];
69
  for j in 0..3 {
70
  let p = f32::from_bits(e.point[j]);
 
28
  entries: &[LocationEntry],
29
  input: &LocationInput,
30
  ) -> Result<LocationSelection, Error> {
31
+ nearest_from(
32
+ |slot| entries.get(slot).copied(),
33
+ LocationLookup::from(input),
34
+ LocationCandidates::Supplied(&input.query),
35
+ )
36
+ }
37
+
38
+ #[derive(Clone, Copy, Debug)]
39
+ pub struct LocationLookup<'a> {
40
+ pub actor: [u32; 3],
41
+ pub cache: Option<usize>,
42
+ pub expiry: u32,
43
+ pub tick: u32,
44
+ pub order: &'a [usize],
45
+ }
46
+
47
+ impl<'a> From<&'a LocationInput> for LocationLookup<'a> {
48
+ fn from(input: &'a LocationInput) -> Self {
49
+ Self {
50
+ actor: input.actor,
51
+ cache: input.cache,
52
+ expiry: input.expiry,
53
+ tick: input.tick,
54
+ order: &input.order,
55
+ }
56
+ }
57
+ }
58
+
59
+ /// Resolve box candidates via linked game slots. Non-location entities take
60
+ /// up space in the native candidate list but do not match the trigger class.
61
+ /// Fallback visibility still comes from the supplied location table.
62
+ pub fn nearest_linked_location(
63
+ index: &crate::spatial_index::SpatialIndex,
64
+ entries: &[Option<LocationEntry>],
65
+ input: LocationLookup<'_>,
66
+ ) -> Result<LocationSelection, Error> {
67
+ nearest_from(
68
+ |slot| entries.get(slot).copied().flatten(),
69
+ input,
70
+ LocationCandidates::Linked(index),
71
+ )
72
+ }
73
+
74
+ enum LocationCandidates<'a> {
75
+ Supplied(&'a [usize]),
76
+ Linked(&'a crate::spatial_index::SpatialIndex),
77
+ }
78
+
79
+ fn nearest_from(
80
+ entry: impl Fn(usize) -> Option<LocationEntry>,
81
+ input: LocationLookup<'_>,
82
+ candidates: LocationCandidates<'_>,
83
+ ) -> Result<LocationSelection, Error> {
84
+ use std::borrow::Cow;
85
+
86
  let mut out = LocationSelection {
87
  selected: None,
88
  queries: vec![],
 
91
  };
92
  if let Some(index) = input.cache {
93
  if (input.tick as i32) < input.expiry as i32 {
94
+ entry(index).ok_or(Error::InvalidIndex)?;
95
  out.selected = Some(index);
96
  return Ok(out);
97
  }
98
  }
99
+ let supplied = matches!(candidates, LocationCandidates::Supplied(_));
100
+ if input.order.len() > 1024
101
+ || matches!(candidates, LocationCandidates::Supplied(slots) if slots.len() > 1024)
102
+ {
103
  return Err(Error::InvalidCount);
104
  }
105
  let mut actor = [0.; 3];
106
+ let mut bounds = [[0.; 3]; 2];
107
  for j in 0..3 {
108
  actor[j] = f32::from_bits(input.actor[j]);
109
  if !actor[j].is_finite() {
110
  return Err(Error::NonFinite);
111
  }
112
  let extent = if j == 2 { 52. } else { 40. };
113
+ bounds[0][j] = actor[j] - extent;
114
+ bounds[1][j] = actor[j] + extent;
115
  }
116
+ out.queries.push(bounds.map(|p| p.map(f32::to_bits)));
117
+ let slots = match candidates {
118
+ LocationCandidates::Supplied(slots) => Cow::Borrowed(slots),
119
+ LocationCandidates::Linked(index) => {
120
+ let bounds = crate::spatial_index::Bounds::new(bounds[0], bounds[1])?;
121
+ Cow::Owned(index.query(bounds, 1024).slots)
122
+ }
123
+ };
124
+ for &slot in slots.iter() {
125
+ match entry(slot) {
126
+ Some(e) if e.trigger => {
127
+ out.selected = Some(slot);
128
+ return Ok(out);
129
+ }
130
+ None if supplied => return Err(Error::InvalidIndex),
131
+ _ => {}
132
  }
133
  }
134
  let mut best = 201326592f32;
135
+ for &index in input.order {
136
+ let e = entry(index).ok_or(Error::InvalidIndex)?;
137
  let mut d = [0.; 3];
138
  for j in 0..3 {
139
  let p = f32::from_bits(e.point[j]);
docs/FINDINGS.md CHANGED
@@ -2065,3 +2065,5 @@ RE-1034–1043 batch validation passed:2,018 Python tests,339 Rust tests,146 det
2065
  - Rust defuse score actions refresh rank words before the objective counter update. [Rust rank feedback parity](research/RUST_DEFUSE_RANK_FEEDBACK.md).
2066
 
2067
  - The Rust sector index preserves candidate order as a function of link history, node placement and traversal. [Spatial index parity](research/RUST_SPATIAL_INDEX.md).
 
 
 
2065
  - Rust defuse score actions refresh rank words before the objective counter update. [Rust rank feedback parity](research/RUST_DEFUSE_RANK_FEEDBACK.md).
2066
 
2067
  - The Rust sector index preserves candidate order as a function of link history, node placement and traversal. [Spatial index parity](research/RUST_SPATIAL_INDEX.md).
2068
+
2069
+ - Location trigger selection can use linked-slot box queries while preserving the caller's cache and fallback list behavior. [Linked location lookup](research/RUST_LINKED_LOCATION.md).
docs/PROVISIONAL_TODO.md CHANGED
@@ -2127,3 +2127,5 @@ RE-974–983 completed routing, command rewrite, inactivity, movement-parameter
2127
  - [x] RE-1059 Port ranking and counter feedback after allocated defuse ([evidence](research/RUST_DEFUSE_RANK_FEEDBACK.md)).
2128
 
2129
  - [x] RE-1060 Port world sector construction, linked slot ownership and ordered area queries ([evidence](research/RUST_SPATIAL_INDEX.md)).
 
 
 
2127
  - [x] RE-1059 Port ranking and counter feedback after allocated defuse ([evidence](research/RUST_DEFUSE_RANK_FEEDBACK.md)).
2128
 
2129
  - [x] RE-1060 Port world sector construction, linked slot ownership and ordered area queries ([evidence](research/RUST_SPATIAL_INDEX.md)).
2130
+
2131
+ - [x] RE-1061 Connect location box queries to the Rust linked-slot index ([evidence](research/RUST_LINKED_LOCATION.md)).
docs/RESEARCH_LEDGER.md CHANGED
@@ -2915,3 +2915,7 @@ The shared roster now reflects defuse scoring before ranking and publishes the c
2915
  ## 2026-11-25 — RE-1060 Port world sector construction, linked slot ownership and ordered area queries
2916
 
2917
  The fixed-depth Rust sector index matches six source trees and 128 placement slices. The composed fixtures also check candidate ordering, relink and unlink, and capacity warnings across sibling branches. See [spatial index parity](research/RUST_SPATIAL_INDEX.md).
 
 
 
 
 
2915
  ## 2026-11-25 — RE-1060 Port world sector construction, linked slot ownership and ordered area queries
2916
 
2917
  The fixed-depth Rust sector index matches six source trees and 128 placement slices. The composed fixtures also check candidate ordering, relink and unlink, and capacity warnings across sibling branches. See [spatial index parity](research/RUST_SPATIAL_INDEX.md).
2918
+
2919
+ ## 2026-11-25 — RE-1061 Connect location box queries to the Rust linked-slot index
2920
+
2921
+ The Rust location selector now accepts linked slot candidates from its spatial index. Nine composition cases check cache timing, trigger ordering and fallback when real box candidates do not provide a location. See [linked location lookup](research/RUST_LINKED_LOCATION.md).
docs/research/README.md CHANGED
@@ -1693,3 +1693,5 @@ The extension collector adds five focused tests for native tail calls, command-r
1693
  - [Ranking and counters after allocated defuse in Rust](RUST_DEFUSE_RANK_FEEDBACK.md)
1694
 
1695
  - [Rust linked-entity sector index](RUST_SPATIAL_INDEX.md)
 
 
 
1693
  - [Ranking and counters after allocated defuse in Rust](RUST_DEFUSE_RANK_FEEDBACK.md)
1694
 
1695
  - [Rust linked-entity sector index](RUST_SPATIAL_INDEX.md)
1696
+
1697
+ - [Location lookup over linked slots](RUST_LINKED_LOCATION.md)
docs/research/RUST_LINKED_LOCATION.md ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ # Location lookup over linked slots
2
+
3
+ `nearest_linked_location` uses the sector index to generate candidates when no unexpired cache entry applies. It queries the same actor-relative box at the original capacity of 1024 and skips linked slots without a location entry. The first trigger in link traversal order wins. The fallback list retains its own traversal and visibility rules even when there are no matching linked candidates.
4
+
5
+ [Nine composition cases](rust-linked-location.json) exercise relink order, cache expiry, non-location slots, exact boundary overlap, nonzero actor coordinates, and fallback behavior. The focused check also reruns the existing QVM parity for nearest location and radio. The adapter still takes location records, cache expiry and fallback visibility from its caller.
docs/research/rust-linked-location.json ADDED
@@ -0,0 +1,362 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "limits": "Rust composition fixtures for linked box candidates. Fallback PVS is supplied by the fixture.",
3
+ "probes": [
4
+ {
5
+ "case": "linked-order",
6
+ "expected": {
7
+ "cache": null,
8
+ "pvs": [],
9
+ "queries": [
10
+ [
11
+ [
12
+ 3256877056,
13
+ 3256877056,
14
+ 3260022784
15
+ ],
16
+ [
17
+ 1109393408,
18
+ 1109393408,
19
+ 1112539136
20
+ ]
21
+ ]
22
+ ],
23
+ "selected": 1
24
+ },
25
+ "rust": {
26
+ "cache": null,
27
+ "pvs": [],
28
+ "queries": [
29
+ [
30
+ [
31
+ 3256877056,
32
+ 3256877056,
33
+ 3260022784
34
+ ],
35
+ [
36
+ 1109393408,
37
+ 1109393408,
38
+ 1112539136
39
+ ]
40
+ ]
41
+ ],
42
+ "selected": 1
43
+ }
44
+ },
45
+ {
46
+ "case": "relink",
47
+ "expected": {
48
+ "cache": null,
49
+ "pvs": [],
50
+ "queries": [
51
+ [
52
+ [
53
+ 3256877056,
54
+ 3256877056,
55
+ 3260022784
56
+ ],
57
+ [
58
+ 1109393408,
59
+ 1109393408,
60
+ 1112539136
61
+ ]
62
+ ]
63
+ ],
64
+ "selected": 0
65
+ },
66
+ "rust": {
67
+ "cache": null,
68
+ "pvs": [],
69
+ "queries": [
70
+ [
71
+ [
72
+ 3256877056,
73
+ 3256877056,
74
+ 3260022784
75
+ ],
76
+ [
77
+ 1109393408,
78
+ 1109393408,
79
+ 1112539136
80
+ ]
81
+ ]
82
+ ],
83
+ "selected": 0
84
+ }
85
+ },
86
+ {
87
+ "case": "cache",
88
+ "expected": {
89
+ "cache": 2,
90
+ "pvs": [],
91
+ "queries": [],
92
+ "selected": 2
93
+ },
94
+ "rust": {
95
+ "cache": 2,
96
+ "pvs": [],
97
+ "queries": [],
98
+ "selected": 2
99
+ }
100
+ },
101
+ {
102
+ "case": "expired-cache",
103
+ "expected": {
104
+ "cache": 2,
105
+ "pvs": [],
106
+ "queries": [
107
+ [
108
+ [
109
+ 3256877056,
110
+ 3256877056,
111
+ 3260022784
112
+ ],
113
+ [
114
+ 1109393408,
115
+ 1109393408,
116
+ 1112539136
117
+ ]
118
+ ]
119
+ ],
120
+ "selected": 1
121
+ },
122
+ "rust": {
123
+ "cache": 2,
124
+ "pvs": [],
125
+ "queries": [
126
+ [
127
+ [
128
+ 3256877056,
129
+ 3256877056,
130
+ 3260022784
131
+ ],
132
+ [
133
+ 1109393408,
134
+ 1109393408,
135
+ 1112539136
136
+ ]
137
+ ]
138
+ ],
139
+ "selected": 1
140
+ }
141
+ },
142
+ {
143
+ "case": "expired-cache-empty-box",
144
+ "expected": {
145
+ "cache": 2,
146
+ "pvs": [
147
+ 0,
148
+ 1
149
+ ],
150
+ "queries": [
151
+ [
152
+ [
153
+ 3256877056,
154
+ 3256877056,
155
+ 3260022784
156
+ ],
157
+ [
158
+ 1109393408,
159
+ 1109393408,
160
+ 1112539136
161
+ ]
162
+ ]
163
+ ],
164
+ "selected": 1
165
+ },
166
+ "rust": {
167
+ "cache": 2,
168
+ "pvs": [
169
+ 0,
170
+ 1
171
+ ],
172
+ "queries": [
173
+ [
174
+ [
175
+ 3256877056,
176
+ 3256877056,
177
+ 3260022784
178
+ ],
179
+ [
180
+ 1109393408,
181
+ 1109393408,
182
+ 1112539136
183
+ ]
184
+ ]
185
+ ],
186
+ "selected": 1
187
+ }
188
+ },
189
+ {
190
+ "case": "touching-query-bound",
191
+ "expected": {
192
+ "cache": null,
193
+ "pvs": [],
194
+ "queries": [
195
+ [
196
+ [
197
+ 3256877056,
198
+ 3256877056,
199
+ 3260022784
200
+ ],
201
+ [
202
+ 1109393408,
203
+ 1109393408,
204
+ 1112539136
205
+ ]
206
+ ]
207
+ ],
208
+ "selected": 0
209
+ },
210
+ "rust": {
211
+ "cache": null,
212
+ "pvs": [],
213
+ "queries": [
214
+ [
215
+ [
216
+ 3256877056,
217
+ 3256877056,
218
+ 3260022784
219
+ ],
220
+ [
221
+ 1109393408,
222
+ 1109393408,
223
+ 1112539136
224
+ ]
225
+ ]
226
+ ],
227
+ "selected": 0
228
+ }
229
+ },
230
+ {
231
+ "case": "nonzero-actor",
232
+ "expected": {
233
+ "cache": null,
234
+ "pvs": [],
235
+ "queries": [
236
+ [
237
+ [
238
+ 3248488448,
239
+ 3256877056,
240
+ 3260022784
241
+ ],
242
+ [
243
+ 1114636288,
244
+ 1109393408,
245
+ 1112539136
246
+ ]
247
+ ]
248
+ ],
249
+ "selected": 0
250
+ },
251
+ "rust": {
252
+ "cache": null,
253
+ "pvs": [],
254
+ "queries": [
255
+ [
256
+ [
257
+ 3248488448,
258
+ 3256877056,
259
+ 3260022784
260
+ ],
261
+ [
262
+ 1114636288,
263
+ 1109393408,
264
+ 1112539136
265
+ ]
266
+ ]
267
+ ],
268
+ "selected": 0
269
+ }
270
+ },
271
+ {
272
+ "case": "no-visible-fallback",
273
+ "expected": {
274
+ "cache": null,
275
+ "pvs": [
276
+ 0,
277
+ 1,
278
+ 2
279
+ ],
280
+ "queries": [
281
+ [
282
+ [
283
+ 3256877056,
284
+ 3256877056,
285
+ 3260022784
286
+ ],
287
+ [
288
+ 1109393408,
289
+ 1109393408,
290
+ 1112539136
291
+ ]
292
+ ]
293
+ ],
294
+ "selected": null
295
+ },
296
+ "rust": {
297
+ "cache": null,
298
+ "pvs": [
299
+ 0,
300
+ 1,
301
+ 2
302
+ ],
303
+ "queries": [
304
+ [
305
+ [
306
+ 3256877056,
307
+ 3256877056,
308
+ 3260022784
309
+ ],
310
+ [
311
+ 1109393408,
312
+ 1109393408,
313
+ 1112539136
314
+ ]
315
+ ]
316
+ ],
317
+ "selected": null
318
+ }
319
+ },
320
+ {
321
+ "case": "trigger-skips-fallback",
322
+ "expected": {
323
+ "cache": null,
324
+ "pvs": [],
325
+ "queries": [
326
+ [
327
+ [
328
+ 3256877056,
329
+ 3256877056,
330
+ 3260022784
331
+ ],
332
+ [
333
+ 1109393408,
334
+ 1109393408,
335
+ 1112539136
336
+ ]
337
+ ]
338
+ ],
339
+ "selected": 1
340
+ },
341
+ "rust": {
342
+ "cache": null,
343
+ "pvs": [],
344
+ "queries": [
345
+ [
346
+ [
347
+ 3256877056,
348
+ 3256877056,
349
+ 3260022784
350
+ ],
351
+ [
352
+ 1109393408,
353
+ 1109393408,
354
+ 1112539136
355
+ ]
356
+ ]
357
+ ],
358
+ "selected": 1
359
+ }
360
+ }
361
+ ]
362
+ }
scripts/analyze_rust_linked_location.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Exercise source location policies with queries from the Rust sector tree."""
2
+ import os
3
+ import subprocess
4
+ from pathlib import Path
5
+
6
+ from analyze_qvm import write_json
7
+ from analyze_rust_location_nearest import encode
8
+ from qvm_move_callbacks_oracle import word
9
+ from rust_lifecycle_support import result
10
+
11
+
12
+ def cases():
13
+ default = dict(cache=None, expiry=10000, tick=10000, query=[2],
14
+ order=[0, 1, 2], points=[[10., 0., 0.], [-10., 0., 0.], [30., 0., 0.]],
15
+ triggers=[1, 1, 0], visible=[1, 1, 1])
16
+ nearby = [(0, 10.), (1, -10.), (3, 0.)]
17
+ yield 'linked-order', default, [0., 0., 0.], nearby, 1, []
18
+ yield 'relink', default, [0., 0., 0.], [*nearby, (0, 10.)], 0, []
19
+ yield 'cache', dict(default, cache=2, expiry=10001), [0., 0., 0.], nearby, 2, []
20
+ yield 'expired-cache', dict(default, cache=2), [0., 0., 0.], nearby, 1, []
21
+ yield 'expired-cache-empty-box', dict(default, cache=2), [0., 0., 0.], [(0, 41.)], 1, [0, 1]
22
+ yield 'touching-query-bound', default, [0., 0., 0.], [(0, 40.)], 0, []
23
+ yield 'nonzero-actor', default, [20., 0., 0.], [(0, 60.), (1, -21.)], 0, []
24
+ yield 'no-visible-fallback', dict(default, visible=[0, 0, 0]), [0., 0., 0.], [], None, [0, 1, 2]
25
+ yield 'trigger-skips-fallback', dict(default, order=[9]), [0., 0., 0.], nearby, 1, []
26
+
27
+
28
+ def main():
29
+ subprocess.run(['cargo', 'build', '--offline', '-p', 'urt-gameplay',
30
+ '--bin', 'urt-location-feedback'], check=True)
31
+ binary = Path(os.environ.get('CARGO_TARGET_DIR', 'target')) / 'debug' / 'urt-location-feedback'
32
+ probes = []
33
+ for case, a, actor, links, selected, pvs in cases():
34
+ words = encode(a)
35
+ operations = [w for slot, x in links for w in (slot, word(x), 0, 0, word(x), 0, 0)]
36
+ args = [len(words), *words, *map(word, actor), *operations]
37
+ bounds = [[word(x + sign * radius) for x, radius in zip(actor, (40., 40., 52.))]
38
+ for sign in (-1, 1)]
39
+ expected = dict(selected=selected, queries=[] if case == 'cache' else [bounds],
40
+ pvs=pvs, cache=a['cache'])
41
+ probes.append(dict(case=case, expected=expected, rust=result(binary, 'nearest-linked', args)))
42
+ write_json(Path('docs/research/rust-linked-location.json'), {
43
+ 'probes': probes,
44
+ 'limits': 'Rust composition fixtures for linked box candidates. Fallback PVS is supplied by the fixture.',
45
+ })
46
+
47
+
48
+ if __name__ == '__main__':
49
+ main()
scripts/test_rust_linked_location.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import unittest
3
+ from pathlib import Path
4
+
5
+
6
+ class LinkedLocationTests(unittest.TestCase):
7
+ def test_linked_lookup(self):
8
+ rows = json.loads(Path('docs/research/rust-linked-location.json').read_text())['probes']
9
+ self.assertEqual(len(rows), 9)
10
+ for row in rows:
11
+ with self.subTest(case=row['case']):
12
+ self.assertEqual(row['rust'], row['expected'])
13
+
14
+
15
+ if __name__ == '__main__':
16
+ unittest.main()
xtask/checks.tsv CHANGED
@@ -4889,3 +4889,14 @@ group gameplay scripts/analyze_rust_spatial_index.py
4889
  edge crates/urt-gameplay/src/spatial_index.rs scripts/analyze_rust_spatial_index.py
4890
  edge crates/urt-gameplay/src/bin/urt-spatial-index.rs scripts/analyze_rust_spatial_index.py
4891
  edge crates/urt-gameplay/src/spatial_index.rs scripts/analyze_rust_health_impulse.py
 
 
 
 
 
 
 
 
 
 
 
 
4889
  edge crates/urt-gameplay/src/spatial_index.rs scripts/analyze_rust_spatial_index.py
4890
  edge crates/urt-gameplay/src/bin/urt-spatial-index.rs scripts/analyze_rust_spatial_index.py
4891
  edge crates/urt-gameplay/src/spatial_index.rs scripts/analyze_rust_health_impulse.py
4892
+ report scripts/analyze_rust_linked_location.py docs/research/rust-linked-location.json
4893
+ edge docs/research/rust-linked-location.json scripts/test_rust_linked_location.py
4894
+ group rust-linked-location scripts/analyze_rust_linked_location.py
4895
+ group rust-linked-location scripts/analyze_rust_location_nearest.py
4896
+ group rust-linked-location scripts/analyze_rust_location_radio.py
4897
+ group gameplay scripts/analyze_rust_linked_location.py
4898
+ edge crates/urt-gameplay/src/location_feedback.rs scripts/analyze_rust_linked_location.py
4899
+ edge crates/urt-gameplay/src/spatial_index.rs scripts/analyze_rust_linked_location.py
4900
+ edge crates/urt-gameplay/src/bin/urt-location-feedback.rs scripts/analyze_rust_linked_location.py
4901
+ edge crates/urt-gameplay/src/bin/support/located_radio.rs scripts/analyze_rust_linked_location.py
4902
+ edge crates/urt-gameplay/src/bin/support/located_radio.rs scripts/analyze_rust_location_nearest.py