// Generates a random chess game use owlchess::{ chain::{GameStatusPolicy, NumberPolicy}, movegen::legal, moves::Style, types::OutcomeFilter, MoveChain, }; use rand::{self, seq::SliceRandom}; fn main() { let mut chain = MoveChain::new_initial(); let mut rng = rand::thread_rng(); while !chain.is_finished() { // Generate all the legal moves let moves = legal::gen_all(chain.last()); // Pick random move and push it into chain let mv = moves .choose(&mut rng) .expect("no legal moves in this position"); chain .push(*mv) .expect("cannot make move generated by legal::gen_all()"); // Verify game outcome chain.set_auto_outcome(OutcomeFilter::Strict); } // Print the results println!( "{} {{{}}}", chain.styled(NumberPolicy::FromBoard, Style::San, GameStatusPolicy::Show), chain.outcome().unwrap(), ); }