Beispiel #1
0
def random_algo(board_width, board_height, hives, flowers, inflight, crashed,
                lost_volants, received_volants, landed, scores, player_id,
                game_id, turn_num):
    if inflight:
        thing_id = random.choice(list(inflight.keys()))
        thing = inflight[thing_id]
        new_heading = random.choice(list(LEGAL_NEW_HEADINGS[thing[3]]))
        new_command = dict(entity=thing_id, command=new_heading)
        # you might want to see what happens with the new command and then make decisions
        new_result = apply_command_and_advance(board_width, board_height,
                                               hives, flowers, inflight,
                                               turn_num, new_command)
        return new_command
Beispiel #2
0
def test_apply_command_and_advance_no_command_nothing_happens():
    crashed, landed, lost = apply_command_and_advance(
        board_width=10,
        board_height=10,
        hives=[],
        flowers=[],
        inflight={
            "abee": ("Bee", 1, 1, 0, 100, DEFAULT_GAME_PARAMETERS._asdict(), 0)
        },
        turn_num=0,
        cmd=None)

    assert not crashed['collided']
    assert not crashed['exhausted']
    assert not crashed['headon']
    assert not crashed['seeds']
    assert not landed
    assert not lost
Beispiel #3
0
def test_apply_command_and_advance_no_command_bee_saved_from_exhaustion_by_flower(
):
    crashed, landed, lost = apply_command_and_advance(
        board_width=10,
        board_height=10,
        hives=[],
        flowers=[Flower(0, 1, DEFAULT_GAME_PARAMETERS, 1, 0, 1000).to_json()],
        inflight={
            "abee": ("Bee", 0, 0, 0, 0, DEFAULT_GAME_PARAMETERS._asdict(), 0)
        },
        turn_num=0,
        cmd=None)

    assert not crashed['collided']
    assert not crashed['exhausted']
    assert not crashed['headon']
    assert not crashed['seeds']
    assert not landed
    assert not lost
Beispiel #4
0
def test_apply_command_and_advance_command_stops_two_bees_crashing():
    crashed, landed, lost = apply_command_and_advance(
        board_width=10,
        board_height=10,
        hives=[],
        flowers=[],
        inflight={
            "abee":
            ("Bee", 0, 0, 0, 100, DEFAULT_GAME_PARAMETERS._asdict(), 0),
            "anotherbee":
            ("Bee", 0, 2, 180, 100, DEFAULT_GAME_PARAMETERS._asdict(), 0)
        },
        turn_num=0,
        cmd=dict(entity="anotherbee", command=120))

    assert not crashed['collided']
    assert not crashed['exhausted']
    assert not crashed['headon']
    assert not crashed['seeds']
    assert not landed
    assert not lost