Then you're back to square one (or, a1

Moderator: Ras
Then you're back to square one (or, a1
[d]8/4b3/8/3k4/2p5/4Pp2/1K1P1P2/R7 b - - 0 1
Code: Select all
bool Board::ep_capture_gives_discovered_check(Move const & m) const
{
#ifdef _DEBUG
Board boardCopy = *this;
#endif
const_cast<Board *>(this)->patch_forward_to_check_ep_capture(m);
bool result = ...;
const_cast<Board +>(this)->patch_backward_to_check_ep_capture(m);
#ifdef _DEBUG
ASSERT(*this == boardCopy);
#endif
return result;
}
Now i am really confused SVEN?
Code: Select all
const_cast<Board +>(this)
Well, actually there are quite some situations where you would need to cast a this-pointer (think about CRTP or Barton-Nackman). In the code snippet here, it seems to be totally off, I agree. From the looks of it I would guess that the "patch_..." methods maybe aren't const such that the compiler would complain. The cast would fix the compiler-error, but may be quite dangerous, because the problem the compiler was complaining about hasn't gone away. The compiler was just told to shut up about it...
Don't use const_cast for that kind of scenario. If from the outside perspective the instance remains constant, then you should investigate using mutable members instead.
What about discovered checks by pieces unrelated to the move?
At that point, we are back to square one anyway, and have a lot of complicated code for corner cases like discovered check through en passant where the discovering piece is not even the moving piece, but the captured pawn.And when you do have a distant slider alignment, and do the ray scan starting at the king
I want to say that with bitboards you get a lot of this stuff for free (Literally a single and instruction). Including resolving all PINS. That is totally impossible with mailslots....Ras wrote: ↑Wed Nov 24, 2021 12:21 pmWhat about discovered checks by pieces unrelated to the move?
At that point, we are back to square one anyway, and have a lot of complicated code for corner cases like discovered check through en passant where the discovering piece is not even the moving piece, but the captured pawn.And when you do have a distant slider alignment, and do the ray scan starting at the king
However, I have another idea for a pretty simple speed-up of discovering checks in mailbox. In the middlegame, the kings are usually on the 1st resp. 8th rank so that there cannot be checks from behind. Arranging the check verification so that the "from behind" checks come last allows an early return in that case.
This must move over the from-square, and can thus only check when the from-square has queen-alignment with the king. This is why you have to test to-square and from-square. In the presence of hoppers (e.g. Xiangqi Cannon) you also have to test the to-square for hopper-alignment (in addition to alignment of the piece that would land there), as the moved piece could have activated the hopper.
Sure, but the point is that you almost never reach that point.At that point, we are back to square one anyway, ...
Well, this cannot be helped. E.p. capture is an intrinsically more complex move, as it modifies 3 squares instead of 2. Each modified square could in principle cause a check. Evacuated squares can cause discovered checks, occupied squares can either have the occupant check directly or activate a hopper. And squares that change occupant can have an effect, such as a Cannon that gets captured in Janggi, the capturer now acting as mount for another cannon (as Cannons are not allowed to jump over each other there)...., and have a lot of complicated code for corner cases like discovered check through en passant where the discovering piece is not even the moving piece, but the captured pawn.
It still seems you imagine a method of check verification where you scan away from the king in all possible directions. For delivering checks, or testing whether you expose your own king when not in check, this is not very competitive. There are at least 3 directions, and usually 5 or 8. (And then I even ignore knight checks!) So it is better to just test the few directions that lead to modified squares. Only when you start from a position where you already are in check you should account for the possibility that the pieces that were checking are still checking, when testing for legality. (And of course when the moving piece is a king, all these short-cuts are from the table.)However, I have another idea for a pretty simple speed-up of discovering checks in mailbox. In the middlegame, the kings are usually on the 1st resp. 8th rank so that there cannot be checks from behind. Arranging the check verification so that the "from behind" checks come last allows an early return in that case.
That does sound a bit optimistic. What would you want to AND to determine wheter a move given as (fromSqr, toSqr) delivers a check?dangi12012 wrote: ↑Wed Nov 24, 2021 1:04 pmI want to say that with bitboards you get a lot of this stuff for free (Literally a single and instruction). Including resolving all PINS. That is totally impossible with mailslots....