Ejemplo n.º 1
0
def test_is_member(board):
    d = Dragon(1, board)
    p = board.positions[1][2]
    assert not d.is_member(p)

    d.add_member(p)
    assert d.is_member(p)
Ejemplo n.º 2
0
def test_edge_neighbors(board):
    d = Dragon(1, board)
    p = board.positions[18][2]
    p2 = board.positions[18][3]
    d.add_member(p2)
    d.add_member(p)

    assert len(d.neighbors) == 4
    assert len(d.members) == 2
    assert len(d.liberties) == 4
Ejemplo n.º 3
0
def test_imagine_position(board):
    d = Dragon(1, board)
    board.dragons[1] = d
    for x in range(3):
        p = board.positions[3][2+x]
        p.player = 'b'
        p.dragon = 1
        d.add_member(p)
    p = board.positions[4][4]
    p.player = 'b'
    d.add_member(p)
    d = Dragon(2, board)
    board.dragons[2] = d
    for x in range(3):
        p = board.positions[5][2+x]
        p.player = 'w'
        p.dragon = 2
        d.add_member(p)
    p = board.positions[4][2]
    p.player = 'w'
    d.add_member(p)

    p = board.positions[4][3]
    rv = board.imagine_position(p, 'b')
    assert not rv['suicide']
    assert rv['stitched'] == {board.dragons[1]}
    assert not rv['captured']
Ejemplo n.º 4
0
def test_capture_dragon(board):
    d = Dragon(1, board)
    board.dragons[1] = d
    for x in range(4):
        p = board.positions[3][2+x]
        p.player = 'b'
        p.dragon = 1
        d.add_member(p)

    p = board.positions[4][5]
    p.player = 'b'
    p.dragon = 1
    d.add_member(p)
    rv = board.capture_dragon(1)
    assert rv == 5