diff --git a/src/imageanalyzer.py b/src/analyzer/__init__.py rename from src/imageanalyzer.py rename to src/analyzer/__init__.py --- a/src/imageanalyzer.py +++ b/src/analyzer/__init__.py @@ -1,13 +1,12 @@ import logging as log -from grid import Grid -from go import exportBoard -import go +from .grid import Grid +from go.core import exportBoard, EMPTY,BLACK,WHITE class ImageAnalyzer: def __init__(self,tresB=30,tresW=60): - self.board=[[go.EMPTY]*19 for r in range(19)] + self.board=[[EMPTY] * 19 for r in range(19)] self.grid=None self.tresB=tresB @@ -48,9 +47,9 @@ class ImageAnalyzer: log.debug("(%d,%d) ... (b=%d,w=%d,e=%d)", row, col, b, w, e) - if b>=w and b>=e: return go.BLACK - if w>=b and w>=e: return go.WHITE - return go.EMPTY + if b>=w and b>=e: return BLACK + if w>=b and w>=e: return WHITE + return EMPTY def setGridCorners(self,corners): self.grid=Grid(corners) diff --git a/src/corners.py b/src/analyzer/corners.py rename from src/corners.py rename to src/analyzer/corners.py --- a/src/corners.py +++ b/src/analyzer/corners.py @@ -1,4 +1,4 @@ -from epoint import EPoint +from .epoint import EPoint class Corners: diff --git a/src/epoint.py b/src/analyzer/epoint.py rename from src/epoint.py rename to src/analyzer/epoint.py diff --git a/src/grid.py b/src/analyzer/grid.py rename from src/grid.py rename to src/analyzer/grid.py --- a/src/grid.py +++ b/src/analyzer/grid.py @@ -1,5 +1,5 @@ import numpy -from epoint import EPoint +from .epoint import EPoint ## Projective transformation of a point with a matrix A. diff --git a/src/core.py b/src/core.py --- a/src/core.py +++ b/src/core.py @@ -5,8 +5,8 @@ import logging as log import PIL from util import MsgQueue from gui import gui -from imageanalyzer import ImageAnalyzer -from go import Go, isLegalPosition +from analyzer import ImageAnalyzer +from go.core import Go, isLegalPosition from statebag import StateBag import config as cfg diff --git a/src/go/__init__.py b/src/go/__init__.py new file mode 100644 diff --git a/src/go.py b/src/go/core.py rename from src/go.py rename to src/go/core.py --- a/src/go.py +++ b/src/go/core.py @@ -1,7 +1,7 @@ import logging as log from util import EMPTY,BLACK,WHITE,colorNames -from gamerecord import GameRecord +from .gamerecord import GameRecord class Go: diff --git a/src/gamerecord.py b/src/go/gamerecord.py rename from src/gamerecord.py rename to src/go/gamerecord.py diff --git a/src/gui/boardview.py b/src/gui/boardview.py --- a/src/gui/boardview.py +++ b/src/gui/boardview.py @@ -1,5 +1,5 @@ from .resizablecanvas import ResizableCanvas -from go import BLACK,WHITE +from go.core import BLACK,WHITE ## Handles and presents the game state as detected by the program. diff --git a/src/gui/imgview.py b/src/gui/imgview.py --- a/src/gui/imgview.py +++ b/src/gui/imgview.py @@ -4,10 +4,10 @@ from PIL import ImageTk import config from .resizablecanvas import ResizableCanvas -from corners import Corners -from epoint import EPoint -from grid import Grid -import imageanalyzer +from analyzer.corners import Corners +from analyzer.epoint import EPoint +from analyzer.grid import Grid +import analyzer class ImgView(ResizableCanvas): @@ -50,7 +50,7 @@ class ImgView(ResizableCanvas): if self._boardGrid!=None and config.gui.showBigPoints: for r in range(19): for c in range(19): - ((r1,c1),(r2,c2))=imageanalyzer.relevantRect(self._boardGrid.intersections[r][c], *(self._boardGrid.stoneSizeAt(r, c))) + ((r1,c1),(r2,c2))=analyzer.relevantRect(self._boardGrid.intersections[r][c], *(self._boardGrid.stoneSizeAt(r, c))) self.create_rectangle(r1,c1,r2,c2,outline="#00ffff") def setImg(self,img): diff --git a/src/statebag.py b/src/statebag.py --- a/src/statebag.py +++ b/src/statebag.py @@ -17,8 +17,8 @@ So we try to find the correct crossover - linearize the fork back by discarding s'_j-s preceding the crossover and s_j-s following the crossover """ -from util import BLACK,WHITE,EMPTY -from go import transitionSequence +from util import EMPTY +from go.core import transitionSequence ## Crude lower bound on edit distance between states. diff --git a/src/tests/testGo.py b/src/tests/testGo.py --- a/src/tests/testGo.py +++ b/src/tests/testGo.py @@ -1,6 +1,6 @@ from unittest import TestCase -from go import isLegalPosition +from go.core import isLegalPosition class TestLegal(TestCase):