How to ponder

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

CRoberson
Posts: 2056
Joined: Mon Mar 13, 2006 2:31 am
Location: North Carolina, USA

How to ponder

Post by CRoberson »

As "The Brain" would say to Pinky, "Are you pondering what I am Pondering?

Based on some statements by others in the thread on HGM's March 2013 blitz tourney, I am not seeing something or they aren't.

Here is how I ponder. This is a UCI implementation so stay away from UCI vs Xboard stuff. Lets stick to the subject.

Code: Select all

  1) Telepath searches on its time to say 20 ply and submits a move for play.
  2) Telepath notes the 2nd move in the PV as the expected opponent move.
  3) Telepath makes the expected ponder move on its internal board and starts a search for unlimited time until opponent moves.
  4) The opponent makes a move:
      4a) Ponder miss: Telepath effectively performs a takeback and then makes the opponents move and restarts the search as normal.
      4b) Ponder Hit: 
            4b1) Not enough search (opponent quick move): Continue searching until satisfied.
            4b2) Enough time: Make move. 
                  (here I should test for failing low and possibly extend search).
Ok, so I don't see how this algorithm would come back with no move at all after a ponder hit as HGM states happens sometimes. Secondly, I don't see the need for a quick search to find a ponder move to ponder. In this case, the opponents choices (steps 1 & 2) have been considered at 19 ply, so a quick 5 ply search seems to be a waste.
User avatar
hgm
Posts: 27827
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: How to ponder

Post by hgm »

Sometimes the search does not come back with a move, and then it also does not have a PV, and no ponder move. (Supposing you take the second move of the PV as a ponder move.) Whether that search itself was a ponder hit or not doesn't have anything to do with it.

This can for instance happen if the first iteration gives you a hash hit that is so deep that the next iteration can't even finish the search of the first move in time, before it is aborted.
CRoberson
Posts: 2056
Joined: Mon Mar 13, 2006 2:31 am
Location: North Carolina, USA

Re: How to ponder

Post by CRoberson »

hgm wrote:Sometimes the search does not come back with a move, and then it also does not have a PV, and no ponder move. (Supposing you take the second move of the PV as a ponder move.) Whether that search itself was a ponder hit or not doesn't have anything to do with it.

This can for instance happen if the first iteration gives you a hash hit that is so deep that the next iteration can't even finish the search of the first move in time, before it is aborted.
Ok, I see what you mean now. I don't do that in the primary search so that is not a problem for me. I've thought about that, but ruled it out.

I don't do LMR for the root. Given that, the search tree beneath the 3rd move (my intended response to the ponder move) is not the same when that position is at the root. That is why I ruled that out.
User avatar
hgm
Posts: 27827
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: How to ponder

Post by hgm »

It is not so much a matter of LMR as of hash cutoffs. If your best move in the root leads to a 19-ply hash entry, and you cannot finish at least one move of the 20-ply search, you will only have a one-move PV, and no ponder move.
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: How to ponder

Post by bob »

CRoberson wrote:
hgm wrote:Sometimes the search does not come back with a move, and then it also does not have a PV, and no ponder move. (Supposing you take the second move of the PV as a ponder move.) Whether that search itself was a ponder hit or not doesn't have anything to do with it.

This can for instance happen if the first iteration gives you a hash hit that is so deep that the next iteration can't even finish the search of the first move in time, before it is aborted.
Ok, I see what you mean now. I don't do that in the primary search so that is not a problem for me. I've thought about that, but ruled it out.

I don't do LMR for the root. Given that, the search tree beneath the 3rd move (my intended response to the ponder move) is not the same when that position is at the root. That is why I ruled that out.
I don't see this problem either. When I start a ponder search, I have a PV from the real search. I just trim the first two moves, and keep the rest. I start the ponder search at 1 ply shallower than the previous search (I already have the score for a 2-ply shallower search).

I can't start a search and get no PV back, because I have no way for a search to terminate without backing up the best move at the root, which can't be a hash hit since I don't probe at the root...

Seems like a whacky way of doing this if you really could do a search and get nada back...
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: How to ponder

Post by bob »

CRoberson wrote:
hgm wrote:Sometimes the search does not come back with a move, and then it also does not have a PV, and no ponder move. (Supposing you take the second move of the PV as a ponder move.) Whether that search itself was a ponder hit or not doesn't have anything to do with it.

This can for instance happen if the first iteration gives you a hash hit that is so deep that the next iteration can't even finish the search of the first move in time, before it is aborted.
Ok, I see what you mean now. I don't do that in the primary search so that is not a problem for me. I've thought about that, but ruled it out.

I don't do LMR for the root. Given that, the search tree beneath the 3rd move (my intended response to the ponder move) is not the same when that position is at the root. That is why I ruled that out.
I don't see this problem either. When I start a ponder search, I have a PV from the real search. I just trim the first two moves, and keep the rest. I start the ponder search at 1 ply shallower than the previous search (I already have the score for a 2-ply shallower search).

I can't start a search and get no PV back, because I have no way for a search to terminate without backing up the best move at the root, which can't be a hash hit since I don't probe at the root...

Seems like a whacky way of doing this if you really could do a search and get nada back...
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: How to ponder

Post by bob »

hgm wrote:It is not so much a matter of LMR as of hash cutoffs. If your best move in the root leads to a 19-ply hash entry, and you cannot finish at least one move of the 20-ply search, you will only have a one-move PV, and no ponder move.
I have three ways to get a ponder move in Crafty.

1. 2nd move from the PV, if there is one.

2. Probe the hash table. If no hit,

3. Do a short search for opponent to find a move to ponder

I never sit and wait, ever.
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: How to ponder

Post by bob »

hgm wrote:It is not so much a matter of LMR as of hash cutoffs. If your best move in the root leads to a 19-ply hash entry, and you cannot finish at least one move of the 20-ply search, you will only have a one-move PV, and no ponder move.
I have three ways to get a ponder move in Crafty.

1. 2nd move from the PV, if there is one.

2. Probe the hash table. If no hit,

3. Do a short search for opponent to find a move to ponder

I never sit and wait, ever.
User avatar
hgm
Posts: 27827
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: How to ponder

Post by hgm »

bob wrote:I can't start a search and get no PV back, because I have no way for a search to terminate without backing up the best move at the root, which can't be a hash hit since I don't probe at the root...
You can get a hash hit at the root PV daughter, if you probe there. Then your PV would only be one move long. (Unless you hash it, of course, but not many engines do.)
JVMerlino
Posts: 1357
Joined: Wed Mar 08, 2006 10:15 pm
Location: San Francisco, California

Re: How to ponder

Post by JVMerlino »

hgm wrote:
bob wrote:I can't start a search and get no PV back, because I have no way for a search to terminate without backing up the best move at the root, which can't be a hash hit since I don't probe at the root...
You can get a hash hit at the root PV daughter, if you probe there. Then your PV would only be one move long. (Unless you hash it, of course, but not many engines do.)
Please correct me if I'm wrong, as this is a bit of a corner case that involves clock management. But isn't it also possible to have a "PV" be only one move long because of a fail high? Then, because of severe time pressure, you make that move anyway because the search with a wider window hasn't finished yet and just hope for the best? At least, that's a possibility in my engine.

Of course, Bob's other ways of getting a move to ponder with will still apply here. So I'm just talking about the case of a one-move PV.

jm