[moves, position] Improve the error messages when asserting during legal move generation
The move generators should only generate moves that can be made, so calling make_move() and unmake_move() should never give an error during legal move generation. Both of these calls assert that the result is not an Err(). Improve the error messaging so that they log the move, the current board position, and the error message. Highlight the squares relevant to the move (origin, target, and capture) when printing the board.
This commit is contained in:
parent
a9674e3215
commit
8fd7ffa586
2 changed files with 26 additions and 4 deletions
|
@ -1,6 +1,7 @@
|
|||
// Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
use crate::defs::{Kind, PromotionShape};
|
||||
use chessfriend_bitboard::BitBoard;
|
||||
use chessfriend_core::{Rank, Shape, Square, Wing};
|
||||
use std::fmt;
|
||||
|
||||
|
@ -215,6 +216,19 @@ impl Move {
|
|||
}
|
||||
}
|
||||
|
||||
impl Move {
|
||||
pub fn relevant_squares(&self) -> BitBoard {
|
||||
[
|
||||
Some(self.origin_square()),
|
||||
Some(self.target_square()),
|
||||
self.capture_square(),
|
||||
]
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
||||
impl Move {
|
||||
fn transfer_char(self) -> char {
|
||||
if self.is_capture() || self.is_en_passant() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue