ChessUSA.com TalkChess.com
Hosted by Your Move Chess & Games
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

futility pruining, razoring question
Goto page 1, 2, 3, 4  Next
 
Post new topic       TalkChess.com Forum Index -> Computer Chess Club: Programming and Technical Discussions Threaded
View previous topic :: View next topic  
Author Message
Marco Belli



Joined: 23 May 2010
Posts: 96

PostPosted: Wed Apr 04, 2012 6:21 pm    Post subject: futility pruining, razoring question Reply to topic Reply with quote

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??
Back to top
View user's profile Send private message
Robert Hyatt



Joined: 27 Feb 2006
Posts: 15819
Location: Birmingham, AL

PostPosted: Thu Apr 05, 2012 7:07 pm    Post subject: Re: futility pruining, razoring question Reply to topic Reply with quote

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??


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...
Back to top
View user's profile Send private message
Karlo Bala Jr.



Joined: 22 Mar 2006
Posts: 195
Location: Novi Sad, Serbia

PostPosted: Thu Apr 05, 2012 7:59 pm    Post subject: Re: futility pruining, razoring question Reply to topic Reply with quote

bob wrote:
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??


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...


What are your latest findings about the futility and/or razoring?
_________________
Best Regards,
Karlo Bala Jr.
Back to top
View user's profile Send private message Send e-mail
Vincent Diepeveen



Joined: 09 Mar 2006
Posts: 1738
Location: The Netherlands

PostPosted: Thu Apr 05, 2012 11:47 pm    Post subject: Re: futility pruining, razoring question Reply to topic Reply with quote

bob wrote:
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??


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...


You're razoring the mainline nowadays?

That'll get you quickly to 100 ply search depth i bet Smile

p.s. if you razor at random, can you claim then having added MonteCarlo+UCT to your program in an 'optimized manner'?
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Lucas Braesch



Joined: 31 May 2010
Posts: 1757

PostPosted: Fri Apr 06, 2012 3:34 am    Post subject: Re: futility pruining, razoring question Reply to topic Reply with quote

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
Code:

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;
}

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
Code:

   // 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;
      }
   }

as for futility pruning, I don't think what I do is really good. I need to do more experiment on it.


Last edited by Lucas Braesch on Fri Apr 06, 2012 3:36 am; edited 1 time in total
Back to top
View user's profile Send private message
Martin Sedlak



Joined: 26 Nov 2010
Posts: 701

PostPosted: Fri Apr 06, 2012 3:35 am    Post subject: Re: futility pruining, razoring question Reply to topic Reply with quote

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??

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).
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.
Back to top
View user's profile Send private message
Martin Sedlak



Joined: 26 Nov 2010
Posts: 701

PostPosted: Fri Apr 06, 2012 4:10 am    Post subject: Re: futility pruining, razoring question Reply to topic Reply with quote

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 Smile
Back to top
View user's profile Send private message
Martin Sedlak



Joined: 26 Nov 2010
Posts: 701

PostPosted: Fri Apr 06, 2012 5:15 am    Post subject: Re: futility pruining, razoring question Reply to topic Reply with quote

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"
Back to top
View user's profile Send private message
Marco Costalba



Joined: 14 Jun 2008
Posts: 2090

PostPosted: Fri Apr 06, 2012 5:45 am    Post subject: Re: futility pruining, razoring question Reply to topic Reply with quote

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:

Code:

const int score = qsearch(B, alpha, beta, 0, ply+1, is_pv, si+1);


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.
Back to top
View user's profile Send private message
Lucas Braesch



Joined: 31 May 2010
Posts: 1757

PostPosted: Fri Apr 06, 2012 7:22 am    Post subject: Re: futility pruining, razoring question Reply to topic Reply with quote

mcostalba 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:

Code:

const int score = qsearch(B, alpha, beta, 0, ply+1, is_pv, si+1);


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.

You're right. As pointed out by Martin, I got fooled by the chess programming wiki Wink
I'm currently testing this alternative:
Code:
   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;
      }
   }

I've just ran 1000 games in 6"+0.1", and it scored 52% against my previous code. Thanks for the tip!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic       TalkChess.com Forum Index -> Computer Chess Club: Programming and Technical Discussions All times are GMT
Goto page 1, 2, 3, 4  Next
Threaded
Page 1 of 4

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




Powered by phpBB © 2001, 2005 phpBB Group
Enhanced with Moby Threads