当前位置: 首页>>代码示例>>Python>>正文


Python Board.play_stone方法代码示例

本文整理汇总了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]
开发者ID:TheDuck314,项目名称:go-NN,代码行数:14,代码来源:MakeMoveData.py

示例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
开发者ID:TheDuck314,项目名称:go-NN,代码行数:69,代码来源:SGFReader.py


注:本文中的Board.play_stone方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。