當前位置: 首頁>>代碼示例>>Python>>正文


Python gtp.WHITE屬性代碼示例

本文整理匯總了Python中gtp.WHITE屬性的典型用法代碼示例。如果您正苦於以下問題:Python gtp.WHITE屬性的具體用法?Python gtp.WHITE怎麽用?Python gtp.WHITE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在gtp的用法示例。


在下文中一共展示了gtp.WHITE屬性的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: maybe_correct_next

# 需要導入模塊: import gtp [as 別名]
# 或者: from gtp import WHITE [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 WHITE [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 WHITE [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 WHITE [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 WHITE [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 WHITE [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 WHITE [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 WHITE [as 別名]
def test_gtp_color(self):
        self.assertEqual(gtp_color(BLACK), "B")
        self.assertEqual(gtp_color(WHITE), "W") 
開發者ID:jtauber,項目名稱:gtp,代碼行數:5,代碼來源:test.py


注:本文中的gtp.WHITE屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。