def test_game_to_sgf_part_handicap(): board = Board(19, 2) board.play(coord2d(10, 10, 19)) sgf = sgf_part_from_node(board, 0) assert (sgf == ';AB[dp][pd];W[jj]' or sgf == ';AB[pd][dp];W[jj]')
def test_game_to_sgf_part_labels(): board = Board(19) board.play(coord2d(10, 10, 19)) board.current_node.toggle_label(180) board.current_node.toggle_label(181) sgf = sgf_part_from_node(board, 0) assert (sgf == ';B[jj]LB[jj:A][kj:B]' or sgf == ';B[jj]LB[kj:B][jj:A]')
def test_current(): board = Board() assert board.current == BLACK board.play(1) assert board.current == WHITE board.play(2) assert board.current == BLACK
def test_both_passed(): board = Board() assert not board.both_passed board.play(PASS) assert not board.both_passed board.play(PASS) assert board.both_passed
def test_game_to_sgf_part_symbols(): board = Board(19) board.play(coord2d(10, 10, 19)) board.current_node.toggle_symbol(180, 'TR') board.current_node.toggle_symbol(181, 'TR') board.current_node.toggle_symbol(182, 'SQ') sgf = sgf_part_from_node(board, 0) assert (sgf == ';B[jj]TR[jj][kj]SQ[lj]' or sgf == ';B[jj]TR[kj][jj]SQ[lj]')
def test_current_edits(): board = Board() board.current = BLACK board.play(1) board.add_edits([3], [], []) assert board.current == WHITE board.play(2) board.add_edits([4], [], []) board.add_edits([], [5], []) assert board.current == BLACK
def test_play_node(): board = Board() assert board.current_node_id is None board.play(coord2d(4, 4)) assert board.current_node_id == 0 assert board.current_node.parent_id is None assert board.current_node.children == [] assert board.current_node.action == NODE_BLACK assert board.current_node.move == coord2d(4, 4) board.play(coord2d(5, 5)) assert board.current_node.id == 1 assert board.current_node.parent_id == 0 assert board.current_node.children == [] assert board.tree[0].children == [1] assert board.current_node.action == NODE_WHITE assert board.current_node.move == coord2d(5, 5) board.play(coord2d(6, 6)) assert board.current_node_id == 2 assert board.current_node.parent_id == 1 assert board.current_node.children == [] assert board.tree[0].children == [1] assert board.tree[1].children == [2] assert board.current_node.action == NODE_BLACK assert board.current_node.move == coord2d(6, 6)
def test_game_to_sgf_part_variations(): board = Board(19) board.play(coord2d(4, 4, 19)) board.play(coord2d(16, 17, 19)) board.current_node_id = 0 board.play(coord2d(17, 16, 19)) sgf = sgf_part_from_node(board, 0) assert sgf == ';B[dd](;W[pq])(;W[qp])'
def test_play(): board = Board() assert board.current == BLACK board.play(coord2d(4, 4)) assert board.current == WHITE board.play(coord2d(3, 3)) assert board.current == BLACK board.play(coord2d(6, 6)) assert board.at(coord2d(4, 4)) == BLACK assert board.at(coord2d(3, 3)) == WHITE assert board.at(coord2d(6, 6)) == BLACK
def board(size=9): board = Board(size) [board.play(i) for i in range(size + 1)] return board
def test_toggle_edit_remove(): board = Board(9) board.play(10) board.toggle_edit(10, BLACK) assert board.at(10) == EMPTY
def test_current_handicap(): board = Board(9, 2) assert board.current == WHITE board.play(1) assert board.current == BLACK
def test_pass(): board = Board() board.play(PASS) assert board.tree[0].move == PASS assert board.current == WHITE