Pondering? Yes. Ponder move? Maybe not.

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

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

Re: Pondering? Yes. Ponder move? Maybe not.

Post by bob »

Edmund wrote:Maybe it would be interesting to test on a correlation between certain ratios and the ponder hit ratio.

For example if the search suggests that the node prediction is weak (not just from one ply to another, which would suggest a tactical plan, but rather a general node prediction uncertainty) it may be more likely that our current pv is pretty close in value to some other moves. Thus a ponder on position might be more beneficial here.
So far nobody has given any rational explanation of why they believe "ponder on position" is any good at all, much less close to ponder best move or whatever. What exactly is the gain on ponder on position when the opponent makes a move and you can not reply instantly unless you are ready to take a search depth hit, and turn this into a tactical mistake. I do not see the benefit of this approach at all, other than it is somewhat easy to implement, where "ponder best move" needs a couple of ways to find the best move if the PV happens to be short, such as probing the hash, or else doing a short search to find the move to ponder, or whatever...
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Pondering? Yes. Ponder move? Maybe not.

Post by bob »

Daniel Shawul wrote:Is the result of your experiment available on your website ?

I switched to pondering strategy (I) but the behavior of the engine during ponder fails is very sad and noticeable with huge differences in ponder score and normal score. I might need to switch to ponder on the position when such score fluctuations are detected.
This is a different kind of program defect. If your score swings wildly between the normal search and the ponder search, that points out a tactical insufficiency in the search somewhere, as these cases should be rare. Otherwise you are going to be losing _lots_ of games due to tactical errors.

You will _occasionally_ see a big drop, or even better, a big jump in the score when pondering, because no search is perfect. But if it is happening often enough to affect pondering results, then something needs work.
User avatar
sje
Posts: 4675
Joined: Mon Mar 13, 2006 7:43 pm

Re: Pondering? Yes. Ponder move? Maybe not.

Post by sje »

hgm wrote:The longer an opponent thinks, the more likely it is that he switches move. Usually the move switch is the reason for the long think. But the ponder move was determined at comparatively shallow depth, so you are much more likely to ponder the move from before the switch, which will then be the wrong one. Thus it seems logical to expect a correlation: good predictions-short thinking, wrong predictions-long thinking.
On the other side of things, there is a strong positive correlation between positional imbalance and NOT switching move choice. So when a program is on either side of an obviously won/lost position, the ponder hit rate will go up. But in those cases, the ponder doesn't help much anyway as pondering will rarely change the move AND the game has probably already been decided.
Daniel Shawul
Posts: 4185
Joined: Tue Mar 14, 2006 11:34 am
Location: Ethiopia

An idea

Post by Daniel Shawul »

Of course big swings doesn't happen often. But it happens enough that
someone noticed something is unnatural the next day I made the
switch,while it was playing in live tournaments. Notice these things
weren't there with the original simpler method.

Anyway, I have an idea that might put this debate to rest.
The problem with the "ponder with the move" is when prediction fails.
Specially against a strong opponent , prediction failure is usually the beginning of trouble.
Lets say the opponent searches 1 ply better than you ,that means
you are constantly underestimating your opponent by 2 plies when you select
your ponder move. Another situation is when the opponent thinks longer than expected
on a move (due to may be its thinking it is in trouble). Here we go on pondering with a move which
could have been irrelevant for a long time,one might wish to check on the
ponder move from time to time. That is exactly what I plan to do.


