[d] r2qkbnr/1pp1pppp/2np4/pB6/3PP1b1/2N2N2/PPP2PPP/R1BQK2R b KQkq - 2 5
In this position Skipper needs almost a second to find a good move against a pin. Isn't there a way to get it quicker without slowing down search. I remember a year ago I implemented pin detection but performance degraded so I removed it.
I think that it is better if Skipper learn the chess rules
g4f3 g2f3 c6d4 is the line at depth 3.
c6d4 is an illegal move.
If your move generator generates c6d4 then I think that it is better to correct it and your program should memorize information about pinned pieces and not generate moves with a knight that is pinned(You need also to update the information after every move that you make).
Henk wrote:Something wrong here. I already don't understand why it does give totally wrong score at depth 1.
It looks like if you don't have quiescence search or SEE is wrong. At ply 1, taking the knight would give you +3 only if you don't take care of following recapture.
Bitboard Board::hidden_checkers(bool find_pins, int color) const
{
assert(initialized && color_ok(color) && (find_pins == 0 || find_pins == 1));
const int aside = color ^ find_pins, kside = opp_color(aside);
Bitboard result = 0ULL, pinners;
// Pinned pieces protect our king, dicovery checks attack the enemy king.
const int ksq = king_pos[kside];
// Pinners are only sliders with X-ray attacks to ksq
pinners = (get_RQ(aside) & bb::rattacks(ksq)) | (get_BQ(aside) & bb::battacks(ksq));
while (pinners) {
int sq = bb::pop_lsb(&pinners);
Bitboard skewered = (bb::between(ksq, sq) ^ (1ULL << sq)) & st().occ;
if (!bb::several_bits(skewered) && (skewered & all[color]))
result |= skewered;
}
return result;
}
Basically is counting the pieces between the possible checkers (sliders aligned with the king), and if there is one of the same color of the king, then is pinned.
I use this technique in Andscacs not one but three times in each node, to search for pinned pieces of each player, and to discover pieces tan can make discovered check. This makes easy and fast to find illegal moves also.
Henk wrote:Something wrong here. I already don't understand why it does give totally wrong score at depth 1.
It looks like if you don't have quiescence search or SEE is wrong. At ply 1, taking the knight would give you +3 only if you don't take care of following recapture.
Yes very stupid bug in qSearch. I already repaired it. Forgot to call the move generator. I reintroduced qSearch this morning. But I was not careful. Before this qSearch and normal search were one routine for I wanted to have as less code as possible. Less code less bugs.
But still there is another bug, for PV at depth 4 is idiotic. Perhaps evaluation for I changed king safety too lately.
Henk wrote:Before this qSearch and normal search were one routine for I wanted to have as less code as possible. Less code less bugs.
I did that for a very long time as well, but eventually splited it out to a different function. As you add more and more things to search, you'll find that many of them don't really make sense for q-search, so you'd need to add a lot of if statements. At that point the code would be simpler if you just separate out the q-search.
Less code less bugs, but less complicated code also less bugs, and in this case less code means more complicated code.
Disclosure: I work for DeepMind on the AlphaZero project, but everything I say here is personal opinion and does not reflect the views of DeepMind / Alphabet.
Henk wrote:[d] 1n2q1k1/rb2n1p1/1p1p2Np/pP3B2/P2P1r2/2N5/2P1Q1PP/2KR3R b - - 3 25
Do you also check other pins ? For instance in position above knight on e7 can not move otherwise it loses it's queen.
So there are minor pieces that shield major pieces or pieces that shield undefended pieces but cannot defend the undefended pieces when chased away.
This is typically where your (quiescence) search is for, to resolve this kind of tactical stuff.
It is impossible to solve this in a static evaluation function because it is way too complex or too time consuming.
Henk wrote:[d] 1n2q1k1/rb2n1p1/1p1p2Np/pP3B2/P2P1r2/2N5/2P1Q1PP/2KR3R b - - 3 25
Do you also check other pins ? For instance in position above knight on e7 can not move otherwise it loses it's queen.
So there are minor pieces that shield major pieces or pieces that shield undefended pieces but cannot defend the undefended pieces when chased away.
This is typically where your (quiescence) search is for, to resolve this kind of tactical stuff.
It is impossible to solve this in a static evaluation function because it is way too complex or too time consuming.
Maybe give a penalty if a piece is undefended in middle game. But that may also be too costly.