Page 1 of 3
QSearch perft
Posted: Fri May 24, 2019 12:36 pm
by Henk
I try to find out if my quiescence search does not accidentally skip moves.
So I extracted a perft out of that code. It does only promotions, captures and en passant moves.
Result for kiwiPete: "r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq - 0 1"
depth 4: 3980
depth 5: 25800
Don't know if these figures are correct.
Are there any other perft figures published/posted for quiescence search ?
Re: QSearch perft
Posted: Fri May 24, 2019 1:04 pm
by xr_a_y
You dont generate check evasion so are you stoping when King is captured ?
Re: QSearch perft
Posted: Fri May 24, 2019 1:13 pm
by Henk
If king is captured it was an illegal move so it returns 0. Just like a normal perft definition but limited to performing only legal captures, promotions and en passant moves.
Re: QSearch perft
Posted: Fri May 24, 2019 2:03 pm
by Joost Buijs
Henk,
With only captures and promotions (and check evasions) I get on kiwipete:
Depth 4 = 3690
Depth 5 = 25347
So my numbers are different, maybe something wrong with your enpassant captures?
Of course there is a possibility that my perft() is in error, but I doubt it.
Re: QSearch perft
Posted: Fri May 24, 2019 2:27 pm
by Henk
Strange my code does ep moves. Can't find it. Or maybe minor promotions. Don't know yet.
I created an extra QPerft with code that collects captures, promotions and ep moves similar to code used in my normal perft test giving standard values for kiwi pete 4 and 5 so that code must be correct. But QPerft getting same figures as posted.
Simpel QPerft:
Code: Select all
public static ulong Perft2(IChessPosition position, int depth, bool epMoves = true)
{
var moves = new List<IMoveBase>();
position.CollectCaptures(moves, depth, epMoves); // collects captures, epmoves, promotions
if (depth == 1) return (ulong)moves.Count;
ulong count = 0;
var board = position.Board;
var other = board.Other;
foreach (MoveBase mv in moves)
{
var field = mv.GetCaptureLocation(position);
var capture = field == 0 ? none : board.PieceSort(field);
mv.Apply(position);
count += Perft2(position, depth - 1, true); //board.PieceKind(mv.End) == Pawn_Kind);
mv.TakeBack(position, capture, field, other);
}
return count;
}
Re: QSearch perft
Posted: Fri May 24, 2019 2:43 pm
by Joost Buijs
These are the counts I get per move at depth 4, maybe it helps.
g2h3: 381
d5e6: 436
e5g6: 495
e5d7: 642
e5f7: 475
e2a6: 343
f3h3: 397
f3f6: 521
Maybe somebody else can verify these numbers.
I think the difference is due to the fact that you don't generate check-evasions, because check-evasions will contain non captures too. So you have to generate evasions when the king is in check. You have to do this in quiescence too, otherwise your quiescence will make very big errors.
Re: QSearch perft
Posted: Fri May 24, 2019 2:59 pm
by Henk
Henk wrote: ↑Fri May 24, 2019 2:27 pm
Strange my code does ep moves. Can't find it. Or maybe minor promotions. Don't know yet.
I created an extra QPerft with code that collects captures, promotions and ep moves similar to code used in my normal perft test giving standard values for kiwi pete 4 and 5 so that code must be correct. But QPerft getting same figures as posted.
Simpel QPerft:
Code: Select all
public static ulong Perft2(IChessPosition position, int depth, bool epMoves = true)
{
var moves = new List<IMoveBase>();
position.CollectCaptures(moves, depth, epMoves); // collects captures, epmoves, promotions
if (depth == 1) return (ulong)moves.Count;
ulong count = 0;
var board = position.Board;
var other = board.Other;
foreach (MoveBase mv in moves)
{
var field = mv.GetCaptureLocation(position);
var capture = field == 0 ? none : board.PieceSort(field);
mv.Apply(position);
count += Perft2(position, depth - 1, true); //board.PieceKind(mv.End) == Pawn_Kind);
mv.TakeBack(position, capture, field, other);
}
return count;
}
Wait this code can't be correct for CollectCaptures does not check whether move is legal (it may place king in check)
I first have to change that. But then I expect the figures to be even lower then I posted before.
Re: QSearch perft
Posted: Fri May 24, 2019 3:12 pm
by Henk
Joost Buijs wrote: ↑Fri May 24, 2019 2:03 pm
Henk,
With only captures and promotions (and check evasions) I get on kiwipete:
Depth 4 = 3690
Depth 5 = 25347
So my numbers are different, maybe something wrong with your enpassant captures?
Of course there is a possibility that my perft() is in error, but I doubt it.
Now I get:
Depth 4 = 3622
Depth 5 = 24467
Re: QSearch perft
Posted: Fri May 24, 2019 3:20 pm
by Joost Buijs
You really have to generate check-evasions when the king is in check (blocking moves and king moves to get out of check) if you want to be correct.
Unfortunately I have to modify my code if I want to do it your way (to check if the king is captured), so it is not straightforward to compare our numbers.
Re: QSearch perft
Posted: Fri May 24, 2019 3:24 pm
by abulmo2
Joost Buijs wrote: ↑Fri May 24, 2019 2:43 pm
These are the counts I get per move at depth 4, maybe it helps.
g2h3: 381
d5e6: 436
e5g6: 495
e5d7: 642
e5f7: 475
e2a6: 343
f3h3: 397
f3f6: 521
Maybe somebody else can verify these numbers.
I think the difference is due to the fact that you don't generate check-evasions, because check-evasions will contain non captures too. So you have to generate evasions when the king is in check. You have to do this in quiescence too, otherwise your quiescence will make very big errors.
I get the same number as you :
Code: Select all
g2h3 381
d5e6 436
e5g6 495
e5d7 642
e5f7 475
e2a6 343
f3h3 397
f3f6 521
total : 3690 leaves
and at depth 5:
Code: Select all
g2h3 2617
d5e6 3202
e5g6 3482
e5d7 4086
e5f7 2908
e2a6 2285
f3h3 2768
f3f6 3999
total : 25347 leaves