Oregami
Repositories/oxedyne/ore

oxedyne/ore/oracle/src/bin/debug1.rs

2.0 KiB, 1 run

created by r2848102244:53, which is this file's identity for as long as the history lasts, whatever it is later renamed to

download · who wrote it · its history

1//! Ad hoc: reproduce a failing stage two seed and name the missing byte.
2
3use ore_oracle::doc::{
4 Bind,
5 Doc,
6 Mode,
7};
8use ore_oracle::id::ContentId;
9use ore_oracle::op::Op;
10use ore_oracle::stage2;
11
12use std::collections::HashSet;
13
14use oxedyne_fe2o3_core::prelude::*;
15
16fn main() {
17 match run() {
18 Ok(()) => {},
19 Err(e) => println!("FAILED: {}", e),
20 }
21}
22
23fn run() -> Outcome<()> {
24 let seed: u64 = std::env::args().nth(1)
25 .and_then(|s| s.parse().ok())
26 .unwrap_or(1007);
27 let ops = res!(stage2::collect(seed, Mode::ClaimRegister, Bind::LeftBias, 4, 12, 3, true));
28 let mut d = Doc::with_bind(Mode::ClaimRegister, Bind::LeftBias);
29 for op in &ops {
30 d.apply(op.clone());
31 }
32 let r = res!(d.render());
33 let mut live: HashSet<ContentId> = HashSet::new();
34 let mut dead: HashSet<ContentId> = HashSet::new();
35 for op in &ops {
36 if let Op::Splice { id, remove, insert, .. } = op {
37 for k in 0..insert.len() {
38 live.insert(ContentId::new(*id, k as u32));
39 }
40 for rr in remove {
41 for cid in rr.ids() {
42 dead.insert(cid);
43 }
44 }
45 }
46 }
47 let shown: HashSet<ContentId> = r.prov.iter().copied().collect();
48 println!("live {} dead {} shown {}", live.len(), dead.len(), shown.len());
49 for pi in &r.pieces {
50 if !pi.visited {
51 println!("UNVISITED piece {}+{} claim {}", pi.place_op, pi.sub, pi.claim);
52 }
53 }
54 for cid in &live {
55 if !dead.contains(cid) && !shown.contains(cid) {
56 println!("missing {}", cid);
57 for pi in &r.pieces {
58 if pi.claim.contains(cid) {
59 println!(" covered by piece {}+{} claim {} emitted {} \
60 visited {}",
61 pi.place_op, pi.sub, pi.claim, pi.emitted, pi.visited);
62 }
63 }
64 for op in &ops {
65 match op {
66 Op::Move { id, src, .. } => {
67 if src.iter().any(|s| s.contains(cid)) {
68 println!(" claimed by move {} src {:?}", id, src);
69 }
70 },
71 Op::Splice { id, left, right, remove, insert } => {
72 if cid.op == *id {
73 println!(" created by splice {} len {} left {:?} \
74 right {:?} remove {:?}",
75 id, insert.len(), left, right, remove);
76 }
77 },
78 }
79 }
80 }
81 }
82 Ok(())
83}