Author: Christophe Theron
Date: 16:32:48 05/31/98
Go up one level in this thread
On May 31, 1998 at 12:13:28, Jens Baek Nielsen wrote:
>
>My chessprogram Dabbaba uses this code to get the time:
>
>double get_the_time()
>// returns the number of 1/100 seconds since the program started
>{return (double)(100*(clock())/CLK_TCK);}
>
>It works fine except at midnight, where strange numbers suddenly appears
>- suddenly white has used more than 8 million seconds etc.!
>
>Is it only me who has encountered this problem?
>Is there a better way to measure the time?
>
>I consider to estimate the time from the number of nodes searched at
>this midnightevent, but it is rather silly code to have in your program.
>
>I use a Borland Turbo C++ 3.0 compiler.
>
>Greetings Jens
The problem comes from a problem with the PC BIOS and the way DOS
handles the clock.
I have the same problem with Tiger compiled with BC3.1 or GnuC.
To fix the problem, you have to do the following:
Your function get_the_time should store the latest value returned by
clock(). When, suddenly, clock() returns a value which is less than the
last value (midnight!), you should store this value and use it as an
offset in any subsequent call to get_the_time.
I have to say that a tester told me recently that he had the midnight
bug one time with Tiger (even with the above mentionned fix). We were
unable to reproduce it, but it happened...
So now I'm considering using the code given by Don in the other reply to
your message...
Christophe
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.