Page 51 of 71

Re: This 'n' that

Posted: Mon Aug 10, 2020 6:17 am
by Bill Spight
Tryss wrote:All in all, I don't see how iterative deepening help in these kind of situations compared to a Depth-first search with backtracking.

To truly solve a problem like this, you need to fully explore all the branch of the tree, it doesn't matter in what order.
You don't need to fully explore all branches of the tree. Thank goodness! :) There is a whole branch of computer science literature aimed at improving upon brute force depth first search.

This is a small problem, with only 5 possibilities for the first move. 4 of them are wrong. With bad luck you could explore all 4 failing branches before hitting upon the path to the solution. Iterative deepening assures that you will always go down the right path at every level of depth. You won't spend a lot of time on failing paths at greater depths than the shallowest solution. :)

It turns out that this example is not a good one to show the advantage of iterative deepening, because the solution is at depth 5. :lol: But that was not my purpose. I meant to show a way to achieve systematic thoroughness in the calculation of variations. And as I said, I don't know of anyone who actually recommends it for humans in actual play. :)

Re: This 'n' that

Posted: Mon Aug 10, 2020 6:17 am
by John Fairbairn
All in all, I don't see how iterative deepening help in these kind of situations compared to a Depth-first search with backtracking.
My take on what Bill was suggesting is this:

Humans (amateurs at any rate) have a built-in propensity to do a depth-first search in any situation. When fighting wild animals or growing corn, that may be biologically the best policy, but in go it is full of pitfalls. The commonest - and I don't believe anyone reading this forum has never fallen in this pit - is to find a quick answer and to stop there. Turn the page and the pro explains various other wrinkles such as ko that you did not even look for.

Iterative deepening (perhaps not the ideal term here, as it tempts people to read computer science into it) seems a cheap way to ensure all (or most) alternatives are looked at.

You could maybe get the same effect by backtracking, but the human brain seems to find it harder to keep track that way.

Cue Irish joke which I'm sure Bill will appreciate: American tourist lost in Portlaoise asks native how to get to Dublin. Wise old native sucks on pipe and says, "well, if I was you I wouldn't start from here."

Re: This 'n' that

Posted: Mon Aug 10, 2020 6:27 am
by Bill Spight
John Fairbairn wrote:Cue Irish joke which I'm sure Bill will appreciate: American tourist lost in Portlaoise asks native how to get to Dublin. Wise old native sucks on pipe and says, "well, if I was you I wouldn't start from here."
American version:

But first, an aside. I read years ago that, in one form or other, one of the most widespread jokes across human cultures is the riddle, "Why did the chicken cross the road?"

Anyway, in the American version, a tourist is lost in Maine and asks an elderly gentleman how to get to, let us say, Boston. The elderly gentlman, who also smokes a pipe, takes it out of his mouth and says, "You can't get theah from heah."

Re: This 'n' that

Posted: Mon Aug 10, 2020 6:50 am
by Tryss
Bill Spight wrote: This is a small problem, with only 5 possibilities for the first move. 4 of them are wrong. With bad luck you could explore all 4 failing branches before hitting upon the path to the solution. Iterative deepening assures that you will always go down the right path at every level of depth. You won't spend a lot of time on failing paths at greater depths than the shallowest solution.
So you will stop once you found a solution? I believed that the goal was fully reading all the variations, and not just finding one line that works.

Re: This 'n' that

Posted: Mon Aug 10, 2020 7:36 am
by Bill Spight
Tryss wrote:
Bill Spight wrote: This is a small problem, with only 5 possibilities for the first move. 4 of them are wrong. With bad luck you could explore all 4 failing branches before hitting upon the path to the solution. Iterative deepening assures that you will always go down the right path at every level of depth. You won't spend a lot of time on failing paths at greater depths than the shallowest solution.
So you will stop once you found a solution? I believed that the goal was fully reading all the variations, and not just finding one line that works.
As I said, my goal here was to illustrate a method to achieve systematic thoroughness for study and training purposes. In this case there is little difference between brute force depth first search and iterative deepening, because the solution is at close to maximum depth. Here is a problem where the maximum depth is around 13, I think, maybe even 15.



