It is currently Fri May 02, 2025 4:57 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 43 posts ]  Go to page 1, 2, 3  Next
Author Message
Offline
 Post subject: visualizing valid and invalid go states
Post #1 Posted: Thu Jun 19, 2014 8:47 pm 
Dies with sente

Posts: 109
Liked others: 8
Was liked: 4
Rank: KGS 4 kyu
KGS: kneh
We can consider a go state as a combination of two bitstrings, where the length of
of those bitstrings is equal to the number of locations on the goban.

So for instance, on a 2x2 goban, there are 4 locations and hence 2^4=16 possible
patterns of stones of one color and on a 3x3 goban, there are 9 locations and
hence 2^9=512 possible patterns of stones of one color.

A combination of two bitstrings of length N is equivalent to a bitstring of
length 2N and amongst those, there are 3^N possible combinations of two mutually
exclusive bitstrings of length N.

Since in any location there can be either a white stone, or a black stone, but
not both, we can see that the number of possible go states
is 3^N, embedded in (2^N)(2^N) = 2^(2N) possible combinations of two
bitstrings of length N, where N is the number of locations on the goban.

So, on a 2x2 goban, there are 3^4 = 81 possible patterns of stones
of two colors, embedded in a spectrum of 256=(2^4)(2^4)=(2^8) possible
combinations of two patterns of stones of one color.
On a 3x3 goban, there are 3^9=19683 possible patterns of stones of two colors,
embedded in a spectrum of 262144=(2^9)(2^9)=(2^18) possible combinations of
two patterns of stones of one color.

A valid go state is one where there are no stones or chains that lack
liberties.
On a 2x2 goban, there are 24 invalid go states and 57 valid go states (24+57=81).
This can be visualized as follows (white stones represent valid states and black
stones invalid states):

http://i.imgur.com/CucxhXS.jpg

To illustrate the way bitstrings are combined, here is a version
that includes an index of the complete spectrum of all possible bitstrings
(in this case of length 4) for both dimensions:

http://i.imgur.com/iDlDKfL.jpg


On a 3x3 goban, there are 7008 invalid go states and 12675 valid go states (7008+12675=19683).
This can be visualized in multiple ways, depending on how the locations on the goban are mapped
to positions of bits in the bitstring:

014
235
678

http://i.imgur.com/b3YmbLD.jpg

012
345
678

http://i.imgur.com/is5PAGW.jpg


Last edited by dohduhdah on Sun Jun 22, 2014 3:07 pm, edited 3 times in total.
Top
 Profile  
 
Offline
 Post subject:
Post #2 Posted: Thu Jun 19, 2014 9:03 pm 
Honinbo
User avatar

Posts: 8859
Location: Santa Barbara, CA
Liked others: 349
Was liked: 2076
GD Posts: 312
Because of the symmetries, do you want to divide by 4 ?

( Of course, because of the huge number at 19x19,
dividing by 4 is insignificant because it's still on the same order of magnitude. )

Top
 Profile  
 
Offline
 Post subject: Re:
Post #3 Posted: Thu Jun 19, 2014 9:08 pm 
Dies with sente

Posts: 109
Liked others: 8
Was liked: 4
Rank: KGS 4 kyu
KGS: kneh
EdLee wrote:
Because of the symmetries, do you want to divide by 4 ?

( Of course, because of the huge number at 19x19,
dividing by 4 is insignificant because it's still on the same order of magnitude. )


Well, most patterns occur in 16 variations (if we include variations obtained by reflections, rotations
and interchanging colors).

Top
 Profile  
 
Offline
 Post subject: Re: visualizing valid and invalid go states
Post #4 Posted: Sun Jun 22, 2014 6:57 am 
Lives in sente

Posts: 1045
Liked others: 0
Was liked: 182
Are you sure about the number of possible legal states for an intersection?

I can see at least four.
a) has a black stone
b) has a white stone
c) has no stone and may be played upon by either side
d) has no stone but may not be played upon by the side having the move (the result of a ko capture).

There are of course other possible ways of encoding the latter so as not to require a state for each intersection and that might save significant space. But space and time often trade off and there might be major (time) advantages for keeping the number of states a power of two.

Top
 Profile  
 
Offline
 Post subject: Re: visualizing valid and invalid go states
