Exemplo 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
Exemplo n.º 2
0
def test_empty():
    g = Board(board=[], disc_color='RED', player_id='Alice')
    assert g.rows() == 0
    assert g.columns() == 0
    assert g.free_space() == 0
    assert g.possible_moves() == []
    assert g.disc_color == 'RED'
    assert g.player_id == 'Alice'
Exemplo n.º 3
0
def test_simple_board():
    b = [['EMPTY', 'EMPTY'], ['EMPTY', 'EMPTY'], ['EMPTY', 'EMPTY']]
    g = Board(board=b, disc_color='RED', player_id='Alice')
    assert g.rows() == len(b)
    assert g.columns() == len(b[0])
    assert g.free_space() == len(b) * len(b[0])
    assert g.possible_moves() == [0, 1]
    assert g.shape() == (len(b), len(b[0]))