:idea:
Start pondering for the opponent (i.e don't select any moves) then search only the first N-1 plies withe the _first_ root move only.
Then from then onwards occasionally check up on a few root moves as well. If we are sure that our selection is good enough,
we might go on forever with our selected move (This is effectively the same as what you do).
This way we can introduce the safety issue as much as we like. This looks so neat to me that someone must have tried it before.
:idea:
User avatar
hgm
Posts: 27796
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: An idea

Post by hgm »

Note that there actually is a gradual transition possible from one strategy to another:

You can start pondering the position, and after reaching some pre-determined depth Dp, freeze the move at ply 1 (so that effectively the node to which that move leads becomes the new root). When Dp=1 you would always freeze immediately, (presumably the move with the best hash value), and thus do pure move pondering. For DP=infinity you would never freeze, and do pure position pondering.

If you would set Dp=8 (say), most of the time the hash hits during the first iteration would give you a depth better than that, so that you immediately start pondering the move. But when for me reason you don't have a hash hit (e.g. you had only a single legal move on the previous ply, which you played without searching, and the move before it was a ponder miss), the search would first deepen to 8 ply to find the best move of the opponent, and after that you freeze that move and start pondering that (through IID in te sub-tree for it).
Daniel Shawul
Posts: 4185
Joined: Tue Mar 14, 2006 11:34 am
Location: Ethiopia

Re: An idea

Post by Daniel Shawul »

Note that there actually is a gradual transition possible from one strategy to another:

You can start pondering the position, and after reaching some pre-determined depth Dp, freeze the move at ply 1 (so that effectively the node to which that move leads becomes the new root). When Dp=1 you would always freeze immediately, (presumably the move with the best hash value), and thus do pure move pondering. For DP=infinity you would never freeze, and do pure position pondering.
Exactly. When I said N-1 plies, I meant to say N-1 _iteration depths_. If we searched to depth 12 then I think it is possible to freeze searching to only the first move for the first 11 iteration depths. But after that our prediction is risky so at iteration 12 we might want to check the second root move, then do the freezing again at iteration 13 and 14 with the best of the two root moves, check again at iteration 15 and so on...
If you would set Dp=8 (say), most of the time the hash hits during the first iteration would give you a depth better than that, so that you immediately start pondering the move. But when for me reason you don't have a hash hit (e.g. you had only a single legal move on the previous ply, which you played without searching, and the move before it was a ponder miss), the search would first deepen to 8 ply to find the best move of the opponent, and after that you freeze that move and start pondering that (through IID in te sub-tree for it).
I agree. For special cases where we don't have a move to ponder on, we search all moves to get a reliable ponder move and then start freezing later.
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: An idea

Post by bob »

Daniel Shawul wrote:Of course big swings doesn't happen often. But it happens enough that
someone noticed something is unnatural the next day I made the
switch,while it was playing in live tournaments. Notice these things
weren't there with the original simpler method.

Anyway, I have an idea that might put this debate to rest.
The problem with the "ponder with the move" is when prediction fails.
Specially against a strong opponent , prediction failure is usually the beginning of trouble.
Lets say the opponent searches 1 ply better than you ,that means
you are constantly underestimating your opponent by 2 plies when you select
your ponder move. Another situation is when the opponent thinks longer than expected
on a move (due to may be its thinking it is in trouble). Here we go on pondering with a move which
could have been irrelevant for a long time,one might wish to check on the
ponder move from time to time. That is exactly what I plan to do.


:idea:
Start pondering for the opponent (i.e don't select any moves) then search only the first N-1 plies withe the _first_ root move only.
Then from then onwards occasionally check up on a few root moves as well. If we are sure that our selection is good enough,
we might go on forever with our selected move (This is effectively the same as what you do).
This way we can introduce the safety issue as much as we like. This looks so neat to me that someone must have tried it before.
:idea:
Search is going to blow up. If you exclude root moves for the first N iterations, you get no hash information to order the search of those moves when you suddenly throw them into the pool of moves to search. They will take much longer than usual, as you are violating the basic premise that makes iterative deepening work in the first place.

But again, how does this "ponder the position" idea help us save time on the next search, which is the only benefit pondering offers, the ability to use our opponent's think time to do something useful/productive.
Daniel Shawul
Posts: 4185
Joined: Tue Mar 14, 2006 11:34 am
Location: Ethiopia

Re: An idea

Post by Daniel Shawul »

Search is going to blow up. If you exclude root moves for the first N iterations,
you get no hash information to order the search of those moves when you suddenly throw them
into the pool of moves to search. They will take much longer than usual, as you are violating the basic
premise that makes iterative deepening work in the first place.
No up to N - 1 iteration there is no blow up whatsoever.
You already searched those moves before starting pondering albeit with a zero width window.
Then again it doesn't matter if I started searching all moves from depth 1 up to N - 1 because we
get quick cutoffs there. For depth N and above search tree grows larger but there is a reason to it...
But again, how does this "ponder the position" idea help us save time on the next search,
which is the only benefit pondering offers, the ability to use our opponent's think time to do something useful/productive.
If you want to save the maximum possible time doing it like you do is the best, but it is also the most risky !
You continually underestimate the opponent to save the maximum possible time but as I have already pointed out
there is a risk to it especially when playing a stronger opponent. So to reduce that risk you check a few root
moves from time to time. The increase in search tree size depends on how cautious you want to be. With 0% risk
this method is _exactly_ the same as yours. If the search tree increases significantly while searching the
second move this is an indication that either it is better than what we selected or is equally good (in which
case it means it is good to search on it because opponent can make the first or second move with 50-50 chance).

Therefore your strategy (the most risky) may not be the best overall even though it tries to
accumulate maximum possible time. What is the point of saving the time if you don't use it when it matters,
like during ponder fails which usually signal trouble!

My plan is to the following:
i) Say we searched to depth 12 and we have a ponder move to depth 11
ii) ponder on only that move up to depth 11
iii) search one more alternative move at depth 12 with zero window
iv) search depth 13,14,15 with whatever was best in iii
v) got to iii
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: An idea

