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


Python gtp.BLACK属性代码示例

本文整理汇总了Python中gtp.BLACK属性的典型用法代码示例。如果您正苦于以下问题:Python gtp.BLACK属性的具体用法?Python gtp.BLACK怎么用?Python gtp.BLACK使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在gtp的用法示例。


在下文中一共展示了gtp.BLACK属性的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: maybe_correct_next

# 需要导入模块: import gtp [as 别名]
# 或者: from gtp import BLACK [as 别名]
def maybe_correct_next(pos, next_node):
    if (('B' in next_node.properties and not pos.to_play == GOPARAMETERS.BLACK) or
            ('W' in next_node.properties and not pos.to_play == GOPARAMETERS.WHITE)):
        pos.flip_playerturn(mutate=True)


# def replay_sgf(sgf_contents):
#     collection = sgf.parse(sgf_contents)
#     game = collection.children[0]
#     props = game.root.properties
#     assert int(sgf_prop(props.get('GM', ['1']))) == 1, "Not a Go SGF!"
#
#     komi = 0
#     if props.get('KM') != None:
#         komi = float(sgf_prop(props.get('KM')))
#     result = parse_game_result(sgf_prop(props.get('RE')))
#
#     pos = BoardState(komi=komi)
#     current_node = game.root
#     while pos is not None and current_node.next is not None:
#         pos = handle_node(pos, current_node)
#         maybe_correct_next(pos, current_node.next)
#         next_move = get_next_move(current_node)
#         yield PositionWithContext(pos, next_move, result)
#         current_node = current_node.next 
开发者ID:PacktPublishing,项目名称:Python-Reinforcement-Learning-Projects,代码行数:27,代码来源:utils.py

示例2: translate_gtp_colors

# 需要导入模块: import gtp [as 别名]
# 或者: from gtp import BLACK [as 别名]
def translate_gtp_colors(gtp_color):
    if gtp_color == gtp.BLACK:
        return go.BLACK
    elif gtp_color == gtp.WHITE:
        return go.WHITE
    else:
        return go.EMPTY 
开发者ID:mlperf,项目名称:training_results_v0.5,代码行数:9,代码来源:gtp_wrapper.py

示例3: translate_gtp_colors

# 需要导入模块: import gtp [as 别名]
# 或者: from gtp import BLACK [as 别名]
def translate_gtp_colors(gtp_color):
  if gtp_color == gtp.BLACK:
    return go.BLACK
  elif gtp_color == gtp.WHITE:
    return go.WHITE
  else:
    return go.EMPTY 
开发者ID:itsamitgoel,项目名称:Gun-Detector,代码行数:9,代码来源:gtp_wrapper.py

示例4: translate_sgf_move

# 需要导入模块: import gtp [as 别名]
# 或者: from gtp import BLACK [as 别名]
def translate_sgf_move(player_move, comment):
    if player_move.color not in (GOPARAMETERS.BLACK, GOPARAMETERS.WHITE):
        raise ValueError("Can't translate color %s to sgf" % player_move.color)
    c = to_sgf(player_move.move)
    color = 'B' if player_move.color == GOPARAMETERS.BLACK else 'W'
    if comment is not None:
        comment = comment.replace(']', r'\]')
        comment_node = "C[{}]".format(comment)
    else:
        comment_node = ""
    return ";{color}[{coords}]{comment_node}".format(
        color=color, coords=c, comment_node=comment_node) 
开发者ID:PacktPublishing,项目名称:Python-Reinforcement-Learning-Projects,代码行数:14,代码来源:utils.py

示例5: sgf_prop

# 需要导入模块: import gtp [as 别名]
# 或者: from gtp import BLACK [as 别名]
def sgf_prop(value_list):
    if value_list is None:
        return None
    if len(value_list) == 1:
        return value_list[0]
    else:
        return value_list


# def handle_node(pos, node):
#     props = node.properties
#     black_stones_added = [from_sgf(
#         c) for c in props.get('AB', [])]
#     white_stones_added = [from_sgf(
#         c) for c in props.get('AW', [])]
#     if black_stones_added or white_stones_added:
#         return add_stones(pos, black_stones_added, white_stones_added)
#     # If B/W props are not present, then there is no move. But if it is present and equal to the empty string, then the move was a pass.
#     elif 'B' in props:
#         black_move = from_sgf(props.get('B', [''])[0])
#         return pos.play_move(black_move, color=GOPARAMETERS.BLACK)
#     elif 'W' in props:
#         white_move = from_sgf(props.get('W', [''])[0])
#         return pos.play_move(white_move, color=GOPARAMETERS.WHITE)
#     else:
#         return pos


# def add_stones(pos, black_stones_added, white_stones_added):
#     working_board = np.copy(pos.board)
#     go.place_stones(working_board, GOPARAMETERS.BLACK, black_stones_added)
#     go.place_stones(working_board, GOPARAMETERS.WHITE, white_stones_added)
#     new_position = BoardState(board=working_board, n=pos.n, komi=pos.komi,
#                               caps=pos.caps, ko=pos.ko, recent=pos.recent, to_play=pos.to_play)
#     return new_position 
开发者ID:PacktPublishing,项目名称:Python-Reinforcement-Learning-Projects,代码行数:37,代码来源:utils.py

示例6: translate_gtp_colors

# 需要导入模块: import gtp [as 别名]
# 或者: from gtp import BLACK [as 别名]
def translate_gtp_colors(gtp_color):
    if gtp_color == gtp.BLACK:
        return GOPARAMETERS.BLACK
    elif gtp_color == gtp.WHITE:
        return GOPARAMETERS.WHITE
    else:
        return GOPARAMETERS.EMPTY 
开发者ID:PacktPublishing,项目名称:Python-Reinforcement-Learning-Projects,代码行数:9,代码来源:utils.py

示例7: test_parse_move

# 需要导入模块: import gtp [as 别名]
# 或者: from gtp import BLACK [as 别名]
def test_parse_move(self):
        self.assertEqual(parse_move("B D4"), (BLACK, (4, 4)))
        self.assertFalse(parse_move("C X"))
        self.assertFalse(parse_move("B 55"))
        self.assertFalse(parse_move("B dd"))
        self.assertFalse(parse_move("B X"))
        self.assertFalse(parse_move("B"))
        self.assertEqual(parse_move("WHITE q16 XXX"), (WHITE, (16, 16)))
        self.assertEqual(parse_move("black pass"), (BLACK, PASS)) 
开发者ID:jtauber,项目名称:gtp,代码行数:11,代码来源:test.py

示例8: test_gtp_color

# 需要导入模块: import gtp [as 别名]
# 或者: from gtp import BLACK [as 别名]
def test_gtp_color(self):
        self.assertEqual(gtp_color(BLACK), "B")
        self.assertEqual(gtp_color(WHITE), "W") 
开发者ID:jtauber,项目名称:gtp,代码行数:5,代码来源:test.py

示例9: test_gtp_move

# 需要导入模块: import gtp [as 别名]
# 或者: from gtp import BLACK [as 别名]
def test_gtp_move(self):
        self.assertEqual(gtp_move(BLACK, (3, 2)), "B C2") 
开发者ID:jtauber,项目名称:gtp,代码行数:4,代码来源:test.py


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