Ejemplo n.º 1
0
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]')
Ejemplo n.º 2
0
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]')
Ejemplo n.º 3
0
def test_current():
    board = Board()
    assert board.current == BLACK

    board.play(1)
    assert board.current == WHITE

    board.play(2)
    assert board.current == BLACK
Ejemplo n.º 4
0
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
Ejemplo n.º 5
0
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]')
Ejemplo n.º 6
0
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
Ejemplo n.º 7
0
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)
Ejemplo n.º 8
0
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])'
Ejemplo n.º 9
0
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
Ejemplo n.º 10
0
def board(size=9):
    board = Board(size)
    [board.play(i) for i in range(size + 1)]
    return board
Ejemplo n.º 11
0
def test_toggle_edit_remove():
    board = Board(9)
    board.play(10)

    board.toggle_edit(10, BLACK)
    assert board.at(10) == EMPTY
Ejemplo n.º 12
0
def test_current_handicap():
    board = Board(9, 2)
    assert board.current == WHITE

    board.play(1)
    assert board.current == BLACK
Ejemplo n.º 13
0
def test_pass():
    board = Board()
    board.play(PASS)

    assert board.tree[0].move == PASS
    assert board.current == WHITE