void Move::set( ColorType color, SquareType from, SquareType to,
PieceType piece, PieceType capture,
PromotionType promotion
)
{
ASSERT_MOVE( color == White || color == Black, "Error: bad color in Move::set()" )
ASSERT_MOVE( from >= 0 && from < 64, "Error: bad from in Move::set()" )
ASSERT_MOVE( to >= 0 && to < 64, "Error: bad to in Move::set()" )
ASSERT_MOVE( piece >= Pawn && piece < 8, "Error: bad piece in Move::set()" )
ASSERT_MOVE( capture >= NoPiece && capture != King && capture < 8, "Error: bad capture in Move::set()" )
ASSERT_MOVE( promotion <= PromoteToKnight, "Error: bad promotion in Move::set()" )
move_ = from | (to << 6) | (promotion << 12) | (piece << 14) | (capture << 17) | (color << 20);
}
This is pointless. Just clutters the code for no reason.
Assert already prints the source file name and line when it fires.
Theory and practice sometimes clash. And when that happens, theory loses. Every single time.
void Move::set( ColorType color, SquareType from, SquareType to,
PieceType piece, PieceType capture,
PromotionType promotion
)
{
ASSERT_MOVE( color == White || color == Black, "Error: bad color in Move::set()" )
ASSERT_MOVE( from >= 0 && from < 64, "Error: bad from in Move::set()" )
ASSERT_MOVE( to >= 0 && to < 64, "Error: bad to in Move::set()" )
ASSERT_MOVE( piece >= Pawn && piece < 8, "Error: bad piece in Move::set()" )
ASSERT_MOVE( capture >= NoPiece && capture != King && capture < 8, "Error: bad capture in Move::set()" )
ASSERT_MOVE( promotion <= PromoteToKnight, "Error: bad promotion in Move::set()" )
move_ = from | (to << 6) | (promotion << 12) | (piece << 14) | (capture << 17) | (color << 20);
}
This is pointless. Just clutters the code for no reason.
Assert already prints the source file name and line when it fires.
Those are pretty bad examples, but sometimes you do want to have a message to go with the assert. I have seen this trick used before: