Play a perfect game of Mu Torere
Ruby, 390 chars
o=-&gt;s,c{f=s=~/o/;[*0..8].select{|t|s[t]==c&amp;&amp;(t&lt;1||(t+6)%8+1==f||t%8+1==f||f&lt;1&amp;&amp;(s[(t+6)%8+1]!=c||s[t%8+1]!=c))}.map{|t|k=s*1;k[f]=c;k[t]=?o;k}}
v=-&gt;s,c,h{f=o[s,c];f==[]?0:h&lt;1?1:2-f.map{|t|v[t,c&gt;?b??b:?w,h-1]}.min}
q=-&gt;g{puts&quot;1-2-3\n|\\|/|\n8-0-4\n|/|\\|\n7-6-5\n&quot;.tr&quot;0-8&quot;,g;$&gt;.flush}
q[g=&quot;obbbbwwww&quot;]
(g.tr!?o,?b;g[gets.to_i]=?o;q[g];q[g=o[g,?w].sort_by{|q|v[q,?w,5]}[-1]])while v[g,?b,5]&gt;0

An implementation in ruby which directly calculates the game tree (which takes quite some code) and thus always plays optimally. The board positions are spiraling outwards as shown in the following figure:
1 - 2 - 3
| \ | / |
8 - 0 - 4
| / | \ |
7 - 6 - 5