Example #1
0
def test_get_game_ended_ongoing():
    """Check that the function correctly signals an ongoing game.
    """
    game = BloomsGame(size=4, score_target=15)
    board = game.getInitBoard()

    assert game.getGameEnded(board, player=-1) == 0.0
Example #2
0
def test_get_game_ended_loss():
    """Check that the function correctly signals a loss.
    """
    game = BloomsGame(size=4, score_target=15)
    board = game.getInitBoard()

    # Set the number of captures for Player 1 (i.e. the opponent) to 15
    board.captures[1] = 15

    assert game.getGameEnded(board, player=-1) == -1.0
Example #3
0
def test_get_game_ended_win():
    """Check that the function correctly signals a win.
    """
    game = BloomsGame(size=4, score_target=15)
    board = game.getInitBoard()

    # Set the number of captures for Player -1/0 to 15
    board.captures[0] = 15

    assert game.getGameEnded(board, player=-1) == 1.0
Example #4
0
def test_get_game_ended_draw():
    """Check that the function correctly signals a draw.
    """
    game = BloomsGame(size=4, score_target=15)
    board = game.getInitBoard()

    # Fill the board
    for position in board.get_empty_spaces():
        board.place_stone(position=position, colour=1)

    assert game.getGameEnded(board, player=-1) == pytest.approx(1e-4)