8000 minigo/go.py at master · A-Infinite/minigo · GitHub
[go: up one dir, main page]

Skip to content

Latest commit

 

History

History
530 lines (444 loc) · 19.1 KB

go.py

File metadata and controls

530 lines (444 loc) · 19.1 KB
return (len(self.recent) >= 2
and self.recent[-1].move is None
and self.recent[-2].move is None)
def score(self):
'Return score from B perspective. If W is winning, score is negative.'
working_board = np.copy(self.board)
while EMPTY in working_board:
unassigned_spaces = np.where(working_board == EMPTY)
c = unassigned_spaces[0][0], unassigned_spaces[1][0]
territory, borders = find_reached(working_board, c)
border_colors = set(working_board[b] for b in borders)
X_border = BLACK in border_colors
O_border = WHITE in border_colors
if X_border and not O_border:
territory_color = BLACK
elif O_border and not X_border:
territory_color = WHITE
else:
territory_color = UNKNOWN # dame, or seki
place_stones(working_board, territory_color, territory)
return np.count_nonzero(working_board == BLACK) - np.count_nonzero(working_board == WHITE) - self.komi
def result(self):
score = self.score()
if score > 0:
return 1
elif score < 0:
return -1
else:
return 0
def result_string(self):
score = self.score()
if score > 0:
return 'B+' + '%.1f' % score
elif score < 0:
return 'W+' + '%.1f' % abs(score)
else:
return 'DRAW'
0