Esempio n. 1
0
def test_winner_o():
    text = """\
XXXXXX
XXXXXX
XXXXXO
OOOOOO
OOOOOO
OOOOOO
>O
"""
    board = OthelloState(text)
    expected_winner = board.O_PLAYER
    winner = board.get_winner()

    assert winner == expected_winner
Esempio n. 2
0
def test_no_moves_for_either():
    board = OthelloState("""\
......
......
......
X.....
.OO...
.OO...
>X
""")
    expected_valid_moves = [False] * 37

    valid_moves = board.get_valid_moves()

    assert valid_moves.tolist() == expected_valid_moves
    assert board.get_winner() == board.O_PLAYER
Esempio n. 3
0
def test_winner_x():
    text = """\
XXXXXX
XXXXXX
XXXXXX
OOOOOX
OOOOOO
OOOOOO
>O
"""
    board = OthelloState(text)
    expected_winner = board.X_PLAYER
    winner = board.get_winner()

    assert winner == expected_winner
    assert board.is_win(expected_winner)
Esempio n. 4
0
def test_no_winner_tie():
    text = """\
XXXXXX
XXXXXX
XXXXXX
OOOOOO
OOOOOO
OOOOOO
>O
"""
    board = OthelloState(text)
    expected_winner = board.NO_PLAYER
    winner = board.get_winner()

    assert winner == expected_winner
    assert board.is_ended()