Files
@ 28c6f89a3a7e
Branch filter:
Location: OneEye/src/tests/util.py - annotation
28c6f89a3a7e
557 B
text/x-python
stone detection enhanced by edge subtraction
b06733513452 b06733513452 b06733513452 b06733513452 b06733513452 b06733513452 b06733513452 b06733513452 b06733513452 b06733513452 b06733513452 b06733513452 b06733513452 eb6c3126cf26 b06733513452 eb6c3126cf26 b06733513452 b06733513452 eb6c3126cf26 b06733513452 eb6c3126cf26 eb6c3126cf26 eb6c3126cf26 eb6c3126cf26 | import re
from go.core import Go
from statebag import BoardState
def simpleLoadSgf(filename):
with open(filename) as f:
contents=f.read()
g=lambda m: tuple(ord(c)-ord('a') for c in reversed(m.group(1)))
return [g(m) for m in re.finditer(r"\b[BW]\[([a-z]{2})\]",contents)]
def listBoards(moves):
g=Go()
res=[tuple(list(x for x in row) for row in g.board)]
for m in moves:
g.doMove(g.toMove,*m)
res.append(tuple(list(x for x in row) for row in g.board))
return res
def listStates(moves):
return [BoardState(b) for b in listBoards(moves)]
|