Post #5 Posted: Sun Jun 22, 2014 7:33 am 
Dies with sente

Posts: 109
Liked others: 8
Was liked: 4
Rank: KGS 4 kyu
KGS: kneh
Mike Novack wrote:
Are you sure about the number of possible legal states for an intersection?

I can see at least four.
a) has a black stone
b) has a white stone
c) has no stone and may be played upon by either side
d) has no stone but may not be played upon by the side having the move (the result of a ko capture).

There are of course other possible ways of encoding the latter so as not to require a state for each intersection and that might save significant space. But space and time often trade off and there might be major (time) advantages for keeping the number of states a power of two.


Well, the numbers I get with my prolog program that differentiates between valid and invalid
states corresponds to the numbers found in online info (though I only checked for the 2x2 and 3x3
cases):

http://en.wikipedia.org/wiki/Go_and_mathematics
http://senseis.xmp.net/?NumberOfPossibleOutcomesOfAGame

I think (super)ko is a concept at the level of sequences of states rather than individual states,
because it involves excluding repetition in any sequence of states (like a sequence of states
that might occur from a given state as both sides play valid moves).
So this can be excluded from consideration when dealing with individual states, just like the side
which is to move is left out of consideration.

For any given individual state, we can consider it in the context of information like where this
state occured in a tree of possible game progressions, which dictates additional aspects like which
side is to move and which empty spots can't be played because of the (super)ko rule to avoid
repetition in the sequence of states from the root of the game tree to the given state.

Top
 Profile  
 
Offline
 Post subject: Re: visualizing valid and invalid go states
Post #6 Posted: Sun Jun 22, 2014 7:37 am 
Gosei
User avatar

Posts: 1585
Location: Barcelona, Spain (GMT+1)
Liked others: 577
Was liked: 298
Rank: KGS 5k
KGS: RBerenguel
Tygem: rberenguel
Wbaduk: JohnKeats
Kaya handle: RBerenguel
Online playing schedule: KGS on Saturday I use to be online, but I can be if needed from 20-23 GMT+1
dohduhdah wrote:
Mike Novack wrote:
Are you sure about the number of possible legal states for an intersection?

I can see at least four.
a) has a black stone
b) has a white stone
c) has no stone and may be played upon by either side
d) has no stone but may not be played upon by the side having the move (the result of a ko capture).

There are of course other possible ways of encoding the latter so as not to require a state for each intersection and that might save significant space. But space and time often trade off and there might be major (time) advantages for keeping the number of states a power of two.


Well, the numbers I get with my prolog program that differentiates between valid and invalid
states corresponds to the numbers found in online info (though I only checked for the 2x2 and 3x3
cases):

http://en.wikipedia.org/wiki/Go_and_mathematics
http://senseis.xmp.net/?NumberOfPossibleOutcomesOfAGame

I think (super)ko is a concept at the level of sequences of states rather than individual states,
because it involves excluding repetition in any sequence of states (like a sequence of states
that might occur from a given state as both sides play valid moves).
So this can be excluded from consideration when dealing with individual states, just like the side
which is to move is left out of consideration.

For any given individual state, we can consider it in the context of information like where this
state occured in a tree of possible game progressions, which dictates additional aspects like which
side is to move and which empty spots can't be played because of the (super)ko rule to avoid
repetition in the sequence of states from the root of the game tree to the given state.


Oh, I'd love to see the code! I like Prolog, but rarely find any use for it in my day-to-day or even mildly for-fun activities

_________________
Geek of all trades, master of none: the motto for my blog mostlymaths.net

Top
 Profile  
 
Offline
 Post subject: Re: visualizing valid and invalid go states
Post #7 Posted: Sun Jun 22, 2014 7:47 am 
Dies with sente

Posts: 109
Liked others: 8
Was liked: 4
Rank: KGS 4 kyu
KGS: kneh
http://i.imgur.com/qRsWI54.jpg

This is a version for a 2x2x2 goban (3 dimensional), where there are 3^8 = 6561 possible states
(embedded in 256^2=65536 possible combinations of two bitstrings of length 8).
Of those, 1288 are invalid and 5273 valid.

Top
 Profile  
 
Offline
 Post subject: Re: visualizing valid and invalid go states
