Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Tree search question

Author: Robert Hyatt

Date: 13:51:19 03/03/03

Go up one level in this thread


On March 03, 2003 at 16:29:07, Alvaro Jose Povoa Cardoso wrote:

>Hi,
>If I want to know if at the current ply/node we are winning with a mate score,
>would the following code be the most compact way to code that or can we do it
>with less code?
>I would like to do it with less branches/code if possible.
>
>
>if (abs(alpha) > MATE-300) {
>   if (wtm) {
>      if (alpha > 0) {
>         //if we get here the current player to move (white) is winning with a
>mate score
>      }
>   else {
>      if (alpha < 0) {
>         //if we get here the current player to move (black) is winning with a
>mate score
>      }
>   }


Try it this way:

if (abs(alpha) > MATE-300) {
/* somebody is getting mated.  */
  if (alpha > 0) {
      /* the side to move here is mating the opponent, assuming negamax  */
  }
  else {
      /* the side to move is getting mated */
  }
}


The negamax formulation of minimax lets you get rid of the (wtm) type tests
most of the time.



>}
>
>Best regards,
>Alvaro Cardoso



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.