projekty
/
imago.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
f662aac
)
comments for output module
author
Tomas Musil
<tomik.musil@gmail.com>
Tue, 24 Jun 2014 14:44:00 +0000
(16:44 +0200)
committer
Tomas Musil
<tomik.musil@gmail.com>
Tue, 24 Jun 2014 14:44:00 +0000
(16:44 +0200)
imago_pack/output.py
patch
|
blob
|
history
diff --git
a/imago_pack/output.py
b/imago_pack/output.py
index
366d0d9
..
821bec9
100644
(file)
--- a/
imago_pack/output.py
+++ b/
imago_pack/output.py
@@
-5,12
+5,16
@@
import sys
COORDS = 'abcdefghijklmnopqrs'
COORDS = 'abcdefghijklmnopqrs'
+# TODO refactor method names
+
class Board:
class Board:
+ """Represents the state of the board."""
def __init__(self, size, stones):
self.stones = stones
self.size = size
def __str__(self):
def __init__(self, size, stones):
self.stones = stones
self.size = size
def __str__(self):
+ """Retrun string representation of the board."""
lines = []
k = 0
for i in range(self.size):
lines = []
k = 0
for i in range(self.size):
@@
-52,9
+56,12
@@
class Board:
return sgf
def addMove(self, m):
return sgf
def addMove(self, m):
+ """Add move to the board."""
self.stones[(m.y * self.size) + m.x] = m.color
def getMoveCandidates(self, board):
self.stones[(m.y * self.size) + m.x] = m.color
def getMoveCandidates(self, board):
+ """Take the next board in game and return a list of moves that are
+ new."""
candidates = []
for i in range(self.size):
for j in range(self.size):
candidates = []
for i in range(self.size):
for j in range(self.size):
@@
-66,6
+73,7
@@
class Board:
return candidates
class Move:
return candidates
class Move:
+ """Repsresents a move."""
def __init__(self, color, y, x, comment=None):
self.color = color
self.x = x
def __init__(self, color, y, x, comment=None):
self.color = color
self.x = x
@@
-73,9
+81,11
@@
class Move:
self.comment = comment
def sgf_coords(self):
self.comment = comment
def sgf_coords(self):
+ """Return coordinates of the move in SGF."""
return COORDS[self.x] + COORDS[self.y]
class Game:
return COORDS[self.x] + COORDS[self.y]
class Game:
+ """Represents a game."""
def __init__(self, size, board=None, debug=True):
self.init_board = board or Board(size, (size * size) * ".")
self.board = copy.deepcopy(self.init_board)
def __init__(self, size, board=None, debug=True):
self.init_board = board or Board(size, (size * size) * ".")
self.board = copy.deepcopy(self.init_board)
@@
-85,6
+95,7
@@
class Game:
self.debug_comment = ""
def addMove(self, board):
self.debug_comment = ""
def addMove(self, board):
+ """Add next move to the game."""
candidates = self.board.getMoveCandidates(board)
if self.debug:
comment = str(board)
candidates = self.board.getMoveCandidates(board)
if self.debug:
comment = str(board)
@@
-100,6
+111,7
@@
class Game:
self.board.addMove(move)
def asSGF(self):
self.board.addMove(move)
def asSGF(self):
+ """Return the game representation as SGF string."""
sgf = "(;FF[4]GM[1]SZ[" + str(self.size) + "]AP[Imago:0.1.0]\n"
sgf += self.init_board.SGFpos()
for m in self.moves:
sgf = "(;FF[4]GM[1]SZ[" + str(self.size) + "]AP[Imago:0.1.0]\n"
sgf += self.init_board.SGFpos()
for m in self.moves: