dannyhammer / brogle

I felt like writing a chess engine. So I did.
2 stars 0 forks source link

Strange move generation bug when creating positions in checkmate #13

Open dannyhammer opened 2 months ago

dannyhammer commented 2 months ago

Given the following position: 1k6/1Q6/K7/8/8/8/8/8 w - - 0 1, brogle seems to think b7b8 is a legal move. which obviously isn't, since it captures k.

This manifests itself with the following stacktracek:

go
Moving Q b7->b8 # debug print
thread '<unnamed>' panicked at brogle_core/src/movegen.rs:817:9:
index out of bounds: the len is 64 but the index is 64
stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic_bounds_check
   3: brogle_core::movegen::MoveGenerator::generate_legal
   4: brogle_core::position::Game::make_move
   5: brogle_core::position::Game::with_move_made
   6: brogle::search::searcher::Searcher::start
   7: <F as threadpool::FnBox>::call_box
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

because, apparently, after moving Q there, k gets placed at a9?