Example #1
0
class Test_Boost():
    def test_1_small_pad_collected(self, replay_cache):
        def test(analysis: AnalysisManager):
            proto_game = analysis.get_protobuf_data()
            player = proto_game.players[0]
            boost = player.stats.boost
            assert (boost.num_small_boosts == 1)

        run_analysis_test_on_replay(test,
                                    get_specific_replays()["1_SMALL_PAD"],
                                    cache=replay_cache)

    def test_1_large_pad_collected(self, replay_cache):
        def test(analysis: AnalysisManager):
            proto_game = analysis.get_protobuf_data()
            player = proto_game.players[0]
            boost = player.stats.boost
            assert (boost.num_large_boosts == 1)

        run_analysis_test_on_replay(test,
                                    get_specific_replays()["1_LARGE_PAD"],
                                    cache=replay_cache)

    def test_0_boost_collected(self, replay_cache):
        def test(analysis: AnalysisManager):
            proto_game = analysis.get_protobuf_data()
            player = proto_game.players[0]
            boost = player.stats.boost
            assert (boost.num_small_boosts == 0)
            assert (boost.num_large_boosts == 0)

        run_analysis_test_on_replay(
            test,
            get_specific_replays()["0_BOOST_COLLECTED"],
            cache=replay_cache)

    def test_boost_used(self, replay_cache):
        case = unittest.TestCase('__init__')

        def test(analysis: AnalysisManager, boost_value):
            proto_game = analysis.get_protobuf_data()
            player = proto_game.players[0]
            boost = player.stats.boost
            print("Predicted usage: {}, actual: {}".format(
                boost.boost_usage, boost_value))
            case.assertAlmostEqual(boost.boost_usage, boost_value, delta=1)
            # self.assertGreater(boost.average_boost_level, 0)

        run_analysis_test_on_replay(
            test,
            get_specific_replays()["BOOST_USED"] +
            get_specific_replays()["0_BOOST_USED"],
            answers=get_specific_answers()["BOOST_USED"] +
            get_specific_answers()["0_BOOST_USED"],
            cache=replay_cache)
Example #2
0
    def test_boost_used(self):

        def test(analysis: AnalysisManager, boost_value):

            proto_game = analysis.get_protobuf_data()
            player = proto_game.players[0]
            boost = player.stats.boost
            self.assertAlmostEqual(boost.boost_usage, boost_value, delta=9) # TODO: Figgure out a way to calculate boost in a more accurate manner
            print(analysis)

        run_analysis_test_on_replay(test, get_specific_replays()["BOOST_USED"] + get_specific_replays()["0_BOOST_USED"],
                                    answers=get_specific_answers()["BOOST_USED"] +
                                            get_specific_answers()["0_BOOST_USED"])
Example #3
0
    def test_boost_used(self):
        def test(analysis: AnalysisManager, boost_value):
            proto_game = analysis.get_protobuf_data()
            player = proto_game.players[0]
            boost = player.stats.boost
            print("Predicted usage: {}, actual: {}".format(
                boost.boost_usage, boost_value))
            self.assertAlmostEqual(boost.boost_usage, boost_value, delta=1)
            # self.assertGreater(boost.average_boost_level, 0)

        run_analysis_test_on_replay(
            test,
            get_specific_replays()["BOOST_USED"] +
            get_specific_replays()["0_BOOST_USED"],
            answers=get_specific_answers()["BOOST_USED"] +
            get_specific_answers()["0_BOOST_USED"])
Example #4
0
    def test_dribble_detection_is_zero(self, replay_cache):
        def test(analysis: AnalysisManager):
            proto_game = analysis.get_protobuf_data()
            carries = proto_game.game_stats.ball_carries
            assert (len(carries) == 0)

        run_analysis_test_on_replay(test,
                                    get_specific_replays()["ZERO_DRIBBLE"],
                                    cache=replay_cache)
Example #5
0
    def test_num_hits_detected(self):

        def test(analysis: AnalysisManager, answer):

            proto_game = analysis.get_protobuf_data()
            hits = proto_game.game_stats.hits
            self.assertEqual(len(hits), answer)
            print(analysis)

        run_analysis_test_on_replay(test, get_specific_replays()["HITS"], get_specific_answers()["HITS"])
Example #6
0
    def test_1_large_pad_collected(self, replay_cache):
        def test(analysis: AnalysisManager):
            proto_game = analysis.get_protobuf_data()
            player = proto_game.players[0]
            boost = player.stats.boost
            assert (boost.num_large_boosts == 1)

        run_analysis_test_on_replay(test,
                                    get_specific_replays()["1_LARGE_PAD"],
                                    cache=replay_cache)
Example #7
0
    def test_offline_replay(self):
        local = self

        def test(analysis: AnalysisManager):
            local.assertIsNotNone(analysis.get_protobuf_data())
            local.assertEqual(False, analysis.get_protobuf_data().game_metadata.is_invalid_analysis)
            game = analysis.get_protobuf_data()
            self.assertEqual(game.game_metadata.match_guid, game.game_metadata.id)

        run_analysis_test_on_replay(test, replay_list=get_specific_replays()["OFFLINE"])
Example #8
0
    def test_1_small_pad_collected(self):
        def test(analysis: AnalysisManager):
            proto_game = analysis.get_protobuf_data()
            player = proto_game.players[0]
            boost = player.stats.boost
            self.assertEqual(boost.num_small_boosts, 1)
            print(analysis)

        run_analysis_test_on_replay(test,
                                    get_specific_replays()["1_SMALL_PAD"])
Example #9
0
    def test_num_hits_detected(self, replay_cache):
        def test(analysis: AnalysisManager, answer):
            proto_game = analysis.get_protobuf_data()
            hits = proto_game.game_stats.hits
            assert (len(hits) == answer)
            print(analysis)

        run_analysis_test_on_replay(test,
                                    replay_list=get_specific_replays()["HITS"],
                                    answers=get_specific_answers()["HITS"],
                                    cache=replay_cache)
Example #10
0
    def test_0_used(self):

        def test(analysis: AnalysisManager, boost_value):

            proto_game = analysis.get_protobuf_data()
            player = proto_game.players[0]
            boost = player.stats.boost
            self.assertEqual(boost.boost_usage, boost_value)
            print(analysis)

        run_analysis_test_on_replay(test, get_specific_replays()["0_BOOST_USED"],
                                    answers=get_specific_answers()["0_BOOST_USED"])
Example #11
0
    def test_0_boost_collected(self, replay_cache):
        def test(analysis: AnalysisManager):
            proto_game = analysis.get_protobuf_data()
            player = proto_game.players[0]
            boost = player.stats.boost
            assert (boost.num_small_boosts == 0)
            assert (boost.num_large_boosts == 0)

        run_analysis_test_on_replay(
            test,
            get_specific_replays()["0_BOOST_COLLECTED"],
            cache=replay_cache)
Example #12
0
    def test_0_boost_collected(self):

        def test(analysis: AnalysisManager):

            proto_game = analysis.get_protobuf_data()
            player = proto_game.players[0]
            boost = player.stats.boost
            self.assertEqual(boost.num_small_boosts, 0)
            self.assertEqual(boost.num_large_boosts, 0)
            print(analysis)

        run_analysis_test_on_replay(test, get_specific_replays()["0_BOOST_COLLECTED"])
Example #13
0
    def test_offline_replay(self, replay_cache):
        def test(analysis: AnalysisManager):
            assert analysis.get_protobuf_data() is not None
            assert not analysis.get_protobuf_data(
            ).game_metadata.is_invalid_analysis
            game = analysis.get_protobuf_data()
            assert game.game_metadata.match_guid, game.game_metadata.id

        run_analysis_test_on_replay(
            test,
            replay_list=get_specific_replays()["OFFLINE"],
            cache=replay_cache)
Example #14
0
    def test_boost_feathered(self):
        def test(analysis: AnalysisManager, boost_value):
            proto_game = analysis.get_protobuf_data()
            player = proto_game.players[0]
            boost = player.stats.boost
            print("Predicted usage: {}, actual: {}".format(
                boost.boost_usage, boost_value))
            assertNearlyEqual(self, boost.boost_usage, boost_value, percent=3)
            # self.assertGreater(boost.average_boost_level, 0)

        run_analysis_test_on_replay(
            test,
            get_specific_replays()["BOOST_FEATHERED"],
            answers=get_specific_answers()["BOOST_FEATHERED"])
Example #15
0
    def test_error_replay(self):
        local = self

        def test(analysis: AnalysisManager):
            local.assertIsNone(analysis.get_protobuf_data())
            local.assertEqual(
                False,
                analysis.get_protobuf_data().game_metadata.is_invalid_analysis)

        try:
            run_analysis_test_on_replay(
                test, replay_list=get_specific_replays()["BROKEN_REPLAYS"])
        except FileNotFoundError as e:
            self.assertIsInstance(e, FileNotFoundError)
