UCI multipv question

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

mar
Posts: 2555
Joined: Fri Nov 26, 2010 2:00 pm
Location: Czech Republic
Full name: Martin Sedlak

UCI multipv question

Post by mar »

Hello everybody,

I just implemented multipv. It seems to work, but I have a question.
How do you handle moves still in multipv from previous iteration that haven't been searched yet? (or: which is the correct way to handle it) I currently report them sorted lower than current depth moves but I thought they perhaps shouldn't be reported at all. Do you leave it up to GUI?

Thanks

Martin
User avatar
Onno Garms
Posts: 224
Joined: Mon Mar 12, 2007 7:31 pm
Location: Bonn, Germany

Re: UCI multipv question

Post by Onno Garms »

If I (in engine Onno) have a PV from a previous iteration, I send it after the PVs of the moves that already have been searched at this iteration.

In the implementation, I keep an ordered list of PVs. After searching a move, it may be sorted to an earlier list position but never to a later one. Than I can just send the required number of PVs from the head of the list.

Code: Select all

uci
id name Deep Onno 1-2-71
id author Onno Garms
option name Log Level type spin default 0 min 0 max 2
option name Verbose Level type spin default 3 min 0 max 5
option name Flush Debug type button
option name Show Full Path type check default false
option name Random Intensity type spin default 9 min 0 max 50
option name Random Seed type spin default 5489 min -1 max 32767
option name Contempt type spin default 0 min -200 max 200
option name Contempt for White type check default false
option name TB Min Depth type spin default 6 min 0 max 128
option name TB Draw type combo default null scores var move instantly var null scores var ignore
option name Threads type spin default 2 min 1 max 2
option name Hash type spin default 16 min 0 max 16384
option name Clear Hash type button
option name Ponder type check default false
option name MultiPV type spin default 1 min 1 max 999
option name UCI_ShowCurrLine type check default false
option name UCI_ShowRefutations type check default false
option name UCI_EngineAbout type string default Deep Onno 1-2-71 (c) by Onno Garms
option name NalimovPath type string default <empty>
option name NalimovCache type spin default 4 min 1 max 256
uciok
copyprotection checking
copyprotection ok
setoption name Threads value 1
setoption name MultiPV value 5
setoption name Verbose Level value 5
go depth 3
info multipv 1 score cp 0 pv b1a3
info multipv 2 score cp 0 pv b1c3
info multipv 3 score cp 0 pv g1f3
info multipv 4 score cp 0 pv g1h3
info multipv 5 score cp 0 pv a2a4
info nodes 0 time 0 nps 0 tbhits 0 cpuload 0
info depth 1 seldepth 1
info currmove b1a3 currmovenumber 1
info multipv 1 depth 1 seldepth 1 nodes 1 time 0 nps 0 tbhits 0 score cp 20 pv b1a3
info multipv 2 score cp 0 pv b1c3
info multipv 3 score cp 0 pv g1f3
info multipv 4 score cp 0 pv g1h3
info multipv 5 score cp 0 pv a2a4
info currmove b1c3 currmovenumber 2
info multipv 1 depth 1 seldepth 1 nodes 2 time 0 nps 0 tbhits 0 score cp 51 pv b1c3
info multipv 2 depth 1 seldepth 1 nodes 1 time 0 nps 0 tbhits 0 score cp 20 pv b1a3
info multipv 3 score cp 0 pv g1f3
info multipv 4 score cp 0 pv g1h3
info multipv 5 score cp 0 pv a2a4
info currmove g1f3 currmovenumber 3
info multipv 1 depth 1 seldepth 1 nodes 3 time 0 nps 0 tbhits 0 score cp 58 pv g1f3
info multipv 2 depth 1 seldepth 1 nodes 2 time 0 nps 0 tbhits 0 score cp 51 pv b1c3
info multipv 3 depth 1 seldepth 1 nodes 1 time 0 nps 0 tbhits 0 score cp 20 pv b1a3
info multipv 4 score cp 0 pv g1h3
info multipv 5 score cp 0 pv a2a4
info currmove g1h3 currmovenumber 4
info multipv 1 depth 1 seldepth 1 nodes 3 time 0 nps 0 tbhits 0 score cp 58 pv g1f3
info multipv 2 depth 1 seldepth 1 nodes 2 time 0 nps 0 tbhits 0 score cp 51 pv b1c3
info multipv 3 depth 1 seldepth 1 nodes 1 time 0 nps 0 tbhits 0 score cp 20 pv b1a3
info multipv 4 depth 1 seldepth 1 nodes 4 time 0 nps 0 tbhits 0 score cp 20 pv g1h3
info multipv 5 score cp 0 pv a2a4
info currmove a2a4 currmovenumber 5
info multipv 1 depth 1 seldepth 1 nodes 3 time 0 nps 0 tbhits 0 score cp 58 pv g1f3
info multipv 2 depth 1 seldepth 1 nodes 2 time 0 nps 0 tbhits 0 score cp 51 pv b1c3
info multipv 3 depth 1 seldepth 1 nodes 1 time 0 nps 0 tbhits 0 score cp 20 pv b1a3
info multipv 4 depth 1 seldepth 1 nodes 4 time 0 nps 0 tbhits 0 score cp 20 pv g1h3
info multipv 5 depth 1 seldepth 1 nodes 5 time 0 nps 0 tbhits 0 score cp 2 pv a2a4
info currmove b2b4 currmovenumber 6
info currmove c2c4 currmovenumber 7
info currmove d2d4 currmovenumber 8
info multipv 1 depth 1 seldepth 1 nodes 3 time 0 nps 0 tbhits 0 score cp 58 pv g1f3
info multipv 2 depth 1 seldepth 1 nodes 2 time 0 nps 0 tbhits 0 score cp 51 pv b1c3
info multipv 3 depth 1 seldepth 1 nodes 8 time 0 nps 0 tbhits 0 score cp 29 pv d2d4
info multipv 4 depth 1 seldepth 1 nodes 1 time 0 nps 0 tbhits 0 score cp 20 pv b1a3
info multipv 5 depth 1 seldepth 1 nodes 4 time 0 nps 0 tbhits 0 score cp 20 pv g1h3
info currmove e2e4 currmovenumber 9
info multipv 1 depth 1 seldepth 1 nodes 3 time 0 nps 0 tbhits 0 score cp 58 pv g1f3
info multipv 2 depth 1 seldepth 1 nodes 2 time 0 nps 0 tbhits 0 score cp 51 pv b1c3
info multipv 3 depth 1 seldepth 1 nodes 8 time 0 nps 0 tbhits 0 score cp 29 pv d2d4
info multipv 4 depth 1 seldepth 1 nodes 9 time 0 nps 0 tbhits 0 score cp 24 pv e2e4
info multipv 5 depth 1 seldepth 1 nodes 1 time 0 nps 0 tbhits 0 score cp 20 pv b1a3
info currmove f2f4 currmovenumber 10
info currmove g2g4 currmovenumber 11
info currmove h2h4 currmovenumber 12
info currmove a2a3 currmovenumber 13
info currmove b2b3 currmovenumber 14
info currmove c2c3 currmovenumber 15
info currmove d2d3 currmovenumber 16
info currmove e2e3 currmovenumber 17
info currmove f2f3 currmovenumber 18
info currmove g2g3 currmovenumber 19
info currmove h2h3 currmovenumber 20
info nodes 20 time 0 nps 0 tbhits 0 cpuload 0
info depth 2 seldepth 2
info currmove g1f3 currmovenumber 1
info multipv 1 depth 2 seldepth 2 nodes 23 time 0 nps 0 tbhits 0 score cp 16 upperbound pv g1f3 b8c6
info multipv 2 depth 1 seldepth 1 nodes 2 time 0 nps 0 tbhits 0 score cp 51 pv b1c3
info multipv 3 depth 1 seldepth 1 nodes 8 time 0 nps 0 tbhits 0 score cp 29 pv d2d4
info multipv 4 depth 1 seldepth 1 nodes 9 time 0 nps 0 tbhits 0 score cp 24 pv e2e4
info multipv 5 depth 1 seldepth 1 nodes 1 time 0 nps 0 tbhits 0 score cp 20 pv b1a3
info multipv 1 depth 2 seldepth 2 nodes 43 time 10 nps 4300 tbhits 0 score cp 2 pv g1f3 g8f6
info multipv 2 depth 1 seldepth 1 nodes 2 time 0 nps 0 tbhits 0 score cp 51 pv b1c3
info multipv 3 depth 1 seldepth 1 nodes 8 time 0 nps 0 tbhits 0 score cp 29 pv d2d4
info multipv 4 depth 1 seldepth 1 nodes 9 time 0 nps 0 tbhits 0 score cp 24 pv e2e4
info multipv 5 depth 1 seldepth 1 nodes 1 time 0 nps 0 tbhits 0 score cp 20 pv b1a3
info currmove b1c3 currmovenumber 2
info multipv 1 depth 2 seldepth 2 nodes 43 time 10 nps 4300 tbhits 0 score cp 2 pv g1f3 g8f6
info multipv 2 depth 2 seldepth 2 nodes 45 time 10 nps 4500 tbhits 0 score cp 10 upperbound pv b1c3 g8f6
info multipv 3 depth 1 seldepth 1 nodes 8 time 0 nps 0 tbhits 0 score cp 29 pv d2d4
info multipv 4 depth 1 seldepth 1 nodes 9 time 0 nps 0 tbhits 0 score cp 24 pv e2e4
info multipv 5 depth 1 seldepth 1 nodes 1 time 0 nps 0 tbhits 0 score cp 20 pv b1a3
info multipv 1 depth 2 seldepth 2 nodes 65 time 10 nps 6500 tbhits 0 score cp 2 pv b1c3 b8c6
info multipv 2 depth 2 seldepth 2 nodes 43 time 10 nps 4300 tbhits 0 score cp 2 pv g1f3 g8f6
info multipv 3 depth 1 seldepth 1 nodes 8 time 0 nps 0 tbhits 0 score cp 29 pv d2d4
info multipv 4 depth 1 seldepth 1 nodes 9 time 0 nps 0 tbhits 0 score cp 24 pv e2e4
info multipv 5 depth 1 seldepth 1 nodes 1 time 0 nps 0 tbhits 0 score cp 20 pv b1a3
info currmove d2d4 currmovenumber 3
info multipv 1 depth 2 seldepth 2 nodes 65 time 10 nps 6500 tbhits 0 score cp 2 pv b1c3 b8c6
info multipv 2 depth 2 seldepth 2 nodes 43 time 10 nps 4300 tbhits 0 score cp 2 pv g1f3 g8f6
info multipv 3 depth 2 seldepth 2 nodes 68 time 10 nps 6800 tbhits 0 score cp -14 upperbound pv d2d4 g8f6
info multipv 4 depth 1 seldepth 1 nodes 9 time 0 nps 0 tbhits 0 score cp 24 pv e2e4
info multipv 5 depth 1 seldepth 1 nodes 1 time 0 nps 0 tbhits 0 score cp 20 pv b1a3
info multipv 1 depth 2 seldepth 2 nodes 65 time 10 nps 6500 tbhits 0 score cp 2 pv b1c3 b8c6
info multipv 2 depth 2 seldepth 2 nodes 43 time 10 nps 4300 tbhits 0 score cp 2 pv g1f3 g8f6
info multipv 3 depth 2 seldepth 2 nodes 88 time 10 nps 8800 tbhits 0 score cp -14 pv d2d4 g8f6
info multipv 4 depth 1 seldepth 1 nodes 9 time 0 nps 0 tbhits 0 score cp 24 pv e2e4
info multipv 5 depth 1 seldepth 1 nodes 1 time 0 nps 0 tbhits 0 score cp 20 pv b1a3
info currmove e2e4 currmovenumber 4
info multipv 1 depth 2 seldepth 2 nodes 65 time 10 nps 6500 tbhits 0 score cp 2 pv b1c3 b8c6
info multipv 2 depth 2 seldepth 2 nodes 43 time 10 nps 4300 tbhits 0 score cp 2 pv g1f3 g8f6
info multipv 3 depth 2 seldepth 2 nodes 88 time 10 nps 8800 tbhits 0 score cp -14 pv d2d4 g8f6
info multipv 4 depth 2 seldepth 2 nodes 91 time 10 nps 9100 tbhits 0 score cp -18 upperbound pv e2e4 b8c6
info multipv 5 depth 1 seldepth 1 nodes 1 time 0 nps 0 tbhits 0 score cp 20 pv b1a3
info multipv 1 depth 2 seldepth 2 nodes 65 time 10 nps 6500 tbhits 0 score cp 2 pv b1c3 b8c6
info multipv 2 depth 2 seldepth 2 nodes 43 time 10 nps 4300 tbhits 0 score cp 2 pv g1f3 g8f6
info multipv 3 depth 2 seldepth 2 nodes 88 time 10 nps 8800 tbhits 0 score cp -14 pv d2d4 g8f6
info multipv 4 depth 2 seldepth 2 nodes 111 time 10 nps 11100 tbhits 0 score cp -18 pv e2e4 b8c6
info multipv 5 depth 1 seldepth 1 nodes 1 time 0 nps 0 tbhits 0 score cp 20 pv b1a3
info currmove b1a3 currmovenumber 5
info multipv 1 depth 2 seldepth 2 nodes 65 time 10 nps 6500 tbhits 0 score cp 2 pv b1c3 b8c6
info multipv 2 depth 2 seldepth 2 nodes 43 time 10 nps 4300 tbhits 0 score cp 2 pv g1f3 g8f6
info multipv 3 depth 2 seldepth 2 nodes 88 time 10 nps 8800 tbhits 0 score cp -14 pv d2d4 g8f6
info multipv 4 depth 2 seldepth 2 nodes 132 time 10 nps 13200 tbhits 0 score cp -17 pv b1a3 g8f6
info multipv 5 depth 2 seldepth 2 nodes 111 time 10 nps 11100 tbhits 0 score cp -18 pv e2e4 b8c6
info currmove g1h3 currmovenumber 6
info currmove d2d3 currmovenumber 7
info multipv 1 depth 2 seldepth 2 nodes 65 time 10 nps 6500 tbhits 0 score cp 2 pv b1c3 b8c6
info multipv 2 depth 2 seldepth 2 nodes 43 time 10 nps 4300 tbhits 0 score cp 2 pv g1f3 g8f6
info multipv 3 depth 2 seldepth 2 nodes 88 time 10 nps 8800 tbhits 0 score cp -14 pv d2d4 g8f6
info multipv 4 depth 2 seldepth 2 nodes 175 time 10 nps 17500 tbhits 0 score cp -16 pv d2d3 g8f6
info multipv 5 depth 2 seldepth 2 nodes 132 time 10 nps 13200 tbhits 0 score cp -17 pv b1a3 g8f6
info currmove e2e3 currmovenumber 8
info currmove g2g4 currmovenumber 9
info currmove g2g3 currmovenumber 10
info currmove a2a4 currmovenumber 11
info currmove f2f4 currmovenumber 12
info currmove b2b3 currmovenumber 13
info currmove c2c4 currmovenumber 14
info currmove f2f3 currmovenumber 15
info currmove b2b4 currmovenumber 16
info currmove h2h4 currmovenumber 17
info currmove h2h3 currmovenumber 18
info currmove c2c3 currmovenumber 19
info currmove a2a3 currmovenumber 20
info nodes 201 time 10 nps 20100 tbhits 0 cpuload 1000
User avatar
Onno Garms
Posts: 224
Joined: Mon Mar 12, 2007 7:31 pm
Location: Bonn, Germany

