本文整理匯總了Python中go.PlayerMove方法的典型用法代碼示例。如果您正苦於以下問題:Python go.PlayerMove方法的具體用法?Python go.PlayerMove怎麽用?Python go.PlayerMove使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類go
的用法示例。
在下文中一共展示了go.PlayerMove方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_long_game_tree_search
# 需要導入模塊: import go [as 別名]
# 或者: from go import PlayerMove [as 別名]
def test_long_game_tree_search(self):
player = MCTSPlayerMixin(DummyNet())
endgame = go.Position(
board=TT_FTW_BOARD,
n=MAX_DEPTH-2,
komi=2.5,
ko=None,
recent=(go.PlayerMove(go.BLACK, (0, 1)),
go.PlayerMove(go.WHITE, (0, 8))),
to_play=go.BLACK
)
player.initialize_game(endgame)
# Test that an almost complete game
for i in range(10):
player.tree_search(num_parallel=8)
self.assertNoPendingVirtualLosses(player.root)
self.assertGreater(player.root.Q, 0)
示例2: test_passing
# 需要導入模塊: import go [as 別名]
# 或者: from go import PlayerMove [as 別名]
def test_passing(self):
start_position = Position(
board=TEST_BOARD,
n=0,
komi=6.5,
caps=(1, 2),
ko=coords.from_kgs('A1'),
recent=tuple(),
to_play=BLACK,
)
expected_position = Position(
board=TEST_BOARD,
n=1,
komi=6.5,
caps=(1, 2),
ko=None,
recent=(PlayerMove(BLACK, None),),
to_play=WHITE,
)
pass_position = start_position.pass_move()
self.assertEqualPositions(pass_position, expected_position)
示例3: test_passing
# 需要導入模塊: import go [as 別名]
# 或者: from go import PlayerMove [as 別名]
def test_passing(self):
start_position = Position(
board=TEST_BOARD,
n=0,
komi=6.5,
caps=(1, 2),
ko=pc('A1'),
recent=tuple(),
to_play=BLACK,
)
expected_position = Position(
board=TEST_BOARD,
n=1,
komi=6.5,
caps=(1, 2),
ko=None,
recent=(PlayerMove(BLACK, None),),
to_play=WHITE,
)
pass_position = start_position.pass_move()
self.assertEqualPositions(pass_position, expected_position)
示例4: test_passing
# 需要導入模塊: import go [as 別名]
# 或者: from go import PlayerMove [as 別名]
def test_passing(self):
start_position = Position(
utils_test.BOARD_SIZE,
board=TEST_BOARD,
n=0,
komi=6.5,
caps=(1, 2),
ko=coords.from_kgs(utils_test.BOARD_SIZE, 'A1'),
recent=tuple(),
to_play=BLACK,
)
expected_position = Position(
utils_test.BOARD_SIZE,
board=TEST_BOARD,
n=1,
komi=6.5,
caps=(1, 2),
ko=None,
recent=(PlayerMove(BLACK, None),),
to_play=WHITE,
)
pass_position = start_position.pass_move()
self.assertEqualPositions(pass_position, expected_position)
示例5: test_long_game_tree_search
# 需要導入模塊: import go [as 別名]
# 或者: from go import PlayerMove [as 別名]
def test_long_game_tree_search(self):
player = MCTSPlayerMixin(utils_test.BOARD_SIZE, DummyNet())
endgame = go.Position(
utils_test.BOARD_SIZE,
board=TT_FTW_BOARD,
n=MAX_DEPTH-2,
komi=2.5,
ko=None,
recent=(go.PlayerMove(go.BLACK, (0, 1)),
go.PlayerMove(go.WHITE, (0, 8))),
to_play=go.BLACK
)
player.initialize_game(endgame)
# Test that an almost complete game
for i in range(10):
player.tree_search(num_parallel=8)
self.assertNoPendingVirtualLosses(player.root)
self.assertGreater(player.root.Q, 0)
示例6: test_long_game_tree_search
# 需要導入模塊: import go [as 別名]
# 或者: from go import PlayerMove [as 別名]
def test_long_game_tree_search(self):
player = MCTSPlayer(DummyNet())
endgame = go.Position(
board=TT_FTW_BOARD,
n=flags.FLAGS.max_game_length - 2,
komi=2.5,
ko=None,
recent=(go.PlayerMove(go.BLACK, (0, 1)),
go.PlayerMove(go.WHITE, (0, 8))),
to_play=go.BLACK
)
player.initialize_game(endgame)
# Test that MCTS can deduce that B wins because of TT-scoring
# triggered by move limit.
for _ in range(10):
player.tree_search(parallel_readouts=8)
self.assertNoPendingVirtualLosses(player.root)
self.assertGreater(player.root.Q, 0)
示例7: test_passing
# 需要導入模塊: import go [as 別名]
# 或者: from go import PlayerMove [as 別名]
def test_passing(self):
start_position = Position(
board=TEST_BOARD,
n=0,
komi=6.5,
caps=(1, 2),
ko=coords.from_gtp('A1'),
recent=tuple(),
to_play=BLACK,
)
expected_position = Position(
board=TEST_BOARD,
n=1,
komi=6.5,
caps=(1, 2),
ko=None,
recent=(PlayerMove(BLACK, None),),
to_play=WHITE,
)
pass_position = start_position.pass_move()
self.assertEqualPositions(pass_position, expected_position)
示例8: test_move_with_capture
# 需要導入模塊: import go [as 別名]
# 或者: from go import PlayerMove [as 別名]
def test_move_with_capture(self):
start_board = test_utils.load_board(EMPTY_ROW * 5 + '''
XXXX.....
XOOX.....
O.OX.....
OOXX.....
''')
start_position = Position(
board=start_board,
n=0,
komi=6.5,
caps=(1, 2),
ko=None,
recent=tuple(),
to_play=BLACK,
)
expected_board = test_utils.load_board(EMPTY_ROW * 5 + '''
XXXX.....
X..X.....
.X.X.....
..XX.....
''')
expected_position = Position(
board=expected_board,
n=1,
komi=6.5,
caps=(7, 2),
ko=None,
recent=(PlayerMove(BLACK, coords.from_kgs('B2')),),
to_play=WHITE,
)
actual_position = start_position.play_move(coords.from_kgs('B2'))
self.assertEqualPositions(actual_position, expected_position)
示例9: test_translate_sgf_move
# 需要導入模塊: import go [as 別名]
# 或者: from go import PlayerMove [as 別名]
def test_translate_sgf_move(self):
self.assertEqual(
";B[db]",
translate_sgf_move(go.PlayerMove(go.BLACK, (1, 3)), None))
self.assertEqual(
";W[aa]",
translate_sgf_move(go.PlayerMove(go.WHITE, (0, 0)), None))
self.assertEqual(
";W[]",
translate_sgf_move(go.PlayerMove(go.WHITE, None), None))
self.assertEqual(
";B[db]C[comment]",
translate_sgf_move(go.PlayerMove(go.BLACK, (1, 3)), "comment"))
示例10: test_move
# 需要導入模塊: import go [as 別名]
# 或者: from go import PlayerMove [as 別名]
def test_move(self):
start_position = Position(
board=TEST_BOARD,
n=0,
komi=6.5,
caps=(1, 2),
ko=None,
recent=tuple(),
to_play=BLACK,
)
expected_board = load_board('''
.XX....OO
X........
''' + EMPTY_ROW * 7)
expected_position = Position(
board=expected_board,
n=1,
komi=6.5,
caps=(1, 2),
ko=None,
recent=(PlayerMove(BLACK, pc('C9')),),
to_play=WHITE,
)
actual_position = start_position.play_move(pc('C9'))
self.assertEqualPositions(actual_position, expected_position)
expected_board2 = load_board('''
.XX....OO
X.......O
''' + EMPTY_ROW * 7)
expected_position2 = Position(
board=expected_board2,
n=2,
komi=6.5,
caps=(1, 2),
ko=None,
recent=(PlayerMove(BLACK, pc('C9')), PlayerMove(WHITE, pc('J8'))),
to_play=BLACK,
)
actual_position2 = actual_position.play_move(pc('J8'))
self.assertEqualPositions(actual_position2, expected_position2)
示例11: test_move_with_capture
# 需要導入模塊: import go [as 別名]
# 或者: from go import PlayerMove [as 別名]
def test_move_with_capture(self):
start_board = load_board(EMPTY_ROW * 5 + '''
XXXX.....
XOOX.....
O.OX.....
OOXX.....
''')
start_position = Position(
board=start_board,
n=0,
komi=6.5,
caps=(1, 2),
ko=None,
recent=tuple(),
to_play=BLACK,
)
expected_board = load_board(EMPTY_ROW * 5 + '''
XXXX.....
X..X.....
.X.X.....
..XX.....
''')
expected_position = Position(
board=expected_board,
n=1,
komi=6.5,
caps=(7, 2),
ko=None,
recent=(PlayerMove(BLACK, pc('B2')),),
to_play=WHITE,
)
actual_position = start_position.play_move(pc('B2'))
self.assertEqualPositions(actual_position, expected_position)
示例12: test_move_with_capture
# 需要導入模塊: import go [as 別名]
# 或者: from go import PlayerMove [as 別名]
def test_move_with_capture(self):
start_board = utils_test.load_board(
EMPTY_ROW * 5 + '''
XXXX.....
XOOX.....
O.OX.....
OOXX.....
''')
start_position = Position(
utils_test.BOARD_SIZE,
board=start_board,
n=0,
komi=6.5,
caps=(1, 2),
ko=None,
recent=tuple(),
to_play=BLACK,
)
expected_board = utils_test.load_board(
EMPTY_ROW * 5 + '''
XXXX.....
X..X.....
.X.X.....
..XX.....
''')
expected_position = Position(
utils_test.BOARD_SIZE,
board=expected_board,
n=1,
komi=6.5,
caps=(7, 2),
ko=None,
recent=(PlayerMove(BLACK, coords.from_kgs(
utils_test.BOARD_SIZE, 'B2')),),
to_play=WHITE,)
actual_position = start_position.play_move(coords.from_kgs(
utils_test.BOARD_SIZE, 'B2'))
self.assertEqualPositions(actual_position, expected_position)
示例13: test_move_with_capture
# 需要導入模塊: import go [as 別名]
# 或者: from go import PlayerMove [as 別名]
def test_move_with_capture(self):
start_board = test_utils.load_board(EMPTY_ROW * 5 + '''
XXXX.....
XOOX.....
O.OX.....
OOXX.....
''')
start_position = Position(
board=start_board,
n=0,
komi=6.5,
caps=(1, 2),
ko=None,
recent=tuple(),
to_play=BLACK,
)
expected_board = test_utils.load_board(EMPTY_ROW * 5 + '''
XXXX.....
X..X.....
.X.X.....
..XX.....
''')
expected_position = Position(
board=expected_board,
n=1,
komi=6.5,
caps=(7, 2),
ko=None,
recent=(PlayerMove(BLACK, coords.from_gtp('B2')),),
to_play=WHITE,
)
actual_position = start_position.play_move(coords.from_gtp('B2'))
self.assertEqualPositions(actual_position, expected_position)
示例14: test_translate_sgf_move
# 需要導入模塊: import go [as 別名]
# 或者: from go import PlayerMove [as 別名]
def test_translate_sgf_move(self):
self.assertEqual(
";B[db]",
translate_sgf_move(go.PlayerMove(go.BLACK, (1, 3))))
self.assertEqual(
";W[aa]",
translate_sgf_move(go.PlayerMove(go.WHITE, (0, 0))))
self.assertEqual(
";W[]",
translate_sgf_move(go.PlayerMove(go.WHITE, None)))