Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Crafty internal iterative deepening

Author: Robert Hyatt

Date: 08:57:42 01/26/00

Go up one level in this thread


On January 26, 2000 at 11:08:50, Tijs van Dam wrote:

>On January 26, 2000 at 10:59:13, Ulrich Tuerke wrote:
>
>>On January 26, 2000 at 08:08:01, Tijs van Dam wrote:
>>
>>
>>>  tree->next_status[ply].phase=FIRST_PHASE;
>>>  if (tree->hash_move[ply]==0 && do_null && depth>=3*INCPLY) do {
>>>  ....
>>>  } while(0);
>>
>>The  "do  { ... } while (0)"
>>above looks peculiar to me. Another copy mistake ?
>
>No, Dr. Hyatt uses this construction a lot. You can break anywhere inside the do
>and continue with what's beyond it. Like "return;" in the middle of a function.
>IMHO, i think it's ugly. And my compiler broke on it in Crafty's evaluation
>function.
>
>>
>>Uli


It isn't ugly in the domain of software engineering.  The problem is that I have
this:

  {a block of code with a lot of
   stuff in it...
   if (condition) go to exit;
   more stuff.
   maybe a lot more stuff;
  }
exit:

If the block of code is more than a few lines, finding the target of the
goto is difficult.  Because it can be forward _or_ backward from the point
where the goto is located.

on the other hand:

  do {a block of code with a lot of
   stuff in it...
   if (condition) break;
   more stuff.
   maybe a lot more stuff;
  } while (0);

is considered easier to read.  Because the break is really a goto, but it
_definitely_ goes in the forward direction _only_.  And it stops at the end
of the current loop.  With vi, you can back up to the beginning "{" for this
loop, hit the % character, and you are looking at the place the break takes
you.

IE it wasn't written for speed, it was written for readability.  There is
exactly one goto in crafty, in the MakeMove() stuff.  I could do the same
there but would have to repeat a bunch of code...

Bob




This page took 0.01 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.