UCI request answers all time..... how to do it?

Discussion of chess software programming and technical issues.

Moderator: Ras

User avatar
Luis Babboni
Posts: 464
Joined: Sat Feb 28, 2015 4:37 pm
Location: Argentina

UCI request answers all time..... how to do it?

Post by Luis Babboni »

Hi,

I´m trying to do my own engine.
I´m reading about UCI-engine communication and found this for example:

isready
...
This command must always be answered with "readyok" and can be sent also when the engine is calculating
in which case the engine should also immediately answer with "readyok" without stopping the search.


How could I do it?
:shock:

I really do not imagine that I must place a call to UCI-engine communications subroutine each , say, ten lines of code everywhere around the all program :?

Please could you explain me where I´m wrong?
Or there is in C++* some way to make a kind "hide phantom" all time present subroutine that suddenly turn on when some imput is making?
*: I´m doing it in QBasic, not in C++

Thnaks! :wink:
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: UCI request answers all time..... how to do it?

Post by bob »

Luis Babboni wrote:Hi,

I´m trying to do my own engine.
I´m reading about UCI-engine communication and found this for example:

isready
...
This command must always be answered with "readyok" and can be sent also when the engine is calculating
in which case the engine should also immediately answer with "readyok" without stopping the search.


How could I do it?
:shock:

I really do not imagine that I must place a call to UCI-engine communications subroutine each , say, ten lines of code everywhere around the all program :?

Please could you explain me where I´m wrong?
Or there is in C++* some way to make a kind "hide phantom" all time present subroutine that suddenly turn on when some imput is making?
*: I´m doing it in QBasic, not in C++

Thnaks! :wink:
Just check for input every second or so. If you spot something, read it and handle it.
User avatar
Luis Babboni
Posts: 464
Joined: Sat Feb 28, 2015 4:37 pm
Location: Argentina

Re: UCI request answers all time..... how to do it?

Post by Luis Babboni »

Well, a second is much more than "inmediatly" :D

Thanks bob!! :wink:
matthewlai
Posts: 793
Joined: Sun Aug 03, 2014 4:48 am
Location: London, UK

Re: UCI request answers all time..... how to do it?

Post by matthewlai »

Luis Babboni wrote:Hi,

I´m trying to do my own engine.
I´m reading about UCI-engine communication and found this for example:

isready
...
This command must always be answered with "readyok" and can be sent also when the engine is calculating
in which case the engine should also immediately answer with "readyok" without stopping the search.


How could I do it?
:shock:

I really do not imagine that I must place a call to UCI-engine communications subroutine each , say, ten lines of code everywhere around the all program :?

Please could you explain me where I´m wrong?
Or there is in C++* some way to make a kind "hide phantom" all time present subroutine that suddenly turn on when some imput is making?
*: I´m doing it in QBasic, not in C++

Thnaks! :wink:
The approach most people take is using a thread to handle IO and nothing else.

It's nice and intuitive, if you are familiar with multi-threading.
Disclosure: I work for DeepMind on the AlphaZero project, but everything I say here is personal opinion and does not reflect the views of DeepMind / Alphabet.
elcabesa
Posts: 860
Joined: Sun May 23, 2010 1:32 pm

Re: UCI request answers all time..... how to do it?

Post by elcabesa »

some programmer check the input every X nodes while searching.
if you know approximately nodes/second, you can use it instead of "check every x second"
AlvaroBegue
Posts: 932
Joined: Tue Mar 09, 2010 3:46 pm
Location: New York
Full name: Álvaro Begué (RuyDos)

Re: UCI request answers all time..... how to do it?

Post by AlvaroBegue »

elcabesa wrote:some programmer check the input every X nodes while searching.
if you know approximately nodes/second, you can use it instead of "check every x second"
Yup, that's what I do. I have a node counter that gets incremented every time you enter quiescence_search or negamax. When this happens in negamax, I also check to see if I have to check for input.

Code: Select all

  // Somewhere near the beginning of negamax...
  ++node_count;
  if (node_count >= next_check) {
    next_check = node_count + 500000; // Schedule the next check
    check_input();
    check_clock(); // In case we hit the maximum allowed time for this search
  }
User avatar
Luis Babboni
Posts: 464
Joined: Sat Feb 28, 2015 4:37 pm
Location: Argentina

Re: UCI request answers all time..... how to do it?

Post by Luis Babboni »

Thanks Matthew; Marco and Álvaro!

about using nodes.... then you need UCI is enough flexible or take a great security gap cause if not, if the engine runs in slow computer the GUI could stop the game?

Null knowledge about multithreads and thats "IO" :oops:
elcabesa
Posts: 860
Joined: Sun May 23, 2010 1:32 pm

Re: UCI request answers all time..... how to do it?

Post by elcabesa »

IO, stand for Input/Output.

so managing the IO stand for handling the uci protocol :)
about using nodes
lets suppose your engine do 500kN/s on a modern computer, you can choose to check the IO every 5000 nodes (every 10ms).
if your engine does 100kN/son a slow one, you'll check the IO eey 50ms, it will loose some games only at very very fast time control