diff --git a/src/go/engine.py b/src/go/engine.py --- a/src/go/engine.py +++ b/src/go/engine.py @@ -10,22 +10,17 @@ class SpecGo(core.Go): def __init__(self,boardSize=19): super().__init__(boardSize) - def load(self,state): - for (r,row) in enumerate(state): - for (c,x) in enumerate(row): - self.board[r][c]=x - def listRelevantMoves(self,diff): """There can be 3 different changes in the diff: additions, deletions and replacements. Additions can be taken as relevant right away. Deletions and replacements had to be captured, so we add their liberties. Also any non-missing stones of partially deleted (or replaced) groups had to be replayed, so add them too. - Needs to handle: Take n, return 1. Snapback. + Needs to handle snapback. There's no end to what could be theoretically relevant, but such sequences are long and we will pretend they won't happen.""" res=(set(),set()) for d in diff: (r,c,action,color)=d - colorKey=(1-color)<<1 # {-1,1}->{1,0} + colorKey=(1-color)>>1 # {-1,1}->{1,0} if action!="-" and (r,c) not in res[colorKey]: res[colorKey].add((r,c)) # this is rather sloppy but correct. the time will show if it is effective enough @@ -39,13 +34,13 @@ class SpecGo(core.Go): if ri>0: res[colorKey].add((ri-1,ci)) res[1-colorKey].add((ri-1,ci)) - if ri0: res[colorKey].add((ri,ci-1)) res[1-colorKey].add((ri,ci-1)) - if ci>1]: + for (r,c) in self._moveList[(1-g.toMove)>>1]: if g.board[r][c]!=EMPTY: continue neighbours=( g.board[r-1][c] if r>0 else None, - g.board[r+1][c] if r0 else None, - g.board[r][c+1] if c1: + toMove=-1*g.toMove seq=self.dfs(state2,limit-1) if seq: - seq.append((-1*g.toMove,r,c)) + seq.append((toMove,r,c)) return seq g.undoMove(r,c,captured) return False