Markov chain GTP engine

For discussing go computing, software announcements, etc.
Post Reply
ethanb
Lives in gote
Posts: 355
Joined: Sat Apr 24, 2010 10:15 am
Rank: AGA 2d
GD Posts: 0
IGS: ethanb
Has thanked: 52 times
Been thanked: 43 times

Markov chain GTP engine

Post by ethanb »

I had an amusing idea the other night about writing a GTP engine that would use statistics from a database of (preferably pro, but whatever) games and decide its next move by constructing a low-order (probably 2 or 3 would provide the most interesting results) Markov chain and always choosing the highest-probability move UNLESS it is an illegal move, in which case choose the next highest.

If we run out of legal moves that make legitimate chains (or have somehow strayed from a path ever trod before), I guess then we can use some sort of Monte Carlo search or just pick a spot in a random common shape from the last same color stone played (one-space jump, two-space extension, keima, ogeima...)

My goal is not to make a super-strong bot (although I wager the Markov chain method would at least play a halfway decent opening) but just to have fun making it, really.
User avatar
Li Kao
Lives in gote
Posts: 643
Joined: Wed Apr 21, 2010 10:37 am
Rank: KGS 3k
GD Posts: 0
KGS: LiKao / Loki
Location: Munich, Germany
Has thanked: 115 times
Been thanked: 102 times

Re: Markov chain GTP engine

Post by Li Kao »

It might have a decent opening, but the midgame would be horrible. Total lack of life and death handling doesn't work well.
One way even a total beginner would beat it is by playing in a different quadrant every move and only return to the original quadrant after 4 moves.
Sanity is for the weak.
ethanb
Lives in gote
Posts: 355
Joined: Sat Apr 24, 2010 10:15 am
Rank: AGA 2d
GD Posts: 0
IGS: ethanb
Has thanked: 52 times
Been thanked: 43 times

Re: Markov chain GTP engine

Post by ethanb »

Oh yeah, obviously tenuki would confuse the heck out of it, but I expect the human player might be surprised by some unexpected "tenuki" too, even in the late opening (why did he just attach to the top of my 10-3 stone? Answer: because it was a normal extension in the most common sequence after the last joseki was played)

Really, I was driving home a few nights ago listening to the System Shock 2 soundtrack and realized that the evil computer voice "speech" during the credits track, while probably an actual human speaking into a microphone and then distorted beyond intelligibility, could also be done by taking samples of phonemes and analyzing a few audiobooks to provide some good patterns of sequences that are possible to pronounce, then using a low-order Markov chain to construct your almost understandable gibberish.

From there it was a short jump (in my tired state) to say "hey, I wonder how a Markov-based Go bot would play?" and decide it might be amusing enough to pursue. :)

Like all Markov-based things, it's more amusing if you try to assume the naive mindset that there's actually some sort of intelligence making these bizarre decisions (which is easy to do - after all, they all look logical in isolation, right?)


Anyone who doesn't know what a Markov chain is, it's an algorithm that constructs the next step in a given sequence based on statistical analysis of past data. Garkov is a good example, where it replaces the speech bubbles in Garfield strips with words based on analyzing a database with the text of all the strips (and generally is way more amusing than the original comic.) One thing I always wonder about things like Garkov though - how does it choose the first word? Based on what the most likely starting words are? Or does it pick a word from the database at random?
User avatar
daniel_the_smith
Gosei
Posts: 2116
Joined: Wed Apr 21, 2010 8:51 am
Rank: 2d AGA
GD Posts: 1193
KGS: lavalamp
Tygem: imapenguin
IGS: lavalamp
OGS: daniel_the_smith
Location: Silicon Valley
Has thanked: 152 times
Been thanked: 330 times
Contact:

Re: Markov chain GTP engine

Post by daniel_the_smith »

Interesting idea!

My initial thought is that Markov chains would not help much; it's necessary for the entire plan to cohere, and Markov chains would just make the bot change plans smoothly (and constantly). (And, of course, the bot wouldn't even have a concept of "plan"!) But I would be very happy to be proved wrong.
That which can be destroyed by the truth should be.
--
My (sadly neglected, but not forgotten) project: http://dailyjoseki.com
hyperpape
Tengen
Posts: 4382
Joined: Thu May 06, 2010 3:24 pm
Rank: AGA 3k
GD Posts: 65
OGS: Hyperpape 4k
Location: Caldas da Rainha, Portugal
Has thanked: 499 times
Been thanked: 727 times

Re: Markov chain GTP engine

Post by hyperpape »

I'll probably put my foot in my mouth, since I only know the capsule version of what Markov chains are, but is switching plans so bad? Take the fuseki--there are a number of longish sequences that have been played many times by professionals--20 moves or so for the whole board. A human playing those needs a plan, because he doesn't have the whole tree of moves in front of him, so he needs some way to generate reasonable moves. A bot using that tree doesn't need a plan--he doesn't need to look ahead--he'll keep choosing from the tree, and end up at a reasonable position, even if it's not one he anticipated ahead of time.

After the fuseki things might be different, because there's issues of global balance. Also, maybe this whole post just indicates that I'm thinking of something different by plans. Hopefully it's still a reasonable question.
jeff_elser
Beginner
Posts: 2
Joined: Wed Aug 04, 2010 7:42 am
Rank: KGS 10 kyu
GD Posts: 0

Re: Markov chain GTP engine

Post by jeff_elser »

I think this is an interesting idea. I've done some work using similar models for joseki and tesuji discovery.

You might consider dynamic Conditional Random Fields. They are a bit stronger than Markov models in that they are discriminative (as opposed to Markov models which are generative) which allows them to model conditional dependencies better (often resulting in better performance). Additionally CRFs would allow you to incorporate non-probabilistic measures like time left on clock, score, etc. The link below will get you started.

http://www.cs.umass.edu/~mccallum/paper ... torial.pdf
ethanb
Lives in gote
Posts: 355
Joined: Sat Apr 24, 2010 10:15 am
Rank: AGA 2d
GD Posts: 0
IGS: ethanb
Has thanked: 52 times
Been thanked: 43 times

Re: Markov chain GTP engine

Post by ethanb »

jeff_elser wrote:I think this is an interesting idea. I've done some work using similar models for joseki and tesuji discovery.

You might consider dynamic Conditional Random Fields. They are a bit stronger than Markov models in that they are discriminative (as opposed to Markov models which are generative) which allows them to model conditional dependencies better (often resulting in better performance). Additionally CRFs would allow you to incorporate non-probabilistic measures like time left on clock, score, etc. The link below will get you started.

http://www.cs.umass.edu/~mccallum/paper ... torial.pdf



That does sound interesting! But I think it's better for somebody who genuinely wishes to advance the state of Go AI research. I just want to spend an hour or so with libkombilo and libshogun and throw together a Python script that'll play horrendously. :)

I started to look at libkombilo's API already. Doesn't seem too bad; the main problem is that I probably don't want to wait for a database search to return after every move, so if I actually want to turn this into something that's not painful to play I'll have to do my path finding beforehand, which is slightly annoying for a project I don't want to take seriously.

On the other hand, maybe the search is fast enough for the simple cases we're talking about (a 19x19 grid with 2-4 stones and the rest of the board filled with "I don't care") that it'll just work out. I'll try it and we'll see.
Post Reply