def test_find_winners(): b = Board(3, 1, 1) b._board = [[Position.PLAYER1, Position.EMPTY, Position.PLAYER2]] assert b.find_winners() == [] b._board = [[Position.EMPTY, Position.PLAYER2, Position.EMPTY]] assert b.find_winners() == [Position.PLAYER1] b._board = [[Position.PLAYER1, Position.EMPTY, Position.EMPTY]] assert b.find_winners() == [Position.PLAYER2] b._board = [[Position.FILLED, Position.EMPTY, Position.EMPTY]] assert b.find_winners() == [Position.PLAYER1, Position.PLAYER2]
def test_apply_gravity(): b = Board(9, 3, 2) b._board = [[ Position.PLAYER1, Position.PLAYER2, Position.PLAYER1, Position.PLAYER2, Position.PLAYER1, Position.PLAYER2, Position.FILLED, Position.FILLED, Position.FILLED ], [ Position.EMPTY, Position.EMPTY, Position.EMPTY, Position.EMPTY, Position.FILLED, Position.FILLED, Position.FILLED, Position.FILLED, Position.FILLED ], [ Position.EMPTY, Position.EMPTY, Position.FILLED, Position.FILLED, Position.FILLED, Position.FILLED, Position.PLAYER1, Position.PLAYER2, Position.FILLED ]] b._apply_gravity() assert b._board == [[ Position.EMPTY, Position.EMPTY, Position.EMPTY, Position.EMPTY, Position.PLAYER1, Position.PLAYER2, Position.FILLED, Position.FILLED, Position.FILLED ], [ Position.EMPTY, Position.EMPTY, Position.PLAYER1, Position.PLAYER2, Position.FILLED, Position.FILLED, Position.FILLED, Position.FILLED, Position.FILLED ], [ Position.PLAYER1, Position.PLAYER2, Position.FILLED, Position.FILLED, Position.FILLED, Position.FILLED, Position.PLAYER1, Position.PLAYER2, Position.FILLED ]]
def sample_board_small(): b = Board(3, 3, 3) b._board = [[Position.FILLED, Position.EMPTY, Position.FILLED], [Position.FILLED, Position.EMPTY, Position.EMPTY], [Position.FILLED, Position.EMPTY, Position.FILLED], [Position.FILLED, Position.EMPTY, Position.EMPTY], [Position.FILLED, Position.EMPTY, Position.FILLED]] return b
def sample_board_small_score(): b = Board(3, 5, 3) b._board = [[Position.PLAYER1, Position.EMPTY, Position.EMPTY], [Position.FILLED, Position.FILLED, Position.FILLED], [Position.PLAYER1, Position.EMPTY, Position.EMPTY], [Position.FILLED, Position.EMPTY, Position.EMPTY], [Position.FILLED, Position.FILLED, Position.FILLED]] return b
def sample_board_medium(): b = Board(5, 5, 3) b._board = [[ Position.EMPTY, Position.FILLED, Position.FILLED, Position.PLAYER2, Position.EMPTY ], [ Position.PLAYER1, Position.FILLED, Position.EMPTY, Position.EMPTY, Position.PLAYER2 ], [ Position.EMPTY, Position.FILLED, Position.FILLED, Position.PLAYER2, Position.EMPTY ], [ Position.FILLED, Position.PLAYER1, Position.EMPTY, Position.EMPTY, Position.FILLED ], [ Position.EMPTY, Position.PLAYER1, Position.FILLED, Position.FILLED, Position.FILLED ]] return b