Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Not too diffcult for computers

Author: Dan Newman

Date: 20:10:02 01/16/01

Go up one level in this thread


On January 15, 2001 at 14:07:00, Thomas Mayer wrote:

>Hi Pete,
>
>
>> So instead of going back to Windows and fixing the
>> problem, I got the Nunntest from a different computer and ran Comet on #10
>> for a
>> few hours.  On this one it went negative for a while, and then it went
>> positive
>> after that.  Hmmmm...
>
>>12.	-0.67	10999	1777802606	 g2g3  b8d7  f1g2  a3a5  h2h3  f8e7
>>13?	-0.81	13376	-2126666136	 g2g3  f8e7  g5f6  e7f6  d4e6  f7e6
>>13.	-0.78	25638	-34456580	 f4f5  b8c6  f5e6  f7e6  d4c6  b7c6
>>13.	-0.71	27082	197569083	 g5f6  g7f6  b1b3  a3a5  f1e2  h8g8
>
>That is quite usual... I think Uli uses like me and most of the others a 32 bit
>long variable to store the nodes count...
>
>The range of a 32 bit variable is:
>signed: -2147483648....2147483647
>unsigned: 0....4294967296
>
>As you can see, Uli uses signed variable... After 2147483647 moves it will
>overflow and go back to negativ number -2147483648... Then it will be increased
>again up to 2147483647 and after that again overflow...
>I use unsigned which means that the effect occurs after 4294967296 moves, Quarks
>node counter returns then to 0...
>Maybe funny in this case is that in those days where i486 or i386 were uses for
>chess, in most cases that was no problem, but things have changed... Anyway - it
>does not influent Comets strength in anyway - a solution is to use a double
>variable for node counter, but that WILL influent Comets strength because it
>will get a little bit slower... (Well, maybe about 0,00000001% ... :) I think I
>have read somewhere that Dieter Buerssner has implemented a double variable in
>his program...
>
>Greets, Thomas
>
>P.S.: Chess programming is also fighting for every tick... so we won't implement
>thinks that lose 0,00000001% .... :))))

I recently let my program (Shrike) run for about 380 hours on a position--it
went over 1.3 trillion nodes :).

What I use for counting nodes is a class that has two 32-bit integers inside
it.  I've overloaded ++ to increment it.  Only one of the two int's is
incremented by ++ so it doesn't cost any more than incrementing an int.  On
every call to the polling function (for time control and winboard input) I
also call a member function (on all the counters) that increments the 2nd int
inside the counter whenever the 1st int has gone over 1 billion.  (It also
subtracts 1 billion from the 1st int when this happens.)  This results in
almost no extra overhead over the usual 32-bit counter.  (Not that it would
have been much anyway...)

Here's the class:

/*
  +-------------------------+
  |                         |
  |   Node counting type.   |
  |                         |
  +-------------------------+
*/
const uint32 BILLION = 1000000000;
class ncount_t {
  private:
    uint32 count;
    uint32 oflow;
    char str[24];
    ncount_t( uint32 c, uint32 o) { count = c; oflow = o; zap(); }
  public:
    ncount_t() {}
    ncount_t( uint32 c) { count = c; oflow = 0; zap(); }
    ncount_t( const ncount_t &nc) { count = nc.count; oflow = nc.oflow; }
    void zero() { count = 0; oflow = 0; }
    void zap() { while( count >= BILLION ) { oflow++; count -= BILLION; } }
    void operator++( int) { count++; }
    void operator+=( uint32 ival) { count += ival; }
    void operator+=( const ncount_t &nc) {
        count += nc.count;
        oflow += nc.oflow;
        zap();
    }
    ncount_t operator+( ncount_t &nc ) {
        return ncount_t( count + nc.count, oflow + nc.oflow);
    }
    int mask( uint32 mask ) { return count & mask; }
    char *operator()() {
        zap();
        if( oflow == 0 )
            sprintf( str, "%d", count);
        else
            sprintf( str, "%d%09d", oflow, count);
        return str;
    }
    operator double() { return (double)BILLION * oflow + count; }
};

-Dan.



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.