Dump roc checkmate

This commit is contained in:
Ayaz Hafiz 2023-07-16 15:01:00 -05:00
parent 1282110ef5
commit fcd733e1df
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
8 changed files with 119 additions and 10 deletions

View file

@ -27,6 +27,26 @@ macro_rules! debug_checkmate {
};
}
#[macro_export]
macro_rules! dump_checkmate {
($opt_collector:expr) => {
#[cfg(debug_assertions)]
{
if let Some(cm) = $opt_collector.as_ref() {
$crate::dump_checkmate(cm);
}
}
};
}
pub fn dump_checkmate(collector: &Collector) {
let timestamp = chrono::Utc::now().format("%Y%m%d_%H%M%S");
let filename = format!("checkmate_{timestamp}.json");
let fi = std::fs::File::create(&filename).unwrap();
collector.write(fi).unwrap();
eprintln!("Wrote checkmate output to {filename}");
}
#[macro_export]
macro_rules! with_checkmate {
({ on => $on:expr, off => $off:expr, }) => {{