Post #8 Posted: Sun Jun 22, 2014 7:57 am 
Dies with sente

Posts: 109
Liked others: 8
Was liked: 4
Rank: KGS 4 kyu
KGS: kneh
RBerenguel wrote:
Oh, I'd love to see the code! I like Prolog, but rarely find any use for it in my day-to-day or even mildly for-fun activities


http://pastebin.com/QHuWrjsG

Various libraries of SICStus prolog 3.8.4 are used (system, lists, random, ordsets).

The code is a bit of a hack of code I had created earlier to visualize prime numbers and the Moebius function:

http://commons.wikimedia.org/wiki/Categ ... oebius.jpg

It presupposes having a folder at "d:\prog\go" and having 6 (small) square jpg files there:

0.jpg = empty - middle
1.jpg = black stone
2.jpg = white stone
3.jpg = empty - lower right corner
4.jpg = empty - bottom side
5.jpg = empty - right side

You could save and rename these files:
http://i.imgur.com/UGEp3Ht.jpg
http://i.imgur.com/aK3Em8j.jpg
http://i.imgur.com/MALazOK.jpg
http://i.imgur.com/Q2uZ3HS.jpg
http://i.imgur.com/kYlhWAu.jpg
http://i.imgur.com/BGaD5Ly.jpg


Those images are composed using imagemagick (which is supposed to be installed for it to work), via
the 'montage' commandline utility.

http://www.imagemagick.org/


Last edited by dohduhdah on Sun Jun 22, 2014 8:41 am, edited 2 times in total.
Top
 Profile  
 
Offline
 Post subject: Re: visualizing valid and invalid go states
Post #9 Posted: Sun Jun 22, 2014 8:18 am 
Gosei
User avatar

Posts: 1585
Location: Barcelona, Spain (GMT+1)
Liked others: 577
Was liked: 298
Rank: KGS 5k
KGS: RBerenguel
Tygem: rberenguel
Wbaduk: JohnKeats
Kaya handle: RBerenguel
Online playing schedule: KGS on Saturday I use to be online, but I can be if needed from 20-23 GMT+1
Phew, quite a lot of rules in there, I'd need to take my time. Also lots of cuts, I hope they are green ;)

Edit: All of my prolog code, ever was hacky, by the way (and most of any of my code...)

_________________
Geek of all trades, master of none: the motto for my blog mostlymaths.net

Top
 Profile  
 
Offline
 Post subject: Re: visualizing valid and invalid go states
Post #10 Posted: Sun Jun 22, 2014 8:49 am 
Dies with sente

Posts: 109
Liked others: 8
Was liked: 4
Rank: KGS 4 kyu
KGS: kneh
RBerenguel wrote:
Phew, quite a lot of rules in there, I'd need to take my time. Also lots of cuts, I hope they are green ;)

Edit: All of my prolog code, ever was hacky, by the way (and most of any of my code...)


Well, not all code is used, some are utility predicates for prototyping and checking.
Some code may also be left over from the original code where I extracted sections that could be
used for how the image is built recursively from smaller pieces.

Sorry about the sparing commenting in the code and I'm sure it's suboptimal, because I don't
code very frequently. :-)

To quickly check the number of invalid states, you can simply do something like:

generatex2(8, X)? X=24

generatex2(18, X)? X=7008

http://i.imgur.com/py9y9Q0.png


Last edited by dohduhdah on Sun Jun 22, 2014 2:40 pm, edited 1 time in total.
Top
 Profile  
 
Offline
 Post subject: Re: visualizing valid and invalid go states
Post #11 Posted: Sun Jun 22, 2014 9:19 am 
Gosei
User avatar

Posts: 1585
Location: Barcelona, Spain (GMT+1)
Liked others: 577
Was liked: 298
Rank: KGS 5k
KGS: RBerenguel
Tygem: rberenguel
Wbaduk: JohnKeats
Kaya handle: RBerenguel
Online playing schedule: KGS on Saturday I use to be online, but I can be if needed from 20-23 GMT+1
No need to apologise. I code very frequently and comment sparingly and have a lot of funky spaghetti most of the time. All I care about is if it works, if it does, it's fine by now. If it is code I need to reuse or anything I try to improve and comment, but every time I've tried to make it a priority, getting to "works relatively ok" took 10 times as much ;)

