I was trying to implement some new feature inside my engine and I can't make futility and razoring work inside my engine.
Today I have noticed that Cheng engine does futility and razoring only inside Null Windows search, is this approach correct??
futility pruining, razoring question
Moderators: hgm, Rebel, chrisw
-
- Posts: 20943
- Joined: Mon Feb 27, 2006 7:30 pm
- Location: Birmingham, AL
Re: futility pruining, razoring question
It should work everywhere if it works anywhere. You might tune/refine it later, but it should work everywhere and produce an improvement, unless you have other issues...elcabesa wrote:I was trying to implement some new feature inside my engine and I can't make futility and razoring work inside my engine.
Today I have noticed that Cheng engine does futility and razoring only inside Null Windows search, is this approach correct??
-
- Posts: 373
- Joined: Wed Mar 22, 2006 10:17 am
- Location: Novi Sad, Serbia
- Full name: Karlo Balla
Re: futility pruining, razoring question
What are your latest findings about the futility and/or razoring?bob wrote:It should work everywhere if it works anywhere. You might tune/refine it later, but it should work everywhere and produce an improvement, unless you have other issues...elcabesa wrote:I was trying to implement some new feature inside my engine and I can't make futility and razoring work inside my engine.
Today I have noticed that Cheng engine does futility and razoring only inside Null Windows search, is this approach correct??
Best Regards,
Karlo Balla Jr.
Karlo Balla Jr.
-
- Posts: 1822
- Joined: Thu Mar 09, 2006 11:54 pm
- Location: The Netherlands
Re: futility pruining, razoring question
You're razoring the mainline nowadays?bob wrote:It should work everywhere if it works anywhere. You might tune/refine it later, but it should work everywhere and produce an improvement, unless you have other issues...elcabesa wrote:I was trying to implement some new feature inside my engine and I can't make futility and razoring work inside my engine.
Today I have noticed that Cheng engine does futility and razoring only inside Null Windows search, is this approach correct??
That'll get you quickly to 100 ply search depth i bet
p.s. if you razor at random, can you claim then having added MonteCarlo+UCT to your program in an 'optimized manner'?
-
- Posts: 3232
- Joined: Mon May 31, 2010 1:29 pm
- Full name: lucasart
Re: futility pruining, razoring question
here's my razoring code. it's a little uncommon as I reduce instead of pruning (and prune when horizon reached). but this seems to work much better than pruning
razor parameters
MP is the value of a pawn in the middlegame. the RazorMargin formula is just a guess (no optimization done). And given that constraint, it appeared that RazorDepth == 3 was best.
in the main search
as for futility pruning, I don't think what I do is really good. I need to do more experiment on it.
razor parameters
Code: Select all
const bool UseRazoring = true;
static const int RazorDepth = 3;
static inline int RazorMargin(int depth) {
assert(1 <= depth && depth <= RazorDepth);
return 2*MP + (depth-1)*MP/4;
}
in the main search
Code: Select all
// Razoring
if (UseRazoring && depth <= RazorDepth
&& !is_pv && !is_mate_score(beta) && !in_check)
{
if (current_eval + RazorMargin(depth) <= alpha) {
const int score = qsearch(B, alpha, beta, 0, ply+1, is_pv, si+1);
if (score <= alpha && --depth <= 0)
return score;
}
}
Last edited by lucasart on Fri Apr 06, 2012 5:36 am, edited 1 time in total.
-
- Posts: 2555
- Joined: Fri Nov 26, 2010 2:00 pm
- Location: Czech Republic
- Full name: Martin Sedlak
Re: futility pruining, razoring question
Yes it's true. Note that I recently fixed a bug in razoring. For no elo gain as usual of course. qsearch alpha-razormargin, beta-razormargin then compare to beta-razormargin is correct (fixed tactical blindness in some testpositions).elcabesa wrote:I was trying to implement some new feature inside my engine and I can't make futility and razoring work inside my engine.
Today I have noticed that Cheng engine does futility and razoring only inside Null Windows search, is this approach correct??
Honestly cheng is NOT a good reference of how things should be done (bugs, source not readable) but in general you don't want to do futility/nullmove in PV nodes. I also recently removed upper/lower (alpha/beta) TT pruning in PV nodes. Null window search in cheng => non-PV => All/Cut nodes.
-
- Posts: 2555
- Joined: Fri Nov 26, 2010 2:00 pm
- Location: Czech Republic
- Full name: Martin Sedlak
Re: futility pruining, razoring question
PS I believe this (common?) razoring mistake (scouting around alpha instead of alpha-razormargin) comes from chessprogramming wiki and should be fixed. When I think about it it doesn't make sense. First compare eval to beta-margin then scout around alpha?!!
Why no elo gain (for me at least) => I guess because fixing it will razor much less nodes. Btw. I certainly wouldn't want to analyse a position with this bug
Why no elo gain (for me at least) => I guess because fixing it will razor much less nodes. Btw. I certainly wouldn't want to analyse a position with this bug
-
- Posts: 2555
- Joined: Fri Nov 26, 2010 2:00 pm
- Location: Czech Republic
- Full name: Martin Sedlak
Re: futility pruining, razoring question
As for futility: never had problem with that and seems pretty stable.
Futility simply prunes (ignores) certain moves at nodes where eval+margin is below beta in scout search.
In general:
-never do futility when evading a check
-don't skip potentially good/dangerous moves: hashmove, captures, promotions, castling, checks, killers and in general any moves you want to extend
perhaps good history moves shouldn't be skipped as well but i don't do that in cheng; i also don't prune passer pushes
PS hashmove, captures, castling and killers boil down to "do futility after the killers phase in movegen"
Futility simply prunes (ignores) certain moves at nodes where eval+margin is below beta in scout search.
In general:
-never do futility when evading a check
-don't skip potentially good/dangerous moves: hashmove, captures, promotions, castling, checks, killers and in general any moves you want to extend
perhaps good history moves shouldn't be skipped as well but i don't do that in cheng; i also don't prune passer pushes
PS hashmove, captures, castling and killers boil down to "do futility after the killers phase in movegen"
-
- Posts: 2684
- Joined: Sat Jun 14, 2008 9:17 pm
Re: futility pruining, razoring question
Well, clearly razoring has no sense in PV (even theoretically) . Near leaves of PV you expect value to be above alpha, and in case you find a fail low at next iteration you really don't want to find it through razoring. But I suspect Bob was referring to something else than all of us: normally I use chessprogramming as a name reference, but I think he is using other references and probably with 'razoring' he is referring to forward pruning or something like that.
Regarding Luca's code I find this:
a really optimistic assumption, normally you want to verify with a reduced margin, not with alpha. If this was also in your original code, perhaps could be a reason why it didn't work for you and so you switched to a kind of reduction instead of pruning.
Regarding Luca's code I find this:
Code: Select all
const int score = qsearch(B, alpha, beta, 0, ply+1, is_pv, si+1);
-
- Posts: 3232
- Joined: Mon May 31, 2010 1:29 pm
- Full name: lucasart
Re: futility pruining, razoring question
You're right. As pointed out by Martin, I got fooled by the chess programming wikimcostalba wrote:Well, clearly razoring has no sense in PV (even theoretically) . Near leaves of PV you expect value to be above alpha, and in case you find a fail low at next iteration you really don't want to find it through razoring. But I suspect Bob was referring to something else than all of us: normally I use chessprogramming as a name reference, but I think he is using other references and probably with 'razoring' he is referring to forward pruning or something like that.
Regarding Luca's code I find this:
a really optimistic assumption, normally you want to verify with a reduced margin, not with alpha. If this was also in your original code, perhaps could be a reason why it didn't work for you and so you switched to a kind of reduction instead of pruning.Code: Select all
const int score = qsearch(B, alpha, beta, 0, ply+1, is_pv, si+1);
I'm currently testing this alternative:
Code: Select all
if (UseRazoring && depth <= RazorDepth
&& !is_pv && !is_mate_score(beta) && !in_check)
{
if (current_eval + RazorMargin(depth) <= alpha) {
const int score = qsearch(B, alpha, beta, 0, ply+1, is_pv, si+1);
if (score + RazorMargin(depth) <= alpha) //**
return score;
}
}