Re: UCI multipv question

Post by Onno Garms »

mar wrote:How do you handle moves still in multipv from previous iteration that haven't been searched yet? (or: which is the correct way to handle it) I currently report them sorted lower than current depth moves but I thought they perhaps shouldn't be reported at all. Do you leave it up to GUI?
UCI specification says:
in k-best mode always send all k variants in k strings together.
so I think not reporting old PVs at all is incorrect. If you prefer to report them at the end or merged into the list of current PVs may be up to you.
User avatar
hgm
Posts: 27796
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: UCI multipv question

Post by hgm »

Awful, isn't it? But of course all of UCI is based on sending the same stuff over and over again, as many times as possible...
mar
Posts: 2555
Joined: Fri Nov 26, 2010 2:00 pm
Location: Czech Republic
Full name: Martin Sedlak

Re: UCI multipv question

Post by mar »

hgm wrote:Awful, isn't it? But of course all of UCI is based on sending the same stuff over and over again, as many times as possible...
IMO UCI is very simple and elegant compared to fat ugly xboard protocol (or chess engine communication protocol if you wish) :D In fact I chose UCI after having read xboard protocol specs. I'd like to thank SMK for UCI!
mar
Posts: 2555
Joined: Fri Nov 26, 2010 2:00 pm
Location: Czech Republic
Full name: Martin Sedlak