Example #16
0
    def test_num_clears_detected(self):
        def test(analysis: AnalysisManager, answer):
            proto_game = analysis.get_protobuf_data()
            hits = proto_game.game_stats.hits
            clear_counter = 0
            for hit in hits:
                if hit.clear:
                    clear_counter += 1

            self.assertEqual(clear_counter, answer)

        run_analysis_test_on_replay(test,
                                    get_specific_replays()["CLEARS"],
                                    get_specific_answers()["CLEARS"])
Example #17
0
    def test_num_clears_detected(self, replay_cache):
        def test(analysis: AnalysisManager, answer):
            proto_game = analysis.get_protobuf_data()
            hits = proto_game.game_stats.hits
            clear_counter = 0
            for hit in hits:
                if hit.clear:
                    clear_counter += 1

        run_analysis_test_on_replay(
            test,
            replay_list=get_specific_replays()["CLEARS"],
            answers=get_specific_answers()["CLEARS"],
            cache=replay_cache)
Example #18
0
    def test_num_passes_detected(self):

        def test(analysis: AnalysisManager, answer):

            proto_game = analysis.get_protobuf_data()
            hits = proto_game.game_stats.hits
            pass_counter = 0
            for hit in hits:
                if hit.pass_:
                    pass_counter += 1

            self.assertEqual(pass_counter, answer)

        run_analysis_test_on_replay(test, get_specific_replays()["PASSES"], get_specific_answers()["PASSES"])
Example #19
0
    def test_num_aerials_detected(self):

        def test(analysis: AnalysisManager, answer):

            proto_game = analysis.get_protobuf_data()
            hits = proto_game.game_stats.hits
            aerial_counter = 0
            for hit in hits:
                if hit.aerial:
                    aerial_counter += 1

            self.assertEqual(aerial_counter, answer)

        run_analysis_test_on_replay(test, get_specific_replays()["AERIALS"], get_specific_answers()["AERIALS"])
Example #20
0
    def test_dribble_detection_more_than_zero(self, replay_cache):
        def test(analysis: AnalysisManager, dribbles, flicks):
            proto_game = analysis.get_protobuf_data()
            carries = proto_game.game_stats.ball_carries
            assert (len(carries) > 0)
            player = proto_game.players[0]
            assert (player.stats.ball_carries.total_carries == dribbles)
            assert (player.stats.ball_carries.total_flicks == flicks)
            assert (player.stats.ball_carries.total_carry_time > 0)

        run_analysis_test_on_replay(test,
                                    get_specific_replays()["DRIBBLES"],
                                    answers=get_multiple_answers(
                                        ["DRIBBLES", "FLICKS"]),
                                    cache=replay_cache)
Example #21
0
    def test_num_saves_detected(self, replay_cache):
        def test(analysis: AnalysisManager, answer):
            proto_game = analysis.get_protobuf_data()
            hits = proto_game.game_stats.hits
            counter = 0
            for hit in hits:
                if hit.save:
                    counter += 1

            assert (counter == answer)

        run_analysis_test_on_replay(
            test,
            replay_list=get_specific_replays()["SAVES"],
            answers=get_specific_answers()["SAVES"],
            cache=replay_cache)
Example #22
0
    def test_team_stat_creation(self):
        def test(analysis: AnalysisManager):
            proto_game = analysis.get_protobuf_data()
            teams = proto_game.teams
            for team in teams:
                if team.is_orange:
                    continue
                self.assertGreater(
                    team.stats.center_of_mass.average_max_distance_from_center,
                    0)
                self.assertGreater(
                    team.stats.center_of_mass.average_distance_from_center, 0)
                self.assertGreater(
                    team.stats.center_of_mass.positional_tendencies.
                    time_behind_ball, 0)

        run_analysis_test_on_replay(test, get_specific_replays()["PASSES"])
