Changeset - ae5bc0b73715
[Not reviewed]
default
0 1 0
Laman - 6 years ago 2018-12-04 17:21:39

enhanced exportBoard: marks stars
1 file changed with 13 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/util.py
Show inline comments
 
@@ -53,10 +53,21 @@ def hashBoard(board):
 
			res^=zobristNums[r][c][item+1]
 
	return res
 

	
 

	
 
def diffHash(r,c,oldItem,newItem):
 
	h=zobristNums[r][c]
 
	return h[oldItem+1] ^ h[newItem+1]
 

	
 

	
 
def exportBoard(board):
 
	substitutions={EMPTY:".", BLACK:"X", WHITE:"O"}
 
	return "\n".join("".join(substitutions.get(x,"?") for x in row) for row in board)
 
	substitutions={BLACK:"X", WHITE:"O"}
 
	template=[["."]*19 for r in range(19)]
 
	for r in range(3,19,6):
 
		for c in range(3,19,6):
 
			template[r][c]=","
 

	
 
	for (row,templateRow) in zip(board,template):
 
		for (c,x) in enumerate(row):
 
			if x!=EMPTY: templateRow[c]=substitutions[x]
 

	
 
	return "\n".join("".join(row) for row in template)
0 comments (0 inline, 0 general)