diff --git a/src/util.py b/src/util.py --- a/src/util.py +++ b/src/util.py @@ -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)