jordanbray / chess

A rust library to manage chess move generation
https://jordanbray.github.io/chess/
MIT License
231 stars 54 forks source link

MoveGen throws an IlleganSanMove for a legal move #79

Closed cbeust closed 1 year ago

cbeust commented 1 year ago

This test fails with

Found f1b5 as a legal move
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: InvalidSanMove', src\main.rs:28:63
    fn test() {
        let move_string = "f1b5";
        let board_string: &str = "rnbqkbnr/p1pppppp/8/1p6/4P3/8/PPPP1PPP/RNBQKBNR w KQkq - 0 1";
        let board = Board::from_str(board_string).unwrap();
        let legal_moves = MoveGen::new_legal(&board);
        for legal in legal_moves {
            if legal.to_string() == move_string {
                println!("Found {} as a legal move", move_string);
            }
        }
        let chess_move = ChessMove::from_san(&board, move_string).unwrap();
    }

You can see that f1b5 is listed as a valid move and yet, from_san() returns an Err.

cbeust commented 1 year ago

Confused from_san and from_str... doh.