_________________
Geek of all trades, master of none: the motto for my blog mostlymaths.net

Top
 Profile  
 
Offline
 Post subject: Re: visualizing valid and invalid go states
Post #12 Posted: Sun Jun 22, 2014 11:49 am 
Lives in sente

Posts: 1045
Liked others: 0
Was liked: 182
I was referring to ordinary ko (whether a ko state exists and if so, for black or for white, is part of the state of the board).

I intentionally mentioned this in terms of information for each intersection but because only one intersection at a time can have a ko state this information might better be stored (for boards up to 22*22) as 11 bits, 2 bits for doesn't exist, exists for black, exists for white and then 9 to specify the intersection.

I am referring to bits because you began with "what is the minimal bitstring". Practical considerations like language and what space/time tradeoffs might be wise depending on how to be processed another matter entirely.

Top
 Profile  
 
Offline
 Post subject: Re: visualizing valid and invalid go states
Post #13 Posted: Sun Jun 22, 2014 1:21 pm 
Dies with sente

Posts: 109
Liked others: 8
Was liked: 4
Rank: KGS 4 kyu
KGS: kneh
Mike Novack wrote:
I was referring to ordinary ko (whether a ko state exists and if so, for black or for white, is part of the state of the board).

I intentionally mentioned this in terms of information for each intersection but because only one intersection at a time can have a ko state this information might better be stored (for boards up to 22*22) as 11 bits, 2 bits for doesn't exist, exists for black, exists for white and then 9 to specify the intersection.

I am referring to bits because you began with "what is the minimal bitstring". Practical considerations like language and what space/time tradeoffs might be wise depending on how to be processed another matter entirely.


No, that's my point.. it's *not* part of the state of the board. You don't need to store it in the state of the board,
because it follows from the sequence of states that occurred previously whether or not there is a ko situation.

Also, I'm not talking about a minimal bitstring. I'm just saying that a bitstring is all you need for the pattern of stones of
one color. Since there are only two colors involved, a combination of two bitstrings can be used in a very straightforward way
to encode both patterns. It's not intended as a minimal way to encode states, just a very intuitive way as there is a
very straightforward correspondence between the pattern of stones and the bitstring encoding that pattern of stones.

Top
 Profile  
 
Offline
 Post subject: Re: visualizing valid and invalid go states
Post #14 Posted: Sun Jun 22, 2014 1:37 pm 
Lives in sente

Posts: 1045
Liked others: 0
Was liked: 182
dohduhdah wrote:

No, that's my point.. it's *not* part of the state of the board. You don't need to store it in the state of the board,
because it follows from the sequence of states that occurred previously whether or not there is a ko situation.


We are maybe not speaking the same "language"?

If you are willing to consider "the state of the board" to include information from the previous states of the board then it could take (for example)only 10 bits! (nine to specify intersection and one to specify if a black or white stone) for this move << since the current move plus all the previous moves specify the current state of the board >>

The sense in which I am using the term "state of the board" would not require any additional information about how arrived at that state. Equivalent to "state of a go game".

Top
 Profile  
 
Offline
 Post subject: Re: visualizing valid and invalid go states
Post #15 Posted: Sun Jun 22, 2014 1:57 pm 
Dies with sente

Posts: 109
Liked others: 8
Was liked: 4
Rank: KGS 4 kyu
KGS: kneh
Mike Novack wrote:
dohduhdah wrote:

No, that's my point.. it's *not* part of the state of the board. You don't need to store it in the state of the board,
because it follows from the sequence of states that occurred previously whether or not there is a ko situation.


We are maybe not speaking the same "language"?

If you are willing to consider "the state of the board" to include information from the previous states of the board then it could take (for example)only 10 bits! (nine to specify intersection and one to specify if a black or white stone) for this move << since the current move plus all the previous moves specify the current state of the board >>

The sense in which I am using the term "state of the board" would not require any additional information about how arrived at that state. Equivalent to "state of a go game".


But how many bits are required to store states is completely irrelevant in the context of this discussion.
My only goal is to visualize the proportion of valid to invalid states and for that purpose, ko is irrelevant.