I peeked at the solution, and it has a depth of around 6 or 7. Even if you didn't have the bad luck to pick the correct play last, you could spend a very long time on failing paths to relatively great depths. :mad: And since they are erroneous paths, how much light would they shed on the actual problem? :cry: It's not helpful to go too far afield. :)

Re: This 'n' that

Posted: Mon Aug 10, 2020 7:53 am
by Tryss
I guess my point can be resumed by : how do you know they are erroneous path if you don't explore them?

Re: This 'n' that

Posted: Mon Aug 10, 2020 8:45 am
by Bill Spight
Tryss wrote:I guess my point can be resumed by : how do you know they are erroneous path if you don't explore them?
With iterative deepening, you know when you find the solution at a certain depth.

Edit: I.e., you do explore them, but only to the depth of the shallowest solution. And, like in this problem, you may be able to disprove a play at a shallower depth. All first moves but one were disproved at depth 4, although the solution has depth 5.

That's for problems, anyway. For actual games, where you may never know the right path, then the general arguments for iterative deepening apply. Not that humans should use it in actual play, OC. :lol:

Re: This 'n' that

Posted: Tue Aug 11, 2020 8:27 am
by Bill Spight
Iterative broadening

Aha! It was Knotwilg's topic, Complexity as width x depth ( https://www.lifein19x19.com/viewtopic.php?f=15&t=17682 ) that got me thinking, if you can iteratively increase the depth, why not iteratively increase the width? :)

OC, there is literature on that, first by Matt Ginsberg three decades ago, with his paper, Iterative broadening ( https://www.aaai.org/Papers/AAAI/1990/AAAI90-033.pdf ), and also by Tristan Cazenave, with Iterative widening ( http://www.lamsade.dauphine.fr/~cazenav ... s/iw00.pdf ), which he developed further in Generalized widening ( http://www.lamsade.dauphine.fr/~cazenav ... openld.pdf ). Now, both are concerned with computerized search — Ginsberg says that iterative broadening is effective with more than 40,000 nodes :shock: —, but maybe either approach can be effectively adapted to human use.

Ginsberg's basic idea is to start with a narrow search, like width 2, to variable depth, and if you don't find a solution or good answer, increase the width. Cazenave's basic idea is to start with a minimal set of moves and do an iterative depth first search with them, widening the set if the search is unsuccessful. He has successfully applied it to open life and death problems in go with as many as 20 possible moves.

I haven't really studied Cazenave's papers, as his ideas are rather more elaborate than I have indicated. But I think I get Ginsberg's idea well enough to apply it to our little problem. :)

Ginsberg makes the following analogy. You are trying to buy a birthday present for a friend, a woman who likes horses. So you decide to buy her a book about Tennessee walking horses. After going to a few book stores and even a tack shop or two, without finding such a book. At this point you may decide to stop looking for that book and try something else.

His point is this. Suppose that the solution set is evenly distributed over the leaves of the search tree. Then depth first search (with backtracking) is as good as anything. But if the set is unevenly distributed, then not finding a solution after looking in a few leaves of a certain branch of the tree, even though it has not been exhaustively searched, is evidence that it is in a different branch. So you search narrowly, and if fail to find a solution, you broaden the search. Iterative broadening.

Ginsberg makes the point that if there is only one solution, which has an equal chance of being on any leaf, iterative broadening is no help. However, if you have heuristics that increases the probability that the solution lies in a certain branch, then failing to find the solution in that branch reduces the probability, and may justify switching to another branch.

Next I shall apply that idea to our problem. :)

Re: This 'n' that

Posted: Tue Aug 11, 2020 8:55 am
by John Fairbairn
Can someone please remind me of the very old tsumego heuristic where you assume one player can have two moves on a row. I've never actually tried using it, but from what I recall (very vaguely) it should work as a tool in iterative broadening, no?

Re: This 'n' that

Posted: Tue Aug 11, 2020 10:57 am
by Bill Spight
John Fairbairn wrote:Can someone please remind me of the very old tsumego heuristic where you assume one player can have two moves on a row. I've never actually tried using it, but from what I recall (very vaguely) it should work as a tool in iterative broadening, no?
Null move heuristic?

Re: This 'n' that

Posted: Tue Aug 11, 2020 1:37 pm
by John Fairbairn
Null move heuristic?
I haven't heard that term in the context I'm talking about (tsumego), but in any case it's not the term I'm after, it's the actual application. Is it for killing, or living, or both, is it a first-move or any-move technique? I've never actually used so I have no in-built memory of it.

