Salvaging a timed-out iteration

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: Salvaging a timed-out iteration

Post by bob »

hgm wrote:My point was that 'last minute' merely means 'large depth'. Apparently there are ways to postpone the loss to a very late ply, or an earlier iteration would have already seen it before.

If you think that it is preferable to do the move that leads to such a late, but bigger loss than trying to limit the damage by giving less (but still lethal) material early on, because the opponent is much more likely to miss a deep tactic than an shallow one, the score should reflect it.

Imagine you would have finished the 20th iteration, with the conclusion that the move that looked good (say +0.03) on the 19th now does -8, and your best move of the 20th does -2.5. Wouldn't it still be better to go for the -8 than for the -2.5. And if you came from +5.03 in stead, would't it be better to go for a certain +2.5 than risk the -3? And wouldn't that be exactly the same even if you were able to finish a 21st iteration after that (confirming the scores of the 20th)?

So my point is that these are things that should be reflected by the score, and not by accidental timing effects.
I explained what I do, and I don't do any of the speculation at all. I simply pointed out that there were plenty of ideas around, including the one from Berliner. I also mentioned that were I to fiddle around with this, I would also take my opponent's supposed strength into consideration and I would be much more likely to speculate if playing a human as opposed to a computer...

As far as your example goes, it would depend. If I am playing (say) Rybka, I'm taking the best score period, and not speculating, because it is doubtful Rybka will overlook something that I saw. As a human, I certainly consider my opponent when choosing a move, particularly when things are "dicey". I also consider not just the "value being lost" but the actual final "value" as well, to handle the case I had mentioned previously, which has some vague notion of expected winning chances folded in.
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Salvaging a timed-out iteration

Post by bob »

One suggestion that works well. When time runs out, never stop the search until the current ply-1 move is completed, unless you overstep a second time limit that is at least 2x the original limit. Why? Often, if you are going to change your mind, you will run out of time on the last partial iteration, while the search is stuck trying to get the new best move search done. The bad moves are dismissed quickly, because of how efficient fail-low moves at the root are searched, but a fail-high move at the root can take 20-30 times as long to search, and you do not want to overlook a winning move just because you ran out of time. Since this is hard to determine at the time (is this move going to fail high), I just require than to time-out the search, (a) the time limit has to be reached or exceeded, or I have used 2x the time limit; or (b) I am ready to select a new move to try at the root, which means that all root moves so far have been completed.

This works well, although there is a bit of a trick in a parallel search if you choose to split everywhere in the tree, including at the root as I do... But that is also easy to solve efficiently as well...
User avatar
hgm
Posts: 28355
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Salvaging a timed-out iteration

Post by hgm »

bob wrote:As far as your example goes, it would depend. If I am playing (say) Rybka, I'm taking the best score period, and not speculating, because it is doubtful Rybka will overlook something that I saw.
This is again another issue, relating to opponent modelling and contempt. It can very well be accomodated in the scheme I mentioned, through tuning the parameters. In particular, the delayed-loss bonus, which sets how much you would be willing to sacrifice for delaying a given loss by one extra move. This should obviously be related to the probability that this extra move will push the loss over the opponent's horizon. It would be low against Rybka, and high against Chad's Chess.
User avatar
Don
Posts: 5106
Joined: Tue Apr 29, 2008 4:27 pm

Re: Salvaging a timed-out iteration

Post by Don »

bob wrote:
(1) makes good sense against humans and we did this in a very late version of Cray Blitz, a mode we could turn on or off at will. We used it all the time in OTB games against humans, and even against computers if we thought they were significantly weaker than CB.

There are lots of ways to speculate, but against a strong computer opponent they will all most likely fail badly...
Do you have any outstanding examples of that actually working in games? It sounds to me like a viable choice against weaker opponents but there is no easy way to asses this. There are two cases and they are both quite common. In one case you are losing badly but the computer doesn't yet realize it. The loss is such that natural moves lead to this loss and you might as well change to the "better" move which really may lose less.

In the other case, it's just as you say. There is a single hard to find refutation, and if the opponent doesn't find it, you are doing just fine. I once played a quickly losing move on purpose, because the normal move led to a slow but very easy and sure win for my opponent. The "tricky" move I chose led to a very quick loss if the opponent found the right response. This is pretty much the same idea. It worked for me because the opponent was quite a bit lower rated and presumably weaker.

I think the first case is more common, but I'm not sure without thinking about it more. But maybe it's still ok (if your opponent is weaker) because you would likely lose anyway.
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Salvaging a timed-out iteration

Post by bob »

Don wrote:
bob wrote:
(1) makes good sense against humans and we did this in a very late version of Cray Blitz, a mode we could turn on or off at will. We used it all the time in OTB games against humans, and even against computers if we thought they were significantly weaker than CB.

There are lots of ways to speculate, but against a strong computer opponent they will all most likely fail badly...
Do you have any outstanding examples of that actually working in games? It sounds to me like a viable choice against weaker opponents but there is no easy way to asses this. There are two cases and they are both quite common. In one case you are losing badly but the computer doesn't yet realize it. The loss is such that natural moves lead to this loss and you might as well change to the "better" move which really may lose less.

In the other case, it's just as you say. There is a single hard to find refutation, and if the opponent doesn't find it, you are doing just fine. I once played a quickly losing move on purpose, because the normal move led to a slow but very easy and sure win for my opponent. The "tricky" move I chose led to a very quick loss if the opponent found the right response. This is pretty much the same idea. It worked for me because the opponent was quite a bit lower rated and presumably weaker.

I think the first case is more common, but I'm not sure without thinking about it more. But maybe it's still ok (if your opponent is weaker) because you would likely lose anyway.
I don't have any particular positions. in 1995 or so I lost every last file I had when a disk system crashed and we discovered that all backups were also corrupted.

I think one of the JICCA articles Hans wrote mentioned this idea, as I believe that is where I first heard of it. I had come across the circumstance (we have a good move, but at the last iteration it fails low and while I am sitting there at the table trying to understand the output to see why it is suddenly bad at a deep depth, it finds a much easier way to lose instead even though it looks somewhat better in terms of raw score... That is the exact reason behind the "swindle mode" in crafty's EGTB handling. I saw it reach KRP vs KR endings where the KR side had to play _precisely_ to avoid losing. And rather than staying in the ending and making the opponent show that it could correctly defend, it would trade rooks or give up the pawn (both of which are still dead draws) but transform into a game a fish could draw. So I now take all the drawing moves and search just those, to find the drawing line that does not give up any material (and a chance to win if the opponent makes a mistake).

Hans' idea was a bit more speculative, but the idea made sense, at least with humans (speculating against a computer is always risky at best, downright foolish against strong opponents with good hardware) and we elected to use it. It seemed particularly effective at speed chess. I remember a game at the 1984 US Open speed chess championship we (Cray Blitz) were playing in. With Gutman (Korchnoi's second at the WC that year) watching, we threw away a queen. After the game, Gutman commented on the program's obvious blunder. I asked him what we should have played and he said something like "just take the rook, it is then an easy endgame to play..." We backed the game up to that point, took the rook, and CB announced a mate in 10 or 12 that blew him away. It sacrificed a queen to avoid a mate that a top-10 player in the world could not see at blitz speeds, and we were playing a 2000 player. Berliner's "fix" would have avoided our only loss in the event nicely, had we had it in at the time... I've seen quite a few such games over the years...