本文整理汇总了Python中Board.play_stone方法的典型用法代码示例。如果您正苦于以下问题:Python Board.play_stone方法的具体用法?Python Board.play_stone怎么用?Python Board.play_stone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Board
的用法示例。
在下文中一共展示了Board.play_stone方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_feature_planes
# 需要导入模块: import Board [as 别名]
# 或者: from Board import play_stone [as 别名]
def test_feature_planes():
board = Board(5)
moves = [(0,0), (1,1), (2,2), (3,3), (4,4)]
play_color = Color.Black
for x,y in moves:
board.show()
feature_planes = make_feature_planes(board, play_color)
move_arr = make_move_arr(x, y)
show_feature_planes_and_move(feature_planes, move_arr)
print
board.play_stone(x, y, play_color)
play_color = flipped_color[play_color]
示例2: __init__
# 需要导入模块: import Board [as 别名]
# 或者: from Board import play_stone [as 别名]
class SGFReader:
def __init__(self, filename):
self.filename = filename
parser = SGFParser(filename)
self.initial_stones = []
self.moves = []
self.black_rank = None
self.white_rank = None
self.result = None
self.board = None
self.komi = None
for property_name, property_data in parser:
if property_name == "SZ": # board size
self.board = Board(int(property_data))
elif property_name == "AB": # black initial stones
for vertex_str in property_data:
self.initial_stones.append((parse_vertex(vertex_str), Color.Black))
elif property_name == "AW": # white initial stones
for vertex_str in property_data:
self.initial_stones.append((parse_vertex(vertex_str), Color.White))
elif property_name == "B": # black plays
self.moves.append((parse_vertex(property_data), Color.Black))
elif property_name == "W": # white plays
self.moves.append((parse_vertex(property_data), Color.White))
elif property_name == "BR": # black rank
self.black_rank = property_data
elif property_name == "WR": # white rank
self.white_rank = property_data
elif property_name == "RE": # result
self.result = property_data
elif property_name == "KM": # komi
self.komi = property_data
if not self.board:
self.board = Board(19) # assume 19x19 if we didn't see a size
for (x,y), color in self.initial_stones:
self.board.play_stone(x, y, color)
self.moves_played = 0
def has_more(self):
return self.moves_played < len(self.moves)
def peek_next_move(self):
return self.moves[self.moves_played]
def play_next_move(self):
move = self.moves[self.moves_played]
self.moves_played += 1
vertex, color = move
if vertex:
x,y = vertex
self.board.play_stone(x, y, color)
else:
self.board.play_pass()
return move
def next_play_color(self):
if self.has_more():
return self.moves[self.moves_played][1]
elif self.moves:
return flipped_color[self.moves[-1][1]]
elif self.initial_stones:
return flipped_color[self.initial_stones[-1][1]]
else:
return Color.Black