Changeset - 3798475f45c1
[Not reviewed]
default
6 5 7
Laman - 7 years ago 2017-12-05 00:27:22

refactoring: moving files around
12 files changed with 20 insertions and 21 deletions:
0 comments (0 inline, 0 general)
src/analyzer/__init__.py
Show inline comments
 
file renamed from src/imageanalyzer.py to src/analyzer/__init__.py
 
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)
src/analyzer/corners.py
Show inline comments
 
file renamed from src/corners.py to src/analyzer/corners.py
 
from epoint import EPoint
 
from .epoint import EPoint
 

	
 

	
 
class Corners:
src/analyzer/epoint.py
Show inline comments
 
file renamed from src/epoint.py to src/analyzer/epoint.py
src/analyzer/grid.py
Show inline comments
 
file renamed from src/grid.py to src/analyzer/grid.py
 
import numpy
 
from epoint import EPoint
 
from .epoint import EPoint
 

	
 

	
 
## Projective transformation of a point with a matrix A.
src/core.py
Show inline comments
 
@@ -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
 

	
src/go/__init__.py
Show inline comments
 
new file 100644
src/go/core.py
Show inline comments
 
file renamed from src/go.py to src/go/core.py
 
import logging as log
 

	
 
from util import EMPTY,BLACK,WHITE,colorNames
 
from gamerecord import GameRecord
 
from .gamerecord import GameRecord
 

	
 

	
 
class Go:
src/go/gamerecord.py
Show inline comments
 
file renamed from src/gamerecord.py to src/go/gamerecord.py
src/gui/boardview.py
Show inline comments
 
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.
src/gui/imgview.py
Show inline comments
 
@@ -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):
src/statebag.py
Show inline comments
 
@@ -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.
src/tests/testGo.py
Show inline comments
 
from unittest import TestCase
 

	
 
from go import isLegalPosition
 
from go.core import isLegalPosition
 

	
 

	
 
class TestLegal(TestCase):
0 comments (0 inline, 0 general)