Edit: Found it here! viewtopic.php?f=15&t=16066

Re: This 'n' that

Posted: Tue Aug 11, 2020 2:41 pm
by Bill Spight
Thanks for the reminder, John. :)

Re: This 'n' that

Posted: Tue Aug 11, 2020 3:20 pm
by Bill Spight
Progressive narrowing

I have taken another look at the topic John referenced. :) viewtopic.php?f=15&t=16066

It now seems to me that this heuristic, when it works, is a way of narrowing the search, not broadening it. In a problem or position of any appreciable difficulty, there will normally be more than three possibly relevant moves. :)

And then I thought about iterative deepening at depth 1. Really? Who does that? Well, who does that consciously?

Harkening back to Kotov's method in Think Like a Grandmaster, he started with identifying candidate moves. How did he do that? Among all of the possible moves on the chess board, some of them stood out, based upon knowledge, experience, and intuition. He had probably also learned some conscious heuristics, like look at checks or look at sacrifices.

It now strikes me that looking over the whole board and letting moves stand out to us is a way of unconsciously doing a depth 1 search that would take too much time, effort, and working memory to do consciously. And sometimes you see deeper than 1 move. :)

Then you follow up with a narrower conscious search.

Re: This 'n' that

Posted: Tue Aug 11, 2020 8:03 pm
by Bill Spight
A look at the heuristic

The heuristic, copied from that topic.
zermelo wrote:The 3-move tsumego rule: Assume that the problem is black to kill. Now let A, B, C be such intersections that if white would start at A, the only way for black to kill with 2 moves would be playing both B and C. Now the solution to the original problem has to start with black play at A, B, or C.
Click Here To Show Diagram Code
[go]$$Bc Case 1
$$ --------------
$$ | . . . . . . .
$$ | X X X X . . .
$$ | B O O . X . .
$$ | B . W O X . .
$$ | O O O X X . .
$$ | . O X . . . .
$$ | O O X . . . .
$$ | . X X . . . .
$$ | . . . . . . .
$$ | . . . , . . .[/go]
If :wc:, both of :bc: are necessary to kill. So :b1: must be one of these.
Click Here To Show Diagram Code
[go]$$Bc Case 2
$$ --------------
$$ | . . . . . . .
$$ | X X X X . . .
$$ | B O O B X . .
$$ | . W . O X . .
$$ | O O O X X . .
$$ | . O X . . . .
$$ | O O X . . . .
$$ | . X X . . . .
$$ | . . . . . . .
$$ | . . . , . . .[/go]
Ditto. The only common point is A-17, so :b1: must play there.
Click Here To Show Diagram Code
[go]$$Bc Case 3?
$$ --------------
$$ | . . . . . . .
$$ | X X X X . . .
$$ | . O O B X . .
$$ | W . B O X . .
$$ | O O O X X . .
$$ | . O X . . . .
$$ | O O X . . . .
$$ | . X X . . . .
$$ | . . . . . . .
$$ | . . . , . . .[/go]
This is not actually a case, because . . .
Click Here To Show Diagram Code
[go]$$Bc Case 3x
$$ --------------
$$ | . . . . . . .
$$ | X X X X . . .
$$ | B O O . X . .
$$ | W . B O X . .
$$ | O O O X X . .
$$ | . O X . . . .
$$ | O O X . . . .
$$ | . X X . . . .
$$ | . . . . . . .
$$ | . . . , . . .[/go]
This also kills, because of White's shortage of liberties.
Click Here To Show Diagram Code
[go]$$Bc Case 3??
$$ --------------
$$ | . . . . . . .
$$ | X X X X . . .
$$ | B O O W X . .
$$ | . B . O X . .
$$ | O O O X X . .
$$ | . O X . . . .
$$ | O O X . . . .
$$ | . X X . . . .
$$ | . . . . . . .
$$ | . . . , . . .[/go]
This is also not a case.
Click Here To Show Diagram Code
[go]$$Bc Case 3xx
$$ --------------
$$ | . . . . . . .
$$ | X X X X . . .
$$ | . O O W X . .
$$ | B B . O X . .
$$ | O O O X X . .
$$ | . O X . . . .
$$ | O O X . . . .
$$ | . X X . . . .
$$ | . . . . . . .
$$ | . . . , . . .[/go]
This also kills.

