jordanbray/chess

bug in can_declare_draw()

Closed this issue · 2 comments

There is a bug in Game::can_declare_draw()

#[test]
pub fn test_can_declare_draw(){
    let moves = 
               "1. Nc3 d5 2. e3 Nc6 3. Nf3 Nf6 4. Bb5 a6 5. Bxc6+ bxc6 6. Ne5 Qd6 7. d4 Nd7
                8. f4 Nxe5 9. dxe5 Qg6 10. O-O Bf5 11. e4 Bxe4 12. Nxe4 Qxe4 13. Re1 Qb4
                14. e6 f6 15. Be3 g6 16. Qd4 Qxd4 17. Bxd4 Bh6 18. g3 g5 19. f5 g4 20. Rad1
                Rg8 21. b3 Rb8 22. c4 dxc4 23. bxc4 Rd8 24. Kg2 Rc8 25. Bc5 Rg5 26. Rd7 Bf8
                27. Rf1 a5 28. Kg1 a4 29. Bb4 Rh5 30. Rf4 Rg5 31. Rf1 Rh5 32. Rf4 Rg5 33.
                Ba5";
    let game = moves.split_whitespace()
        .filter(|s| !s.ends_with("."))
        .fold(Game::new(), |mut g, m| {g.make_move(san_move_to_move(&g.current_position(),m)); g});
    assert!(!game.can_declare_draw());
}

It thinks a draw can be declared after 33. Ba5, but that is not the case.

This is resolved in the version on github.

Additionally, ChessMove::from_san( has been added which takes the same arguments as your san_move_to_move

Great. I'll check it out.