//! Read layer on real villains (plan D1c): one wire-form profile object per stdin line, decoded as a //! live request's `villains[].profile`, then `exploit::range_read::RangeRead`. Prints one tab line //! per profile: tilt, bluff share river (pot bet / 2/3 pot), fold river, confidence, bluff trust //! river, or `-` without a read. //! //! messung/zaehlung/range_read.py writes the profiles and reads this back. use rechner::exploit::range_read::RangeRead; use std::io::BufRead; fn main() { let stdin = std::io::stdin(); for line in stdin.lock().lines() { let Ok(line) = line else { break }; let text = format!("{{\"villains\":[{{\"seat\":1,\"stack\":100,\"folded\":false,\"profile\":{}}}]}}", line.trim()); let profile = rechner::json::parse::parse(&text) .ok() .and_then(|root| rechner::wire::decode_villain::villains(&root).ok()) .and_then(|v| v.into_iter().next()) .and_then(|v| v.profile); match RangeRead::from_profile(profile.as_ref()) { Some(r) => println!( "{:.4}\t{:.4}\t{:.4}\t{}\t{:.4}\t{:.4}", r.tilt, r.bluff_share(2, 1.0), r.bluff_share(2, 0.66), r.fold_to_bet(2).map_or("-".to_string(), |f| format!("{f:.4}")), r.confidence, r.trust(true, 2) ), None => println!("-"), } } }