Re: UCI multipv question

Post by mar »

Onno Garms wrote:
mar wrote:How do you handle moves still in multipv from previous iteration that haven't been searched yet? (or: which is the correct way to handle it) I currently report them sorted lower than current depth moves but I thought they perhaps shouldn't be reported at all. Do you leave it up to GUI?
UCI specification says:
in k-best mode always send all k variants in k strings together.
so I think not reporting old PVs at all is incorrect. If you prefer to report them at the end or merged into the list of current PVs may be up to you.
Thanks Onno, that seems reasonable. What I don't like, however is that I have to send all the PVs together. So basically I have to wait for k best moves first before sending the PVs to GUI. And what if I have a position where number of legal moves is less than k?
mar
Posts: 2555
Joined: Fri Nov 26, 2010 2:00 pm
Location: Czech Republic
Full name: Martin Sedlak

Re: UCI multipv question

Post by mar »

Thanks for reply. I also noticed that you use windowing in multipv mode as well. That sounds interesting. I currently don't do any windowing in k-best mode.
User avatar
Onno Garms
Posts: 224
Joined: Mon Mar 12, 2007 7:31 pm
Location: Bonn, Germany

Re: UCI multipv question

Post by Onno Garms »

mar wrote: So basically I have to wait for k best moves first before sending the PVs to GUI.
You don't have to wait as you can fill with moves from the previous depth (as explained in the previous post). At depth 1, waiting does not matter, but I have created all moves anyway, so I can send PVs of length 1 as shown in the example output.
And what if I have a position where number of legal moves is less than k?
Than the output is the same as with MultiPV n, where n is the number of legal moves.
mcostalba
Posts: 2684
Joined: Sat Jun 14, 2008 9:17 pm

Re: UCI multipv question

Post by mcostalba »

hgm wrote:Awful, isn't it? But of course all of UCI is based on sending the same stuff over and over again, as many times as possible...
Don't want to start a protocol flame war, but IMO an elegant protocol is one that has few and simple rules that are straight forward to implement with the minimal quantity of source code.

The actual messages of the protocol are aimed to be consumed by programs, not by humans, so it does not matter if they are "awful" in a human like metric.
User avatar
Onno Garms
Posts: 224
Joined: Mon Mar 12, 2007 7:31 pm
Location: Bonn, Germany

Re: UCI multipv question

Post by Onno Garms »

mar wrote:Thanks for reply. I also noticed that you use windowing in multipv mode as well. That sounds interesting. I currently don't do any windowing in k-best mode.
I think if you do windowing in MultiPV mode, you should have individual windows for each move. Using just one window for all moves is most likely harmful. The lazy solution is not to do windowing at all in MultiPV mode. My possibly better solution (though I never compared in a tournament with MultiPV enabled) can be found here:

http://talkchess.com/forum/viewtopic.php?t=38404