Post by bob »

Daniel Shawul wrote:
Note that there actually is a gradual transition possible from one strategy to another:

You can start pondering the position, and after reaching some pre-determined depth Dp, freeze the move at ply 1 (so that effectively the node to which that move leads becomes the new root). When Dp=1 you would always freeze immediately, (presumably the move with the best hash value), and thus do pure move pondering. For DP=infinity you would never freeze, and do pure position pondering.
Exactly. When I said N-1 plies, I meant to say N-1 _iteration depths_. If we searched to depth 12 then I think it is possible to freeze searching to only the first move for the first 11 iteration depths. But after that our prediction is risky so at iteration 12 we might want to check the second root move, then do the freezing again at iteration 13 and 14 with the best of the two root moves, check again at iteration 15 and so on...
Suppose we are averaging 20 ply searches in a game. It seems that you are saying to switch sides, and after a 19 ply search, "freeze" the best move and ponder only that for the remainder of the time?

How does that make sense. When I finished the last search I _already_ had a 19 ply search completed for my opponent, since the total depth was 20 plies and I played the first move.

I don't see how this makes any sense at all, you just repeat the same search you already have completed, and with luck it will take almost no time due to the hash table, with bad luck it will take a longer time and hurt worse.


If you would set Dp=8 (say), most of the time the hash hits during the first iteration would give you a depth better than that, so that you immediately start pondering the move. But when for me reason you don't have a hash hit (e.g. you had only a single legal move on the previous ply, which you played without searching, and the move before it was a ponder miss), the search would first deepen to 8 ply to find the best move of the opponent, and after that you freeze that move and start pondering that (through IID in te sub-tree for it).
I agree. For special cases where we don't have a move to ponder on, we search all moves to get a reliable ponder move and then start freezing later.
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: An idea

Post by bob »

Daniel Shawul wrote:
Search is going to blow up. If you exclude root moves for the first N iterations,
you get no hash information to order the search of those moves when you suddenly throw them
into the pool of moves to search. They will take much longer than usual, as you are violating the basic
premise that makes iterative deepening work in the first place.
No up to N - 1 iteration there is no blow up whatsoever.
You already searched those moves before starting pondering albeit with a zero width window.
Then again it doesn't matter if I started searching all moves from depth 1 up to N - 1 because we
get quick cutoffs there. For depth N and above search tree grows larger but there is a reason to it...
So you don't have a transposition table "age" field that would cause many of those positions to be overwritten on this new search since the age would have increased by one?
But again, how does this "ponder the position" idea help us save time on the next search,
which is the only benefit pondering offers, the ability to use our opponent's think time to do something useful/productive.
If you want to save the maximum possible time doing it like you do is the best, but it is also the most risky !
You continually underestimate the opponent to save the maximum possible time but as I have already pointed out
there is a risk to it especially when playing a stronger opponent. So to reduce that risk you check a few root
moves from time to time. The increase in search tree size depends on how cautious you want to be. With 0% risk
this method is _exactly_ the same as yours. If the search tree increases significantly while searching the
second move this is an indication that either it is better than what we selected or is equally good (in which
case it means it is good to search on it because opponent can make the first or second move with 50-50 chance).
And what happens when you search two moves that lead to the same score, a transposition? Or the search tree explodes and the second move takes almost as long as the first since few cutoffs happen? In either case, you really expend search effort that is _guaranteed_ to be 1/2 wasted. Where with "ponder the move" if you can beat 50% ponder hits, you are already ahead of the game and the higher the hit rate the more ahead in the timing game you get.

I'll ask the same question again, show me any sane reason for pondering the position, given a hit rate of over 50% (mine seems to be over 60% in most games), and I'll give it some thought. But so far, no mathematical explanation, or logical explanation has been given, just "there must be a better way..."


Therefore your strategy (the most risky) may not be the best overall even though it tries to
accumulate maximum possible time. What is the point of saving the time if you don't use it when it matters,
like during ponder fails which usually signal trouble!
I _do_ use the extra time if a ponder search fails low. Why wouldn't I since I use extra time if a normal search fails low, and on a ponder hit, the ponder search becomes a normal search and can use extended time.

My plan is to the following:
i) Say we searched to depth 12 and we have a ponder move to depth 11
ii) ponder on only that move up to depth 11
iii) search one more alternative move at depth 12 with zero window
iv) search depth 13,14,15 with whatever was best in iii
v) got to iii

You are making one assumption I do not agree with. I believe it is better to use _all_ time on a single move. If it fails low, then we find a better move to play since on a fail low we are pretty sure we are pondering the right move. But no matter what happens, I want to search as deeply as possible. Otherwise I would be doing an N-best sort of search all the time, which would simply kill my search performance.