Finally.
Click Here To Show Diagram Code
[go]$$Bc White life
$$ --------------
$$ | . . . . . . .
$$ | X X X X . . .
$$ | W O O . X . .
$$ | . . . O X . .
$$ | O O O X X . .
$$ | . O X . . . .
$$ | O O X . . . .
$$ | . X X . . . .
$$ | . . . . . . .
$$ | . . . , . . .[/go]
If :wc:, White lives, even if Black plays two moves in a row. :b1: must be at A-17.

All of this information is available after depth first search at depth 3, except the necessity of both Black stones, given :w2:. We can check that, however, with another White play, i.e., with a depth 4 sequence. To do so we do not have to do a full depth 4 search. (If neither is necessary, then White will die at depth 3, given :w2: and two different Black plays.)
Click Here To Show Diagram Code
[go]$$Bc White dies at depth 3
$$ --------------
$$ | . . . . . . .
$$ | X X X X . . .
$$ | 1 O O 3 X . .
$$ | . 2 . O X . .
$$ | O O O X X . .
$$ | . O X . . . .
$$ | O O X . . . .
$$ | . X X . . . .
$$ | . . . . . . .
$$ | . . . , . . .[/go]
Assuming that we recognize that White is dead without further search, we can check whether :b3: is necessary, given :w2:, by the following sequence.
Click Here To Show Diagram Code
[go]$$Bc White lives at depth 4
$$ --------------
$$ | . . . . . . .
$$ | X X X X . . .
$$ | 1 O O 4 X . .
$$ | 3 2 . O X . .
$$ | O O O X X . .
$$ | . O X . . . .
$$ | O O X . . . .
$$ | . X X . . . .
$$ | . . . . . . .
$$ | . . . , . . .[/go]
And we can check whether :b1: is necessary, given :w2: with the following sequences.
Click Here To Show Diagram Code
[go]$$Bc White lives at depth 4
$$ --------------
$$ | . . . . . . .
$$ | X X X X . . .
$$ | 4 O O 1 X . .
$$ | 3 2 . O X . .
$$ | O O O X X . .
$$ | . O X . . . .
$$ | O O X . . . .
$$ | . X X . . . .
$$ | . . . . . . .
$$ | . . . , . . .[/go]

Click Here To Show Diagram Code
[go]$$Bc White lives at depth 4
$$ --------------
$$ | . . . . . . .
$$ | X X X X . . .
$$ | 4 O O 1 X . .
$$ | . 2 3 O X . .
$$ | O O O X X . .
$$ | . O X . . . .
$$ | O O X . . . .
$$ | . X X . . . .
$$ | . . . . . . .
$$ | . . . , . . .[/go]

Edit: I realized that we have to check both plays for :b3:.

Neither of these depth 4 sequences fits neatly into the category of iterative deepening or iterative broadening, although the verification sequence is one step deeper and one step wider.
Click Here To Show Diagram Code
[go]$$Bc White dies at depth 3, II
$$ --------------
$$ | . . . . . . .
$$ | X X X X . . .
$$ | 1 O O . X . .
$$ | 3 . 2 O X . .
$$ | O O O X X . .
$$ | . O X . . . .
$$ | O O X . . . .
$$ | . X X . . . .
$$ | . . . . . . .
$$ | . . . , . . .[/go]
Now to check whether :b1: is necessary, given :w2:.
Click Here To Show Diagram Code
[go]$$Bc White lives at depth 4, II
$$ --------------
$$ | . . . . . . .
$$ | X X X X . . .
$$ | 4 O O 3 X . .
$$ | 1 . 2 O X . .
$$ | O O O X X . .
$$ | . O X . . . .
$$ | O O X . . . .
$$ | . X X . . . .
$$ | . . . . . . .
$$ | . . . , . . .[/go]
Click Here To Show Diagram Code
[go]$$Bc White lives at depth 4, II
$$ --------------
$$ | . . . . . . .
$$ | X X X X . . .
$$ | 4 O O . X . .
$$ | 1 3 2 O X . .
$$ | O O O X X . .
$$ | . O X . . . .
$$ | O O X . . . .
$$ | . X X . . . .
$$ | . . . . . . .
$$ | . . . , . . .[/go]
Edit: Added later.