Example #23
0
class Test_Boost():
    def test_1_small_pad_collected(self, replay_cache):
        def test(analysis: AnalysisManager):
            proto_game = analysis.get_protobuf_data()
            frames = analysis.get_data_frame()
            player = proto_game.players[0]
            boost = player.stats.boost
            assert (boost.num_small_boosts == 1)

        run_analysis_test_on_replay(test,
                                    get_specific_replays()["1_SMALL_PAD"],
                                    cache=replay_cache)

    def test_1_large_pad_collected(self, replay_cache):
        def test(analysis: AnalysisManager):
            proto_game = analysis.get_protobuf_data()
            player = proto_game.players[0]
            boost = player.stats.boost
            assert (boost.num_large_boosts == 1)

        run_analysis_test_on_replay(test,
                                    get_specific_replays()["1_LARGE_PAD"],
                                    cache=replay_cache)

    def test_1_large_pad_1_small_pad_collected(self, replay_cache):
        def test(analysis: AnalysisManager):
            proto_game = analysis.get_protobuf_data()
            player = proto_game.players[0]
            boost = player.stats.boost
            assert (boost.num_large_boosts == 1)
            assert (boost.num_small_boosts == 1)

        run_analysis_test_on_replay(
            test,
            get_raw_replays()["12_AND_100_BOOST_PADS_0_USED"],
            cache=replay_cache)

    def test_0_boost_collected(self, replay_cache):
        def test(analysis: AnalysisManager):
            proto_game = analysis.get_protobuf_data()
            player = proto_game.players[0]
            boost = player.stats.boost
            assert (boost.num_small_boosts == 0)
            assert (boost.num_large_boosts == 0)

        run_analysis_test_on_replay(
            test,
            get_specific_replays()["0_BOOST_COLLECTED"],
            cache=replay_cache)

    def test_lots_of_boost_collected(self, replay_cache):
        def test(analysis: AnalysisManager):
            proto_game = analysis.get_protobuf_data()
            player = proto_game.players[0]
            boost = player.stats.boost
            assert [boost.num_small_boosts, boost.num_large_boosts] == [25, 6]

        run_analysis_test_on_replay(test,
                                    get_raw_replays()["6_BIG_25_SMALL"],
                                    cache=replay_cache)

    def test_boost_steals(self, replay_cache):
        def test(analysis: AnalysisManager):
            proto_game = analysis.get_protobuf_data()
            player = proto_game.players[0]
            boost = player.stats.boost
            assert boost.num_stolen_boosts == 2

        run_analysis_test_on_replay(test,
                                    get_raw_replays()["6_BIG_25_SMALL"],
                                    cache=replay_cache)

    def test_boost_steals_post_goal(self, replay_cache):
        def test(analysis: AnalysisManager):
            proto_game = analysis.get_protobuf_data()
            player = proto_game.players[0]
            boost = player.stats.boost
            assert [
                boost.num_small_boosts, boost.num_large_boosts,
                boost.num_stolen_boosts, boost.boost_usage
            ] == [0, 0, 0, 0]

            player = proto_game.players[1]
            boost = player.stats.boost
            assert [boost.num_large_boosts, boost.num_stolen_boosts] == [3, 3]
            assert boost.boost_usage > 0

        run_analysis_test_on_replay(
            test,
            get_raw_replays()["3_STEAL_ORANGE_0_STEAL_BLUE"],
            cache=replay_cache)

    def test_boost_used(self, replay_cache):
        case = unittest.TestCase('__init__')

        def test(analysis: AnalysisManager, boost_value):
            proto_game = analysis.get_protobuf_data()
            player = proto_game.players[0]
            boost = player.stats.boost
            print("Predicted usage: {}, actual: {}".format(
                boost.boost_usage, boost_value))
            case.assertAlmostEqual(boost.boost_usage, boost_value, delta=1)
            # self.assertGreater(boost.average_boost_level, 0)

        run_analysis_test_on_replay(
            test,
            get_specific_replays()["BOOST_USED"] +
            get_specific_replays()["0_BOOST_USED"],
            answers=get_specific_answers()["BOOST_USED"] +
            get_specific_answers()["0_BOOST_USED"],
            cache=replay_cache)
Example #24
0
    def test_boost_feathered(self, replay_cache):
        case = unittest.TestCase('__init__')

        def test(analysis: AnalysisManager, boost_value):
            proto_game = analysis.get_protobuf_data()
            player = proto_game.players[0]
            boost = player.stats.boost
            print("Predicted usage: {}, actual: {}".format(
                boost.boost_usage, boost_value))
            assertNearlyEqual(case, boost.boost_usage, boost_value, percent=3)
            # self.assertGreater(boost.average_boost_level, 0)

        run_analysis_test_on_replay(
            test,
            get_specific_replays()["BOOST_FEATHERED"],
            answers=get_specific_answers()["BOOST_FEATHERED"],
            cache=replay_cache)

    def test_boost_wasted_collection(self, replay_cache):
        case = unittest.TestCase('__init__')

        def test(analysis: AnalysisManager, boost_value):
            proto_game = analysis.get_protobuf_data()
            for index, player in enumerate(proto_game.players):
                wasted_answer = boost_value[index]
                total_wasted = (wasted_answer[0] -
                                (255 - wasted_answer[1])) / 256.0 * 100.0
                boost = player.stats.boost
                case.assertAlmostEqual(boost.wasted_collection,
                                       total_wasted,