Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Crafty null move question

Author: Robert Hyatt

Date: 08:52:39 07/18/02

Go up one level in this thread


On July 18, 2002 at 03:13:46, Uri Blass wrote:

>On July 18, 2002 at 02:25:50, Steffen Jakob wrote:
>
>>On July 18, 2002 at 00:37:57, Robert Hyatt wrote:
>>
>>>On July 17, 2002 at 16:30:24, Patrik wrote:
>>>
>>>>Hello, Dr Hyatt.
>>>>
>>>>  if (do_null && !tree->in_check[ply] && pieces && (pieces>5 || depth<421)) {
>>>>
>>>>Where does the depth 421 come from?
>>>>
>>>>Thank you.
>>>
>>>
>>>A ply is 60, so that says "if (depth <= 7)  (7*60=420)
>>
>>Craftys code uses a lot of magic numbers which makes it difficult to read
>>sometimes. Why not write "depth <= 7*INCPLY" here?
>>
>>Greetings,
>>Steffen.
>
>Speed.
>
>Calculating <421 is faster than calculating 7*INCPLY again and again.


Speed is not an issue for the calculation.  if INCPLY is a constant, then
the compiler realizes 7*INCPLY is _also_ a constant and will produce the code
using the constant 420 rather than doing the calculation.

The reason it is a constant (magic number as Steffen said) is that as I tested
this, I played with a _lot_ of different values, and I found things like
6*INCPLY+30 to be tedius to type.  Once I settled on 7*INCPLY I should have
used that to make it more readable of course, and I will fix this (and others)
as I notice them.

>
>If the target is to do the code more easy to understand then it is possible to
>add a comment in the code.
>
>Uri



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.