Esempio n. 1
0
def test_possible_moves_columns():
    b = [['EMPTY', 'EMPTY'], ['EMPTY', 'EMPTY'], ['EMPTY', 'EMPTY']]
    g = Board(board=b, disc_color='RED', player_id='Alice')
    assert g.possible_moves() == [0, 1]
    assert g.free_space_column(0) == 3
    assert g.free_space_column(1) == 3
    assert g.free_space() == g.free_space_column(0) + g.free_space_column(1)
    assert g.free_space_row(0) == 2
    assert g.free_space_row(1) == 2
    assert g.free_space_row(2) == 2

    b = [['YELLOW', 'EMPTY'], ['YELLOW', 'RED'], ['RED', 'RED']]
    g = Board(board=b, disc_color='RED', player_id='Alice')
    assert g.possible_moves() == [1]
    assert g.free_space_column(0) == 0
    assert g.free_space_column(1) == 1
    assert g.free_space() == g.free_space_column(0) + g.free_space_column(1)
    assert g.free_space_row(0) == 1
    assert g.free_space_row(1) == 0
    assert g.free_space_row(2) == 0

    b = [['EMPTY', 'RED'], ['YELLOW', 'RED'], ['RED', 'RED']]
    g = Board(board=b, disc_color='RED', player_id='Alice')
    assert g.possible_moves() == [0]
    assert g.free_space_column(0) == 1
    assert g.free_space_column(1) == 0
    assert g.free_space() == g.free_space_column(0) + g.free_space_column(1)
    assert g.free_space_row(0) == 1
    assert g.free_space_row(1) == 0
    assert g.free_space_row(2) == 0

    b = [['YELLOW', 'RED'], ['YELLOW', 'RED'], ['RED', 'RED']]
    g = Board(board=b, disc_color='RED', player_id='Alice')
    assert g.possible_moves() == []
    assert g.free_space_column(0) == 0
    assert g.free_space_column(1) == 0
    assert g.free_space() == g.free_space_column(0) + g.free_space_column(1)
    assert g.free_space_row(0) == 0
    assert g.free_space_row(1) == 0
    assert g.free_space_row(2) == 0

    b = [['RED', 'RED'], ['EMPTY', 'RED'], ['EMPTY', 'EMPTY']]
    g = Board(board=b, disc_color='RED', player_id='Alice')
    assert g.possible_moves() == [0, 1]
    assert g.free_space_column(0) == 2
    assert g.free_space_column(1) == 1
    assert g.free_space() == g.free_space_column(0) + g.free_space_column(1)
    assert g.free_space_row(0) == 0
    assert g.free_space_row(1) == 1
    assert g.free_space_row(2) == 2
Esempio n. 2
0
def test_free_space():
    b = [['EMPTY', 'EMPTY'], ['EMPTY', 'EMPTY'], ['EMPTY', 'EMPTY']]
    g = Board(board=b, disc_color='RED', player_id='Alice')
    assert g.free_space() == 6
    assert g.free_space_row(0) == 2
    assert g.free_space_row(1) == 2
    assert g.free_space_row(2) == 2
    assert g.free_space_column(0) == 3
    assert g.free_space_column(1) == 3

    b = [['YELLOW', 'EMPTY'], ['YELLOW', 'RED'], ['RED', 'RED']]
    g = Board(board=b, disc_color='RED', player_id='Alice')
    assert g.free_space() == 1
    assert g.free_space_row(0) == 1
    assert g.free_space_row(1) == 0
    assert g.free_space_row(2) == 0
    assert g.free_space_column(0) == 0
    assert g.free_space_column(1) == 1

    b = [['EMPTY', 'RED'], ['EMPTY', 'RED'], ['RED', 'RED']]
    g = Board(board=b, disc_color='RED', player_id='Alice')
    assert g.free_space() == 2
    assert g.free_space_row(0) == 1
    assert g.free_space_row(1) == 1
    assert g.free_space_row(2) == 0
    assert g.free_space_column(0) == 2
    assert g.free_space_column(1) == 0

    b = [['YELLOW', 'RED'], ['YELLOW', 'RED'], ['RED', 'RED']]
    g = Board(board=b, disc_color='RED', player_id='Alice')
    assert g.free_space() == 0
    assert g.free_space_row(0) == 0
    assert g.free_space_row(1) == 0
    assert g.free_space_row(2) == 0
    assert g.free_space_column(0) == 0
    assert g.free_space_column(1) == 0