Beispiel #1
0
def test_land_bees_two_bees_single_board_single_hive():
    game = GameState(game_params=DEFAULT_GAME_PARAMETERS,
                     game_id=sentinel.game_id,
                     boards=1,
                     board_width=10,
                     board_height=10,
                     hives=((Hive(5, 5), ), ),
                     flowers=((), ),
                     game_length=sentinel.game_length)

    assert all(
        board.calculate_score() == DEFAULT_GAME_PARAMETERS.hive_score_factor
        for board in game.boards)

    game.boards[0].inflight[sentinel.bee_1] = Bee(5, 5, 0, 10,
                                                  DEFAULT_GAME_PARAMETERS, 1)
    game.boards[0].inflight[sentinel.bee_2] = Bee(5, 5, 0, 10,
                                                  DEFAULT_GAME_PARAMETERS, 2)
    landed_bees = game.land_bees()

    for board in game.boards:
        assert sentinel.bee_1 not in board.inflight
        assert sentinel.bee_2 not in board.inflight

    assert [board.calculate_score() for board in game.boards] == [
        DEFAULT_GAME_PARAMETERS.hive_score_factor +
        3 * DEFAULT_GAME_PARAMETERS.nectar_score_factor
    ]
    assert landed_bees == [{
        sentinel.bee_1:
        Bee(5, 5, 0, 10, DEFAULT_GAME_PARAMETERS, 1),
        sentinel.bee_2:
        Bee(5, 5, 0, 10, DEFAULT_GAME_PARAMETERS, 2)
    }]
    assert check_bee_nectar_eq_hive_nectar(landed_bees, game)
Beispiel #2
0
def test_land_queenbees_single_queenbee_single_board_single_hive():
    game = GameState(game_params=DEFAULT_GAME_PARAMETERS,
                     game_id=sentinel.game_id,
                     boards=1,
                     board_width=10,
                     board_height=10,
                     hives=((Hive(5, 5), ), ),
                     flowers=((), ),
                     game_length=sentinel.game_length)

    assert all(
        board.calculate_score() == DEFAULT_GAME_PARAMETERS.hive_score_factor
        for board in game.boards)

    game.boards[0].inflight[sentinel.bee_1] = QueenBee(
        5, 5, 0, 10, DEFAULT_GAME_PARAMETERS, 1)
    landed_bees = game.land_bees()

    for board in game.boards:
        assert sentinel.bee_1 not in board.inflight

    assert [board.calculate_score() for board in game.boards] == [
        DEFAULT_GAME_PARAMETERS.hive_score_factor +
        DEFAULT_GAME_PARAMETERS.dead_bee_score_factor
    ]
    assert landed_bees == [{
        sentinel.bee_1:
        QueenBee(5, 5, 0, 10, DEFAULT_GAME_PARAMETERS, 1)
    }]
    assert game.boards[0].inflight == {}
Beispiel #3
0
def test_land_bees_single_queenbee_single_regular_bee_single_board_single_hive(
):
    game = GameState(game_params=DEFAULT_GAME_PARAMETERS,
                     game_id=sentinel.game_id,
                     boards=1,
                     board_width=10,
                     board_height=10,
                     hives=((Hive(5, 5), ), ),
                     flowers=((), ),
                     game_length=sentinel.game_length)

    assert all(
        board.calculate_score() == DEFAULT_GAME_PARAMETERS.hive_score_factor
        for board in game.boards)
    queen_bee = QueenBee(5, 5, 0, 10, DEFAULT_GAME_PARAMETERS, 1)
    bee = Bee(5, 5, 0, 10, DEFAULT_GAME_PARAMETERS, 1)
    both_bees = {sentinel.bee_1: queen_bee, sentinel.bee_2: bee}
    game.boards[0].inflight = both_bees.copy()
    landed_bees = game.land_bees()

    for board in game.boards:
        assert sentinel.bee_1 not in board.inflight
        assert sentinel.bee_2 not in board.inflight

    assert [board.calculate_score() for board in game.boards] == [
        DEFAULT_GAME_PARAMETERS.hive_score_factor +
        DEFAULT_GAME_PARAMETERS.dead_bee_score_factor +
        bee.nectar * DEFAULT_GAME_PARAMETERS.nectar_score_factor
    ]
    assert landed_bees == [both_bees]
    assert game.boards[0].inflight == {}
    assert check_bee_nectar_eq_hive_nectar([{sentinel.bee_2: bee}], game)
Beispiel #4
0
def test_land_bees_do_not_land_bee_not_on_hive():
    game = GameState(game_params=DEFAULT_GAME_PARAMETERS,
                     game_id=sentinel.game_id,
                     boards=1,
                     board_width=10,
                     board_height=10,
                     hives=((Hive(5, 5), ), ),
                     flowers=((), ),
                     game_length=sentinel.game_length)

    assert all(
        board.calculate_score() == DEFAULT_GAME_PARAMETERS.hive_score_factor
        for board in game.boards)

    game.boards[0].inflight[sentinel.bee_1] = Bee(5, 4, 0, 10,
                                                  DEFAULT_GAME_PARAMETERS, 1)
    landed_bees = game.land_bees()

    assert all(
        board.calculate_score() == DEFAULT_GAME_PARAMETERS.hive_score_factor
        for board in game.boards)
    assert sentinel.bee_1 in game.boards[0].inflight
    assert landed_bees == [{}]
    assert game.boards[0].inflight == {
        sentinel.bee_1: Bee(5, 4, 0, 10, DEFAULT_GAME_PARAMETERS, 1)
    }
    assert check_bee_nectar_eq_hive_nectar(landed_bees, game)