Permalink
Switch branches/tags
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
37 lines (29 sloc) 1.19 KB
# make the board
width n => make-cs n
height n => make-rs n
make-cs n, n > 0 => col n, make-cs (n - 1)
make-rs n, n > 0 => row n, make-rs (n - 1)
row m, col n => location l m n
location l _ _ => empty l 'black, empty l 'white
location l1 m n, location l2 j k, m = j, (n - k) = 1 => adjacent l1 l2, adjacent l2 l1
location l1 m n, location l2 j k, (m - j) = 1, n = k => adjacent l1 l2, adjacent l2 l1
# undirected paths of the same color
stone s l1 c, stone t l2 c, adjacent l1 l2 ~> :stone-edge s t
:stone-edge s t ~> :path s t
:stone-edge s t, :path t u ~> :path s u
# liveness
stone s l c, adjacent l n, empty n c ~> :liberty s
:liberty s ~> :alive s
:liberty s, :path s t ~> :alive t
# death
stone s _ _, !:alive s => dying s
dying s, ..stone s l _ => empty l 'black, empty l 'white
# external input: place a stone
@place-stone color m n, location loc m n, op color other, ..empty loc other => make-stone loc color
@make-stone loc color, ..empty loc color => stone s loc color
# performance testing rule:
board-fill, location _ m n, height max, m < max => place-stone 'black m n
board-fill, location _ m n, height max, m = max => place-stone 'black m n
# TODO ko
# TODO suicide rule
# TODO scoring game