本文整理汇总了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
示例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
示例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
示例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)
示例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
示例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
示例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))
示例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")