use kish::{Board, GameStatus};
fn main() {
let mut board = Board::new_default();
println!("Starting position:");
println!("{board}");
println!();
let actions = board.actions();
println!("White has {} legal moves:", actions.len());
for action in actions.iter().take(5) {
let detailed = action.to_detailed(board.turn, &board.state);
println!(" {}", detailed.to_notation());
}
if actions.len() > 5 {
println!(" ... and {} more", actions.len() - 5);
}
println!();
println!("Playing some moves:");
let mut move_count = 0;
while board.status() == GameStatus::InProgress && move_count < 10 {
let actions = board.actions();
if actions.is_empty() {
break;
}
let action = &actions[0];
let detailed = action.to_detailed(board.turn, &board.state);
println!(" {}: {}", board.turn, detailed.to_notation());
board.apply_(action);
board.swap_turn_();
move_count += 1;
}
println!();
println!("Position after {move_count} moves:");
println!("{board}");
match board.status() {
GameStatus::InProgress => println!("Game is still in progress"),
GameStatus::Draw => println!("Game ended in a draw"),
GameStatus::Won(team) => println!("Game won by {team}"),
}
}