Beispiel #1
0
def test_move_in_a_full_column_throws_valueError():
    grid = c4.Grid(num_rows, num_cols)
    for i in range(num_rows):
        grid.add_piece(0, 'x')
    
    with pytest.raises(ValueError):
        grid.add_piece(0, 'x')
Beispiel #2
0
def test_reset_clears_existing_board_state():
    grid = c4.Grid(num_rows, num_cols)
    grid.add_piece(0, 'x')
    grid.add_piece(1, 'o')
    
    grid.reset()

    assert grid.state() == blank_grid
Beispiel #3
0
def test_grid_tracks_one_move():
    grid = c4.Grid(num_rows, num_cols)
    grid.add_piece(3, 'x')

    assert grid.state() == '''-------
-------
-------
-------
-------
---x---
'''

    assert grid.value_at(0, 3) == 'x'
Beispiel #4
0
import connect_four.connect_four as c4
from connect_four import driver

grid = c4.Grid(6, 7)

# grid.add_piece(0, 'x')
# grid.add_piece(0, 'x')
# grid.add_piece(0, 'x')
# grid.add_piece(0, 'x')
# grid.add_piece(1, 'x')
# grid.add_piece(2, 'x')
# grid.add_piece(3, 'x')
# grid.add_piece(5, 'x')
# grid.add_piece(1, 'x')
# grid.add_piece(2, 'o')
# grid.add_piece(2, 'x')
# grid.add_piece(3, 'o')
# grid.add_piece(3, 'o')
# grid.add_piece(3, 'x')
# grid.add_piece(0, 'x')

# print(grid.state())
# print(grid.get_token_coordinates('x'))

# print(grid.winning_lines())

# game = Game()
# game.print_grid()
# game.add_piece('a', 3)
# game.print_grid()
Beispiel #5
0
def test_move_in_a_too_large_column_number_throws_indexError():
    grid = c4.Grid(num_rows, num_cols)
    
    with pytest.raises(IndexError):
        grid.add_piece(num_cols, 'x')
Beispiel #6
0
def test_blank_grid_is_blank():
    grid = c4.Grid(num_rows, num_cols)

    assert grid.state() == blank_grid