:b1: is necessary, given :w2:.

The only point common to both triplets is A-17, which must then be Black's first move. We discovered that with only five (Edit: I can't count. :lol: ) sequences at depth 4. When this happens it is a more efficient way to discover Black's first move than iterative deepening, which requires several depth 4 sequences. :)

Edit: Note that we cannot check necessity simply by changing the color of the Black stones. For instance:
Click Here To Show Diagram Code
[go]$$Bc White dies
$$ --------------
$$ | . . . . . . .
$$ | X X X X . . .
$$ | . O O B X . .
$$ | W . B O X . .
$$ | O O O X X . .
$$ | . O X . . . .
$$ | O O X . . . .
$$ | . X X . . . .
$$ | . . . . . . .
$$ | . . . , . . .[/go]
Click Here To Show Diagram Code
[go]$$Bc White lives
$$ --------------
$$ | . . . . . . .
$$ | X X X X . . .
$$ | . O O W X . .
$$ | W . B O X . .
$$ | O O O X X . .
$$ | . O X . . . .
$$ | O O X . . . .
$$ | . X X . . . .
$$ | . . . . . . .
$$ | . . . , . . .[/go]
Click Here To Show Diagram Code
[go]$$Bc White lives
$$ --------------
$$ | . . . . . . .
$$ | X X X X . . .
$$ | . O O B X . .
$$ | W . W O X . .
$$ | O O O X X . .
$$ | . O X . . . .
$$ | O O X . . . .
$$ | . X X . . . .
$$ | . . . . . . .
$$ | . . . , . . .[/go]

Re: This 'n' that

Posted: Wed Aug 12, 2020 4:21 am
by Bill Spight
Generalizing the heuristic

We can generalize the heuristic to any goal. For instance, suppose that White to play can live. Then:

Let A, B, C be such intersections that if Black would start at A, the only way for White to live with 2 moves would be playing both B and C. Now White to live has to start with a play at A, B, or C.

Now let's apply that to the position after :b1: at A-17 in our little problem.
Click Here To Show Diagram Code
[go]$$Wc White to play and live
$$ --------------
$$ | . . . . . . .
$$ | X X X X . . .
$$ | X O O . X . .
$$ | . . . O X . .
$$ | O O O X X . .
$$ | . O X . . . .
$$ | O O X . . . .
$$ | . X X . . . .
$$ | . . . . . . .
$$ | . . . , . . .[/go]
Click Here To Show Diagram Code
[go]$$Wc White lives, I
$$ --------------
$$ | . . . . . . .
$$ | X X X X . . .
$$ | X O O W X . .
$$ | B W . O X . .
$$ | O O O X X . .
$$ | . O X . . . .
$$ | O O X . . . .
$$ | . X X . . . .
$$ | . . . . . . .
$$ | . . . , . . .[/go]
Only way to make a second eye, given :bc:.
Click Here To Show Diagram Code
[go]$$Wc White lives, II
$$ --------------
$$ | . . . . . . .
$$ | X X X X . . .
$$ | X O O . X . .
$$ | W B W O X . .
$$ | O O O X X . .
$$ | . O X . . . .
$$ | O O X . . . .
$$ | . X X . . . .
$$ | . . . . . . .
$$ | . . . , . . .[/go]
Only way to make a second eye, given :bc:.
Click Here To Show Diagram Code
[go]$$Wc Proof of necessity
$$ --------------
$$ | . . . . . . .
$$ | X X X X . . .
$$ | X O O W X . .
$$ | W B 4 O X . .
$$ | O O O X X . .
$$ | . O X . . . .
$$ | O O X . . . .
$$ | . X X . . . .
$$ | . . . . . . .
$$ | . . . , . . .[/go]
This way :b4: kills.
Click Here To Show Diagram Code
[go]$$Wc White lives, III
$$ --------------
$$ | . . . . . . .
$$ | X X X X . . .
$$ | X O O W X . .
$$ | . W B O X . .
$$ | O O O X X . .
$$ | . O X . . . .
$$ | O O X . . . .
$$ | . X X . . . .
$$ | . . . . . . .
$$ | . . . , . . .[/go]
Only way to make a second eye, given :bc:.
Click Here To Show Diagram Code
[go]$$Wc Proof of necessity
$$ --------------
$$ | . . . . . . .
$$ | X X X X . . .
$$ | X O O W X . .
$$ | W 4 B O X . .
$$ | O O O X X . .
$$ | . O X . . . .
$$ | O O X . . . .
$$ | . X X . . . .
$$ | . . . . . . .
$$ | . . . , . . .[/go]
This way :b4: kills.
Click Here To Show Diagram Code
[go]$$Wc White lives, IV
$$ --------------
$$ | . . . . . . .
$$ | X X X X . . .
$$ | X O O B X . .
$$ | W . W O X . .
$$ | O O O X X . .
$$ | . O X . . . .
$$ | O O X . . . .
$$ | . X X . . . .
$$ | . . . . . . .
$$ | . . . , . . .[/go]
Only way to make a second eye, given :bc:.

