bug-gnu-chess
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GNU chess seems to always run at 100% CPU


From: George Pauly
Subject: Re: GNU chess seems to always run at 100% CPU
Date: Thu, 25 Jul 2013 23:14:01 -0400

Antonio Ceballos wrote:

> 
>  ...
> 
> I will have a look into it as soon as I can. I will let you know of
> any news. Meanwhile, any help is much appreciated.
> 
> 
> Regards,
> Antonio

I'd like to use GNU chess to test a web interface-to-uci project, and
this bug will be a problem.


Referring to source code, starting at the console loop in
engine/protocol.cpp, line 135 (quoted below). 

I haven't drilled down into this code to try to understand it in detail.
Browsing it raises some questions:

   Why isn't GNU readline used for the console?  Isn't readline the
defacto standard?

   Can someone who has a better understanding of this than me advise if
this code may (not) be responsible for the cpu racing?

   This is likely not relevant -- feel free to ignore this when you
answer -- , but why is the uci stop command (means cleanly stop
searching) referred to in the condition of the console while loop?  fwiw
entering a stop command does not affect the cpu racing.


thanks,

George Pauly



> // event()
> 
> void event() {
> 
>    while (!SearchInfo->stop && input_available()) loop_step();
> }
> 
> // loop_step()
> 
> static void loop_step() {
> 
>    char string[65536];
> 
>    // read a line
> 
>    get(string,65536);
> 
>    // parse
> 
>    if (false) {
> 
>    } else if (string_start_with(string,"debug ")) {
> 
>       // dummy
> 
>    } else if (string_start_with(string,"go ")) {
> 
>       if (!Searching && !Delay) {
>          init();
>          parse_go(string);
>       } else {
>          ASSERT(false);
>       }
> 
>    } else if (string_equal(string,"isready")) {
> 
>       if (!Searching && !Delay) {
>          init();
>       }
> 
>       send("readyok"); // no need to wait when searching (dixit SMK)
> 
>    } else if (string_equal(string,"ponderhit")) {
> 
>       if (Searching) {
> 
>          ASSERT(Infinite);
> 
>          SearchInput->infinite = false;
>          Infinite = false;
> 
>       } else if (Delay) {
> 
>          send_best_move();
>          Delay = false;
> 
>       } else {
> 
>          ASSERT(false);
>       }
> 
>    } else if (string_start_with(string,"position ")) {
> 
>       if (!Searching && !Delay) {
>          init();
>          parse_position(string);
>       } else {
>          ASSERT(false);
>       }
> 
>    } else if (string_equal(string,"quit")) {
> 
>       ASSERT(!Searching);
>       ASSERT(!Delay);
> 
>       exit(EXIT_SUCCESS);
> 
>    } else if (string_start_with(string,"setoption ")) {
> 
>       if (!Searching && !Delay) {
>          parse_setoption(string);
>       } else {
>          ASSERT(false);
>       }
> 
>    } else if (string_equal(string,"stop")) {
> 
>       if (Searching) {
> 
>          SearchInfo->stop = true;
>          Infinite = false;
> 
>       } else if (Delay) {
> 
>          send_best_move();
>          Delay = false;
>       }
> 
>    } else if (string_equal(string,"uci")) {
> 
>       ASSERT(!Searching);
>       ASSERT(!Delay);
> 
>       send("id name GNU Chess " VERSION);
>       send("id author GNU Chess team");
> 
>       option_list();
> 
>       send("uciok");
> 
>    } else if (string_equal(string,"ucinewgame")) {
> 
>       if (!Searching && !Delay && Init) {
>          trans_clear(Trans);
>       } else {
>          ASSERT(false);
>       }
> 
>    } else if (string_equal(string,"hashon")) {
> 
>       UseTrans = true;
> 
>    } else if (string_equal(string,"hashoff")) {
> 
>       UseTrans = false;
> 
>    }
> }






reply via email to

[Prev in Thread] Current Thread [Next in Thread]