UCI: Console Play Mode?

Discussion of anything and everything relating to chess playing software and machines.

Moderators: hgm, Rebel, chrisw

User avatar
mhull
Posts: 13447
Joined: Wed Mar 08, 2006 9:02 pm
Location: Dallas, Texas
Full name: Matthew Hull

UCI: Console Play Mode?

Post by mhull »

How do you play a UCI chess program in console mode where you play against the program, entering moves and observe its thinking/pondering at the same time? It was not clear to me how this is done from just reading the UCI protocol definition.
Matthew Hull
User avatar
hgm
Posts: 27793
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: UCI: Console Play Mode?

Post by hgm »

Type

Code: Select all

uci
setoption name Hash value 256
isready
ucinewgame
position startpos moves e2e4
go wtime 300000 btime 300000 movestogo 40
Then repeat the 'position' and 'go' line for every move you want to make, but with the entire game so far after 'moves', and the actual clock times left. E.g. if the engine replied (after thinking output) with "bestmove e7e5", for your next move you would type:

Code: Select all

position startpos moves e2e4 e7e5 g1f3
go wtime 290000 btime 295000 movestogo 39
to play Ng3, etc.
User avatar
mhull
Posts: 13447
Joined: Wed Mar 08, 2006 9:02 pm
Location: Dallas, Texas
Full name: Matthew Hull

Re: UCI: Console Play Mode?

Post by mhull »

hgm wrote:Type

Code: Select all

uci
setoption name Hash value 256
isready
ucinewgame
position startpos moves e2e4
go wtime 300000 btime 300000 movestogo 40
Then repeat the 'position' and 'go' line for every move you want to make, but with the entire game so far after 'moves', and the actual clock times left. E.g. if the engine replied (after thinking output) with "bestmove e7e5", for your next move you would type:

Code: Select all

position startpos moves e2e4 e7e5 g1f3
go wtime 290000 btime 295000 movestogo 39
to play Ng3, etc.
Thanks, HG. That looks a bit ponderous for playing a full game from the console. My target machine will only support a console but it may have networking (if I can get a driver running). I guess I'd better use a GUI over the network (assuming that's possible) or write a front-end to make console play more practical.
Matthew Hull
Alexander Schmidt
Posts: 1203
Joined: Thu May 10, 2007 2:49 pm

Re: UCI: Console Play Mode?

Post by Alexander Schmidt »

mhull wrote:
hgm wrote:Type

Code: Select all

uci
setoption name Hash value 256
isready
ucinewgame
position startpos moves e2e4
go wtime 300000 btime 300000 movestogo 40
Then repeat the 'position' and 'go' line for every move you want to make, but with the entire game so far after 'moves', and the actual clock times left. E.g. if the engine replied (after thinking output) with "bestmove e7e5", for your next move you would type:

Code: Select all

position startpos moves e2e4 e7e5 g1f3
go wtime 290000 btime 295000 movestogo 39
to play Ng3, etc.
Thanks, HG. That looks a bit ponderous for playing a full game from the console. My target machine will only support a console but it may have networking (if I can get a driver running). I guess I'd better use a GUI over the network (assuming that's possible) or write a front-end to make console play more practical.
You could use an uci to winboard adapter and run it with the winboard commands.
User avatar
hgm
Posts: 27793
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: UCI: Console Play Mode?

Post by hgm »

When you can recall the previous lines with an arrow key it is doable; you just add the latest two moves to the recalled position line. And whe you don't care too much about the time usage, you can leave the 'go' line the same always.
User avatar
mhull
Posts: 13447
Joined: Wed Mar 08, 2006 9:02 pm
Location: Dallas, Texas
Full name: Matthew Hull

Re: UCI: Console Play Mode?

Post by mhull »

hgm wrote:When you can recall the previous lines with an arrow key it is doable; you just add the latest two moves to the recalled position line. And whe you don't care too much about the time usage, you can leave the 'go' line the same always.
Ah, that makes sense. Thanks.
Matthew Hull
User avatar
hgm
Posts: 27793
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: UCI: Console Play Mode?

Post by hgm »

Alexander Schmidt wrote:You could use an uci to winboard adapter and run it with the winboard commands.
I wanted to propose that, but then I realized that both Polyglot and UCI2WB support 'feature usermove=1', meaning they request the GUI/console user to prefix every input move with 'usermove ', which sort of spoils the fun.

I just discovered that Polyglot also understands moves without the 'usermove ' prefix, however! So all that is needed is:

Run the command

Code: Select all

polyglot -noini -ec "ENGINE_COMMAND" -ed "ENGINE_DIRECTORY"
Then type

Code: Select all

new
level 0 5 0
e4
The engine will reply "move e7e5", and you can then simply enter your own next move as

Code: Select all

Nf3
Polyglot does understand SAN.

If you want to play black, instead of entering your first move, just enter "go".

The "0 5 0" in the 'level' command means 5-min, no increment.
User avatar
mhull
Posts: 13447
Joined: Wed Mar 08, 2006 9:02 pm
Location: Dallas, Texas
Full name: Matthew Hull

Re: UCI: Console Play Mode?

Post by mhull »

hgm wrote:
Alexander Schmidt wrote:You could use an uci to winboard adapter and run it with the winboard commands.
I wanted to propose that, but then I realized that both Polyglot and UCI2WB support 'feature usermove=1', meaning they request the GUI/console user to prefix every input move with 'usermove ', which sort of spoils the fun.

I just discovered that Polyglot also understands moves without the 'usermove ' prefix, however! So all that is needed is:

Run the command

Code: Select all

polyglot -noini -ec "ENGINE_COMMAND" -ed "ENGINE_DIRECTORY"
Then type

Code: Select all

new
level 0 5 0
e4
The engine will reply "move e7e5", and you can then simply enter your own next move as

Code: Select all

Nf3
Polyglot does understand SAN.

If you want to play black, instead of entering your first move, just enter "go".

The "0 5 0" in the 'level' command means 5-min, no increment.
This is a nice solution. How does polyglot enable pondering for a UCI program?
Matthew Hull
User avatar
hgm
Posts: 27793
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: UCI: Console Play Mode?

Post by hgm »

The command 'hard' switches it on, the command 'easy' switches it off. As long as it is switched on the engine will ponder while the opponent is on move (except in the start position).