By inspection, no play belongs to all four triplets. Therefore there is no play by which White lives. (Also by inspection, there is no ko.)

White is dead. QED. :cool:

What?! :shock: What do you mean, QED? We already know (assume) that Black to play can prevent White from living without ko. The question is how does Black play to do that?

OK. Calm down. The information is there. For instance:
Click Here To Show Diagram Code
[go]$$Bc Black to play and kill
$$ --------------
$$ | . . . . . . .
$$ | X X X X . . .
$$ | 1 O O . X . .
$$ | 2 . . O X . .
$$ | O O O X X . .
$$ | . O X . . . .
$$ | O O X . . . .
$$ | . X X . . . .
$$ | . . . . . . .
$$ | . . . , . . .[/go]
Suppose that White plays :w2:. What is the triplet to live that does not contain :w2:?
Click Here To Show Diagram Code
[go]$$Wc White lives, III
$$ --------------
$$ | . . . . . . .
$$ | X X X X . . .
$$ | X O O W X . .
$$ | . W B O X . .
$$ | O O O X X . .
$$ | . O X . . . .
$$ | O O X . . . .
$$ | . X X . . . .
$$ | . . . . . . .
$$ | . . . , . . .[/go]
This is it. The Black stone tells Black where to play.
Click Here To Show Diagram Code
[go]$$Bc Black to play and kill
$$ --------------
$$ | . . . . . . .
$$ | X X X X . . .
$$ | 1 O O . X . .
$$ | 2 . 3 O X . .
$$ | O O O X X . .
$$ | . O X . . . .
$$ | O O X . . . .
$$ | . X X . . . .
$$ | . . . . . . .
$$ | . . . , . . .[/go]
Bingo! :D

Likewise:
Click Here To Show Diagram Code
[go]$$Bc Black to play and kill
$$ --------------
$$ | . . . . . . .
$$ | X X X X . . .
$$ | 1 O O 2 X . .
$$ | . . . O X . .
$$ | O O O X X . .
$$ | . O X . . . .
$$ | O O X . . . .
$$ | . X X . . . .
$$ | . . . . . . .
$$ | . . . , . . .[/go]
Where should Black play?
Click Here To Show Diagram Code
[go]$$Wc White lives, II
$$ --------------
$$ | . . . . . . .
$$ | X X X X . . .
$$ | X O O . X . .
$$ | W B W O X . .
$$ | O O O X X . .
$$ | . O X . . . .
$$ | O O X . . . .
$$ | . X X . . . .
$$ | . . . . . . .
$$ | . . . , . . .[/go]
This triplet does not contain :w2:. Play :b3: at :bc:.
Click Here To Show Diagram Code
[go]$$Bc Black to play and kill
$$ --------------
$$ | . . . . . . .
$$ | X X X X . . .
$$ | 1 O O 2 X . .
$$ | . 3 . O X . .
$$ | O O O X X . .
$$ | . O X . . . .
$$ | O O X . . . .
$$ | . X X . . . .
$$ | . . . . . . .
$$ | . . . , . . .[/go]
Bingo!

The Black replies to the other two White plays are obvious, but the same method works. :)

Is this superior to iterative deepening?

Well, maybe. It performs less search, because the two necessary stones do not dictate move order. And, OC, the second move in each sequence remains the same. However, the comparison of triplets is not something that the search algorithm does. This 'n' that. ;)