Changeset - d0b9b2add091
[Not reviewed]
default
0 1 0
Laman - 7 years ago 2018-04-15 17:22:22

handling preset positions (in handicap games)
1 file changed with 10 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/diana.py
Show inline comments
 
@@ -78,24 +78,34 @@ class SourceFile:
 
		return template
 

	
 
	def createGameInfo(self):
 
		rec=self._record
 
		return """{title}
 
B: {black} {bRank}
 
W: {white} {wRank}
 
{date}
 
{result}""".format(title=rec.get("GN",""), black=rec.get("PB",""), bRank=rec.get("BR",""), white=rec.get("PW",""), wRank=rec.get("WR",""), date=rec.get("DT",""), result=rec.get("RE",""))
 

	
 
	def _setMove(self,k):
 
		self._game=go.Go()
 

	
 
		blackStones=self._record.root.getProp("AB")
 
		whiteStones=self._record.root.getProp("AW")
 
		if blackStones:
 
			for p in blackStones:
 
				self._game.board[p.c][p.r]=BLACK
 
		if whiteStones:
 
			for p in whiteStones:
 
				self._game.board[p.c][p.r]=WHITE
 

	
 
		for i in range(k):
 
			(color,move)=self._moves[i]
 
			if move==tuple(): continue # pass
 
			self._move(color,*move)
 

	
 
	def _move(self,color,c,r):
 
		if not self._game.move(BLACK if color=='b' else WHITE, c,r):
 
			# !! we do not honor http://red-bean.com/sgf/ff5/m_vs_ax.htm at the moment
 
			msg="illegal move: {0} at {1},{2}".format(self._game.moveCount+1,c,r)
 
			if cfg.keepBroken:
 
				print(msg)
 
			else:
0 comments (0 inline, 0 general)