I'm talking about categorically valid/invalid go states, where this concept of validity is independent of the
context in which the state occurs. The fact that certain valid states can still be invalid in the context of a particular
game because of the ko or superko rule, doesn't detract from the utility of a categorical concept of validity of a go state,
defined strictly in terms of what patterns of stones are involved.

The kind of valid go states I'm talking about are the ones that KGS lets you create when you set up a board position via edit
in a custom game.

http://i.imgur.com/dSMQTqd.png

For instance, it allows me to create a valid state like this:
http://i.imgur.com/PpBBhtx.png

but not an invalid state like this:
http://i.imgur.com/peIDBbw.png


Last edited by dohduhdah on Sun Jun 22, 2014 3:51 pm, edited 3 times in total.
Top
 Profile  
 
Offline
 Post subject: Re: visualizing valid and invalid go states
Post #16 Posted: Sun Jun 22, 2014 2:21 pm 
Oza

Posts: 2495
Location: DC
Liked others: 157
Was liked: 443
Universal go server handle: skydyr
Online playing schedule: When my wife is out.
Depending on the ruleset, there is also a state where one side can play on an intersection, but the other side cannot because they would commit suicide, either for the stone played or for that stone and an attached group that was in atari.

Top
 Profile  
 
Offline
 Post subject: Re: visualizing valid and invalid go states
Post #17 Posted: Sun Jun 22, 2014 2:27 pm 
Dies with sente

Posts: 109
Liked others: 8
Was liked: 4
Rank: KGS 4 kyu
KGS: kneh
skydyr wrote:
Depending on the ruleset, there is also a state where one side can play on an intersection, but the other side cannot because they would commit suicide, either for the stone played or for that stone and an attached group that was in atari.


As far as I know, the ruleset doesn't make any difference regarding the number of positions KGS lets you set up when you edit a custom game.


Last edited by dohduhdah on Sun Jun 22, 2014 2:51 pm, edited 1 time in total.
Top
 Profile  
 
Offline
 Post subject: Re: visualizing valid and invalid go states
Post #18 Posted: Sun Jun 22, 2014 2:35 pm 
Oza

Posts: 2495
Location: DC
Liked others: 157
Was liked: 443
Universal go server handle: skydyr
Online playing schedule: When my wife is out.
dohduhdah wrote:
skydyr wrote:
Depending on the ruleset, there is also a state where one side can play on an intersection, but the other side cannot because they would commit suicide, either for the stone played or for that stone and an attached group that was in atari.


As far as I know, the ruleset doesn't make any difference regarding the number of positions kgs lets you set up when you edit a custom game.


It allows suicide under NZ rules but not the other rulesets. If you start from an arbitrary board position, are you concerned with whether or not anyone is able to play on a particular empty intersection legally? I mean apart from ko, which you said you did not care about because it depended on the order of previous moves, as I recall.

Top
 Profile  
 
Offline
 Post subject: Re: visualizing valid and invalid go states
Post #19 Posted: Sun Jun 22, 2014 2:45 pm 
Dies with sente

Posts: 109
Liked others: 8
Was liked: 4
Rank: KGS 4 kyu
KGS: kneh
skydyr wrote:
It allows suicide under NZ rules but not the other rulesets. If you start from an arbitrary board position, are you concerned with whether or not anyone is able to play on a particular empty intersection legally? I mean apart from ko, which you said you did not care about because it depended on the order of previous moves, as I recall.


I'm not concerned with moves at all. I'm concerned with states (a given position, like the way KGS lets
you set up a position in terms of stones on the goban, where all stones and chains have at least 1 liberty).
Moves are combinations of two states, so that's really irrelevant for the discussion regarding individual
states that are categorically valid or invalid.

Top
 Profile  
 
Offline
 Post subject: Re: visualizing valid and invalid go states
Post #20 Posted: Sun Jun 22, 2014 3:29 pm 
Tengen

Posts: 4382
Location: Caldas da Rainha, Portugal
Liked others: 499
Was liked: 733
Rank: AGA 3k
GD Posts: 65
OGS: Hyperpape 4k
Seriously, it's clear what the OP was interested in, and whether or not state is the right way to describe it, let's not waste our time on a dumb terminalogical point.

_________________
Occupy Babel!

Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 43 posts ]  Go to page 1, 2, 3  Next

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: Bing [Bot] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group