use ogdoad::forms::{fit_f2_quadratic, QuadricFit};
use ogdoad::games::loopy_decision_sets;
mod common;
use common::{gold, polar};
fn radical(a: u128, m: u128) -> Vec<u128> {
let n = 1u128 << m;
(0..n)
.filter(|&v| (0..n).all(|d| polar(v, d, a, m) == 0))
.collect()
}
fn name_fit(fit: &Option<QuadricFit>) -> String {
match fit {
Some(f) if f.is_genuinely_quadratic() => {
format!("quadric (Arf={}, rank={})", f.arf.arf, f.arf.rank)
}
Some(_) => "affine/linear (subspace coset)".to_string(),
None => "not a quadric".to_string(),
}
}
fn run(m: u128, a: u128) {
let k = m as usize;
let n = 1usize << k;
let zero: Vec<u128> = (0..n as u128).filter(|&v| gold(v, a, m) == 0).collect();
let rad = radical(a, m);
let (loss, draw) = loopy_decision_sets(n, |v| {
(1..n)
.filter(|&d| polar(v as u128, d as u128, a, m) == 1)
.map(|d| v ^ d)
.collect()
});
let loss_u: Vec<u128> = loss.iter().map(|&v| v as u128).collect();
let draw_u: Vec<u128> = draw.iter().map(|&v| v as u128).collect();
println!(
"F_2^{m}, Gold Q_{a}: |{{Q=0}}|={} |R(B)|={}",
zero.len(),
rad.len()
);
println!(
" symmetric B-coupling: |Loss|={} |Draw|={}",
loss.len(),
draw.len()
);
println!(
" Loss-set = R(B)? {} Loss-set = {{Q=0}}? {}",
loss_u == rad,
loss_u == zero
);
println!(
" Loss-set is a {}",
name_fit(&fit_f2_quadratic(&loss_u, k))
);
println!(
" Draw-set is a {}",
name_fit(&fit_f2_quadratic(&draw_u, k))
);
}
fn main() {
println!("Loopy (cyclic) B-only rules — both flip directions, so Draws appear.\n");
println!("(m,a)=(4,1): the radical coincidentally equals {{Q=0}} —");
run(4, 1);
println!("\n(m,a)=(8,1): the coincidence breaks — Loss is still R(B), not {{Q=0}} —");
run(8, 1);
println!("\nConclusion. The symmetric B-only loopy rule detects R(B), the radical — at");
println!("(4,1) that equals {{Q=0}} (4 points each), at (8,1) it does not (|R(B)|=4 vs");
println!("|{{Q=0}}|=112). R(B) is precisely where the Sp(B) frame-blind no-go is silent, so");
println!("the loopy instrument reproduces the obstruction rather than escaping it. The open");
println!("question stands; the Draw-set is now a first-class target the probes can sweep.");
}