diff --git a/src/go/engine.py b/src/go/engine.py --- a/src/go/engine.py +++ b/src/go/engine.py @@ -8,7 +8,7 @@ from . import core # @param colorOut {BLACK,WHITE}: color to close the sequence def getTransitionSequence(state1,state2,colorIn,colorOut,diff): eng.load(state1,diff) - eng.iterativelyDeepen(state2,colorIn,colorOut) + return eng.iterativelyDeepen(state2,colorIn,colorOut) class SpecGo(core.Go): @@ -69,6 +69,7 @@ class Engine: if seq: seq.reverse() return seq + return None def dfs(self,state2,limit): g=self._g @@ -80,10 +81,6 @@ class Engine: if m==PASS: # no reason for both players to pass self._moveList[(1-g.toMove)>>1].remove(m) - if g.hash()==state2.hash(): - self._undoMove(m,captured) - return [(g.toMove,*m)] - if limit>1: seq=self.dfs(state2,limit-1) if seq: @@ -91,8 +88,12 @@ class Engine: seq.append((g.toMove,*m)) return seq + if limit==1 and g.hash()==state2.hash(): + self._undoMove(m,captured) + return [(g.toMove,*m)] + self._undoMove(m,captured) - return False + return None def _undoMove(self,move,captured): g=self._g