Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Interruption and C++

Author: Mathieu Pagé

Date: 08:58:00 08/26/03

Go up one level in this thread


On August 26, 2003 at 08:20:27, dominique LONGBIEN wrote:

>On August 26, 2003 at 08:08:19, Anthony Cozzie wrote:
>
>>On August 26, 2003 at 07:34:42, dominique LONGBIEN wrote:
>>
>>>Hi there
>>>Is any body use an interruption (i.e. every 200ms) to look at the input buffer
>>>to know if a message from winboard or arena is present ?
>>>If yes, how should i declare this interrupt in C++ for windows ?
>>>Is it a good idea ?
>>>
>>>Thank for any help
>>>
>>>Dominique (adam)
>>
>>There are two usual approaches:
>>
>>Crafty does something like:
>>
>>if(nodes % 10000 == 0 && check_for_input())
>>  process_input();
>>
>>Zappa sets up a few threads and has one block on fgets.  Crafty's is definitely
>>easier, but I think Zappa's is cleaner. YMMV.
>>
>>anthony
>Thank you. I currently use the same methode as crafty but it is processor speed
>depandent, I am looking for a time based method.

I use a similar thechnique to return informations to the UI every 1 second here
is some pseudo-code:

int nps;
int NodesToNextLap;

void myfunct()
{
  NodesToNextLap = 10000; //something small that will be far less than a second

  While(someconditions)
  {
    if (NodesToNextLap == 0)
    {
      /* We do something that will only happen every 200 ms */
      /* Check for input in your case */

      /* We get the new nps based on nodes visited and time elapsed */
      nps = GetNPS();

      /* we calculate how many nodes we will visite in the next 0.2 seconds */
      /* this is an estimate of course */
      NodesToNextLap = 0.2 * nps;
    }
    else
    {
      NodesToNextLap--;
    }
  }
}

Hope it helps

Mahtieu Pagé
pagemathieu@hotmail.com



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.