1use atomic_movegen::board::Board;
2use atomic_movegen::movegen;
3use atomic_movegen::types::sq_str;
4use atomic_movegen::types::MoveList;
5use std::env;
6
7fn main() {
8 atomic_movegen::attacks::init();
9 let args: Vec<String> = env::args().collect();
10 if args.len() < 2 {
11 eprintln!("Usage: list_moves <fen>");
12 return;
13 }
14 let fen = &args[1];
15 let board = Board::from_fen(fen).expect("Invalid FEN");
16
17 let mut moves = MoveList::new();
18 movegen::generate_legal(&board, &mut moves);
19 moves
20 .as_mut_slice()
21 .sort_by_key(|m| (m.from_sq() as u16, m.to_sq() as u16));
22
23 println!("Legal moves ({} total):", moves.len());
24 for &m in moves.as_slice() {
25 println!(" {}{}", sq_str(m.from_sq()), sq_str(m.to_sq()));
26 }
27}