コード例 #1
0
def main():
    """Testing for errors and performance"""

    from timeit import timeit
    from rlbot.utils.structures.game_data_struct import GameTickPacket
    from skeleton.test.skeleton_agent_test import SkeletonAgentTest, MAX_BOOSTS

    agent = SkeletonAgentTest()
    game_tick_packet = GameTickPacket()
    game_tick_packet.num_boost = MAX_BOOSTS
    agent.initialize_agent()

    def test_function():
        return closest_available_boost(agent.game_data.my_car.location,
                                       agent.game_data.boost_pads)

    test_function()

    fps = 120
    n_times = 10000
    time_taken = timeit(test_function, number=n_times)
    percentage = time_taken * fps / n_times * 100

    print(f"Took {time_taken} seconds to run {n_times} times.")
    print(f"That's {percentage:.5f} % of our time budget.")
コード例 #2
0
def main():
    """Testing for errors and performance"""

    agent = SkeletonAgentTest("test_agent", 0, 0)
    agent.initialize_agent()
    game_tick_packet = GameTickPacket()

    game_tick_packet.num_cars = MAX_PLAYERS
    game_tick_packet.num_boost = MAX_BOOSTS
    game_tick_packet.num_goals = MAX_GOALS

    def test_function():
        return agent.get_output(game_tick_packet)

    fps = 120
    n_times = 1000
    time_taken = timeit(test_function, number=n_times)
    percentage = round(time_taken * fps / n_times * 100, 5)

    print(f"Took {time_taken} seconds to run {n_times} times.")
    print(f"That's {percentage} % of our time budget.")