Iteration in pondering

Discussion of chess software programming and technical issues.

Moderator: Ras

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

Re: Iteration in pondering

Post by bob »

Sven Schüle wrote:
bob wrote:
Chang wrote:Hi,

In pondering mode, while human player thinking, the program starts pondering by making a guessing move, let’s say move X, then going deeper in iteration starting from depth 1. Suppose a situation, after finishing depth 10 while going through depth 11, human player input move X. My question is, on its turn to move, should the program start calculating at depth 1 as usual or depth 10 in stead?

Thanks for any advices.

Best regards,
Teerapong
I do what you suggest in Crafty. But it is not clear that it makes that much difference. Ostensibly, if I search to depth 20 and make a move, and start pondering, I predict the second move in the PV, so the resulting position should be able to use all the hash entries (if they were not overwritten) to quickly complete depth 18 (which I had really already completed since I did 20, played a move and assumed a move).

I start at 19 in Crafty, just because it seems like the right thing to do. And it helps on infrequent occasions, and can rarely hurt, so...
The question, as well as the discussion we already had about it, was how to react on a ponderhit. It seems you are talking about how you start pondering.

Sven
Maybe I misunderstood.

When I start any search, I set a target time, and a max time. When I start pondering, so long as I am pondering, the time-out test is not done. Once I get a move, if it matches, I now start to do the normal time-out testing, as though I was not pondering at all. That is, if my target is 60 seconds, and you think for 5 minutes and then make the predicted move, at that instant I say "whoa, I have used 5 minutes of thinking, move NOW." If I have used less than 60 seconds, I compute until 60 seconds are gone, and move, unless the usual fail-low time extension gets triggered. The goal is to accumulate extra time.
Chang

Re: Iteration in pondering

Post by Chang »

mar wrote:
Chang wrote:Hi,

Thanks for any advices.

Best regards,
Teerapong
No what you describe is a ponderhit and the program simply continues searching. Only if it misses the guessed move (pondermiss) it aborts and restarts from depth 1.

Martin
Hi Martin,

Thanks for the idea. My original question is when ponderhit, after switching from pondering() to thinking(), what depth to start? I didn't think of thinking() in pondering(). I get it done already. Thanks again.

Teerapong
AgentEE7

Re: Iteration in pondering

Post by AgentEE7 »

The goal shouldn't be to just accumulate the extra time but to use it effectively. If you have consecutive ponder hits you could just keep accumulating extra time instead of using it to your advantage. With a lot of ponder hits you could be minimizing any advantage gained by pondering.

It would seem that a better approach for ponder hits would be to use at least half of the time saved by pondering now and saving the rest for later. That way you benefit to some extent both on the current move and on future moves with extra time and the additional hash table entries generated.
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Iteration in pondering

Post by bob »

AgentEE7 wrote:The goal shouldn't be to just accumulate the extra time but to use it effectively. If you have consecutive ponder hits you could just keep accumulating extra time instead of using it to your advantage. With a lot of ponder hits you could be minimizing any advantage gained by pondering.

It would seem that a better approach for ponder hits would be to use at least half of the time saved by pondering now and saving the rest for later. That way you benefit to some extent both on the current move and on future moves with extra time and the additional hash table entries generated.
Each time I get a ponder hit and save time, the target time per move creeps up... So I am not sure exactly what you mean. What is special about "this move" Apparently your move ordering is already good, and the search is following the correct path, because your opponent did exactly what you expected him to do. It makes more sense to use more time when you get a ponder miss. What did you overlook to predict the wrong move???
AgentEE7

Re: Iteration in pondering

Post by AgentEE7 »

OK, say you get four (or even more) ponder hits in a row, and each time you move without using further time because you pondered slightly longer than your allocated time. So during this period you are moving without using any of your clock time, just saving it for later. It seems reasonable to use at least some of your allocated time during this sequence of moves. (Your target time creeping up isn't helping you any over this sequence of moves.)

This sequence of four (or even more) moves could contain a key game position that you neglect allocating any of your time to and you will actually be spending the exact same amount of time as your opponent during this sequence - when you could be benefitting from the ponder time you have gained. If this was a critical sequence of moves you have squandered a potential time advantage.

It just makes sense to me to spread your gain out (in some way) over all remaining moves including the current move. Any move (or sequence of moves) could be the critical move - including moves where both engines thinking for the same amount of time select the same move. Maybe if you look a little longer than the opposing engine you will see what both engines missed when using the same amount of time. (This argument doesn't require a sequence of consecutive ponder hits - but such a sequence demonstrates how just saving time for the future can have a cummulative effect on a potential missed opportunities.)

Of course you can save your time for later - but you might miss a key move now. (In general, the sooner you get an advantage the better.) In my opinion it's best to compromise and use some of the gained time now, while also saving some for later.
User avatar
hgm
Posts: 28447
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Iteration in pondering

Post by hgm »

Well, that basically re-iterates what I said in the beginning of this thread. This is especially clear when the number of remaining moves is 0 or 1, and when you are facing a massive fail low in the current search.
AgentEE7

Re: Iteration in pondering

Post by AgentEE7 »

Thanks for the comments. Do you agree with my logic in general - regardless of remaining moves to time control or fail low status?
User avatar
hgm
Posts: 28447
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Iteration in pondering

Post by hgm »

Well, let me put it this way: why would I have argued the same thing before if I did not agree with it?
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Iteration in pondering

Post by bob »

AgentEE7 wrote:OK, say you get four (or even more) ponder hits in a row, and each time you move without using further time because you pondered slightly longer than your allocated time. So during this period you are moving without using any of your clock time, just saving it for later. It seems reasonable to use at least some of your allocated time during this sequence of moves. (Your target time creeping up isn't helping you any over this sequence of moves.)

This sequence of four (or even more) moves could contain a key game position that you neglect allocating any of your time to and you will actually be spending the exact same amount of time as your opponent during this sequence - when you could be benefitting from the ponder time you have gained. If this was a critical sequence of moves you have squandered a potential time advantage.

It just makes sense to me to spread your gain out (in some way) over all remaining moves including the current move. Any move (or sequence of moves) could be the critical move - including moves where both engines thinking for the same amount of time select the same move. Maybe if you look a little longer than the opposing engine you will see what both engines missed when using the same amount of time. (This argument doesn't require a sequence of consecutive ponder hits - but such a sequence demonstrates how just saving time for the future can have a cummulative effect on a potential missed opportunities.)

Of course you can save your time for later - but you might miss a key move now. (In general, the sooner you get an advantage the better.) In my opinion it's best to compromise and use some of the gained time now, while also saving some for later.
My take is this: If I can identify a position, with a concrete reason, I'm willing to spend more than the usual time. One good example is a fail-low, or just a score drop (in Crafty, if the score drops 0.01 from the previous iteration, I will use more than the normal target time.

However, that being said, I don't see any gain for searching longer when I get a ponder hit. In that 4 move sequence you mentioned, each successive ponder search will have a longer target time, and at least one or two of those will use more than the normal time anyway because of my very "thin" score drop triggers extra time, because the margin is tiny.

Wouldn't it make just as much sense to just pick a random move and take longer than usual? A good program will correctly predict its opponent 50% of the time or higher, I don't want to burn 1/2 of the saved time on each of those, I'd rather save it for when the position dictates a longer search.