Example #1
0
 def test(analysis: AnalysisManager):
     local.assertIsNotNone(analysis.get_protobuf_data())
     local.assertEqual(False, analysis.get_protobuf_data().game_metadata.is_invalid_analysis)
     for player in analysis.get_protobuf_data().players:
         ratio = (player.stats.positional_tendencies.time_in_front_ball +
                  player.stats.positional_tendencies.time_behind_ball) / player.time_in_game
         local.assertEqual(True, ratio > 0.99)
         local.assertGreater(player.stats.positional_tendencies.time_in_front_ball, 0)
         local.assertGreater(player.stats.positional_tendencies.time_behind_ball, 0)
         local.assertGreater(player.time_in_game, 0)
         local.assertGreater(player.stats.speed.time_at_slow_speed, 0)
         local.assertGreater(player.stats.boost.average_boost_level, 0)
Example #2
0
 def test(analysis: AnalysisManager):
     assert (analysis.get_protobuf_data() is not None)
     assert (not analysis.get_protobuf_data().game_metadata.is_invalid_analysis)
     for player in analysis.get_protobuf_data().players:
         ratio = (player.stats.positional_tendencies.time_in_front_ball +
                  player.stats.positional_tendencies.time_behind_ball) / player.time_in_game
         assert (ratio > 0.99)
         assert (player.stats.positional_tendencies.time_in_front_ball > 0)
         assert (player.stats.positional_tendencies.time_behind_ball > 0)
         assert (player.time_in_game > 0)
         assert (player.stats.speed.time_at_slow_speed > 0)
         assert (player.stats.boost.average_boost_level > 0)
Example #3
0
 def test(analysis: AnalysisManager):
     assert (analysis.get_protobuf_data() is not None)
     assert(not analysis.get_protobuf_data().game_metadata.is_invalid_analysis)
     for player in analysis.get_protobuf_data().players:
         ratio = (player.stats.positional_tendencies.time_in_front_ball +
                  player.stats.positional_tendencies.time_behind_ball) / player.time_in_game
         assert ratio > 0.99
         # local.assertGreater(player.stats.positional_tendencies.time_in_front_ball, 0)
         # local.assertGreater(player.stats.positional_tendencies.time_behind_ball, 0)
         assert (player.time_in_game > 0)
         assert(player.stats.speed.time_at_slow_speed > 0)
         assert(player.stats.boost.average_boost_level > 0)
         assert(player.stats.boost.wasted_collection > -1)
     json = analysis.get_json_data()
     assert len(json['players']) > 0
Example #4
0
    def processReplays(self, replay, outputfile):
        self.outputfile = outputfile

        _json = carball.decompile_replay(replay)
        game = Game()
        player = Player()

        # Initialize and perform default analysis
        game.initialize(loaded_json=_json)

        analysis = AnalysisManager(game)
        analysis.create_analysis()

        # Get protobuf data to analyze
        proto_game = analysis.get_protobuf_data()

        # Readability
        self.meta = proto_game.game_metadata
        self.team = proto_game.teams
        self.players = proto_game.players

        self.getMetaInfo()
        self.getPlayerInfo()
        self.getTeamInfo()
        self.outputJSON()
Example #5
0
        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)
        def test(analysis: AnalysisManager):

            proto_game = analysis.get_protobuf_data()
            kickoffs = proto_game.game_stats.kickoffs
            assert (len(kickoffs) == 6)

            first_player = proto_game.players[0].stats
            kickoff_stats = first_player.kickoff_stats
            assert kickoff_stats.num_time_first_touch == 1
            assert kickoff_stats.num_time_go_to_ball == 1
            assert kickoff_stats.num_time_boost == 1
            assert kickoff_stats.num_time_cheat == 0
            assert kickoff_stats.num_time_defend == 1
            assert kickoff_stats.num_time_afk == 1
            assert kickoff_stats.total_kickoffs == 6
            assert 2 == (
                kickoff_stats.total_kickoffs -
                (kickoff_stats.num_time_go_to_ball +
                 kickoff_stats.num_time_boost + kickoff_stats.num_time_cheat +
                 kickoff_stats.num_time_defend + kickoff_stats.num_time_afk))

            second_player_stats = proto_game.players[1].stats.kickoff_stats
            assert second_player_stats.num_time_first_touch == 5
            assert second_player_stats.num_time_go_to_ball == 6
            for i in range(len(kickoffs)):
                kickoff = proto_game.game_stats.kickoff_stats[i]
                player = kickoff.touch.players[0]
                start_left = player.start_position.pos_x < 0
                assert player.start_left == start_left
Example #7
0
        def test(analysis: AnalysisManager):
            proto_game = analysis.get_protobuf_data()

            assert proto_game.game_metadata.goals[0].extra_mode_info.pre_items
            assert not proto_game.game_metadata.goals[
                1].extra_mode_info.pre_items
            assert proto_game.game_metadata.goals[2].extra_mode_info.pre_items
Example #8
0
        def test(analysis: AnalysisManager):

            proto_game = analysis.get_protobuf_data()
            player = proto_game.players[0]
            boost = player.stats.boost
            self.assertEqual(boost.num_large_boosts, 1)
            print(analysis)
Example #9
0
        def test(analysis: AnalysisManager):
            proto_game = analysis.get_protobuf_data()
            assertions = unittest.TestCase('__init__')

            dropshot_ball_proto = proto_game.game_stats.ball_stats.extra_mode

            assert dropshot_ball_proto.dropshot_phase_stats[0].phase == 0
            assertions.assertAlmostEqual(
                dropshot_ball_proto.dropshot_phase_stats[0].average,
                3.72452275, 5)
            assertions.assertAlmostEqual(
                dropshot_ball_proto.dropshot_phase_stats[0].max, 6.9999535, 5)
            assertions.assertAlmostEqual(
                dropshot_ball_proto.dropshot_phase_stats[0].total, 7.4490455,
                5)

            assert dropshot_ball_proto.dropshot_phase_stats[1].phase == 1
            assertions.assertAlmostEqual(
                dropshot_ball_proto.dropshot_phase_stats[1].average, 0.1, 5)
            assertions.assertAlmostEqual(
                dropshot_ball_proto.dropshot_phase_stats[1].max, 0.1, 5)
            assertions.assertAlmostEqual(
                dropshot_ball_proto.dropshot_phase_stats[1].total, 0.1, 5)

            assert dropshot_ball_proto.dropshot_phase_stats[2].phase == 2
            assert dropshot_ball_proto.dropshot_phase_stats[2].average == 0
            assert dropshot_ball_proto.dropshot_phase_stats[2].max == 0
            assert dropshot_ball_proto.dropshot_phase_stats[2].total == 0

            game_dropshot_stats = proto_game.game_stats.dropshot_stats

            assert len(game_dropshot_stats.damage_events[0].tiles) == 7
Example #10
0
 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
Example #11
0
 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)
Example #12
0
 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)
Example #13
0
 def test(analysis: AnalysisManager, boost_value):
     proto_game = analysis.get_protobuf_data()
     for index, player in enumerate(proto_game.players):
         boost = player.stats.boost
         case.assertAlmostEqual(boost.wasted_collection,
                                boost_value[index],
                                delta=2)
Example #14
0
        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)
Example #15
0
 def test(analysis: AnalysisManager):
     proto_game = analysis.get_protobuf_data()
     fifties = proto_game.game_stats.fifty_fifties
     # Tuples are (starting frame, ending frame, # hits, # unique players)
     expected_tuples = [
         (173, 177, 4, 2),
         (259, 261, 2, 2),
         (539, 540, 2, 2),
         (1212, 1214, 2, 2),
         (1676, 1679, 2, 2),
         (2261, 2265, 3, 2),
         (2634, 2636, 2, 2),
         (3172, 3174, 3, 2),
         (4132, 4134, 2, 2),
         (4774, 4776, 2, 2),
         (5124, 5127, 2, 2),
         (5224, 5226, 2, 2),
         (6260, 6262, 2, 2),
         (7495, 7496, 2, 2),
         (7916, 7921, 3, 2),
         (8203, 8207, 2, 2),
         (8855, 8857, 3, 2),
         (8906, 8909, 2, 2),
         (9291, 9294, 3, 2),
         (10257, 10259, 2, 2),
     ]
     assert (len(fifties) == len(expected_tuples))
     for i in range(len(fifties)):
         fifty = fifties[i]
         fifty_tuple = (fifty.starting_frame, fifty.ending_frame,
                        len(fifty.hits), len(fifty.players))
         assert (fifty_tuple == expected_tuples[i])
Example #16
0
 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)
Example #17
0
        def test(analysis: AnalysisManager):
            proto_game = analysis.get_protobuf_data()
            player = proto_game.players[0]
            print(player)

            percent = 6
            assert player.stats.ball_carries.total_carry_time == pytest.approx(
                196, percent / 100)
Example #18
0
        def test(analysis: AnalysisManager):

            proto_game = analysis.get_protobuf_data()
            kickoffs = proto_game.game_stats.kickoffs
            assert (len(kickoffs) == 0)

            first_player = proto_game.players[0].stats
            kickoff_stats = first_player.kickoff_stats
            assert kickoff_stats.total_kickoffs == 0
Example #19
0
        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

            self.assertEqual(counter, answer)
Example #20
0
 def test(analysis: AnalysisManager, boost_value):
     proto_game = analysis.get_protobuf_data()
     player = proto_game.players[0]
     boost = player.stats.boost
     self.assertAlmostEqual(boost.wasted_collection,
                            boost_value,
                            delta=1)
     # self.assertGreater(boost.average_boost_level, 0)
     print(analysis)
Example #21
0
        def test(analysis: AnalysisManager):
            proto_game = analysis.get_protobuf_data()

            self.assertTrue(
                proto_game.game_metadata.goals[0].extra_mode_info.pre_items)
            self.assertFalse(
                proto_game.game_metadata.goals[1].extra_mode_info.pre_items)
            self.assertTrue(
                proto_game.game_metadata.goals[2].extra_mode_info.pre_items)
Example #22
0
        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

            assert (aerial_counter == answer)
Example #23
0
        def test(analysis: AnalysisManager):
            proto_game = analysis.get_protobuf_data()

            assert proto_game.game_metadata.goals[
                0].extra_mode_info.dropshot_tile.id == 89
            assert proto_game.game_metadata.goals[
                0].extra_mode_info.phase_1_tiles == 0
            assert proto_game.game_metadata.goals[
                0].extra_mode_info.phase_2_tiles == 1
Example #24
0
        def test(analysis: AnalysisManager):
            proto_game = analysis.get_protobuf_data()
            hits = proto_game.game_stats.hits
            kickoff_counter = 0
            for hit in hits:
                if hit.is_kickoff:
                    kickoff_counter += 1
            print(analysis)

            assert (kickoff_counter == 3)
Example #25
0
 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,
                                delta=2)
Example #26
0
        def test(analysis: AnalysisManager):
            proto_game = analysis.get_protobuf_data()

            self.assertNotEqual(
                proto_game.game_stats.rumble_items[1].frame_number_use, -1)

            freeze_stats = next(
                filter(lambda x: x.item == BALL_FREEZE,
                       proto_game.players[0].stats.rumble_stats.rumble_items))
            self.assertEqual(freeze_stats.used, 1)
Example #27
0
        def test(analysis: AnalysisManager):
            proto_game = analysis.get_protobuf_data()

            spike_stats = next(
                filter(lambda x: x.item == BALL_VELCRO,
                       proto_game.players[0].stats.rumble_stats.rumble_items))
            self.assertAlmostEqual(spike_stats.average_hold, 11.87916, 5)

            spike_stats = next(
                filter(lambda x: x.item == BALL_VELCRO,
                       proto_game.teams[0].stats.rumble_stats.rumble_items))
            self.assertAlmostEqual(spike_stats.average_hold, 11.87916, 5)
Example #28
0
        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
Example #29
0
 def test(analysis: AnalysisManager):
     proto_game = analysis.get_protobuf_data()
     teams = proto_game.teams
     for team in teams:
         if team.is_orange:
             continue
         assert (
             team.stats.center_of_mass.average_max_distance_from_center
             > 0)
         assert (team.stats.center_of_mass.average_distance_from_center
                 > 0)
         assert (team.stats.center_of_mass.positional_tendencies.
                 time_behind_ball > 0)
        def test(analysis: AnalysisManager):
            proto_game = analysis.get_protobuf_data()
            camera_settings = proto_game.players[0].camera_settings

            assertions.assertAlmostEqual(camera_settings.distance, 330.0, 5)
            assertions.assertAlmostEqual(camera_settings.field_of_view, 100.0,
                                         5)
            assertions.assertAlmostEqual(camera_settings.height, 100.0, 5)
            assertions.assertAlmostEqual(camera_settings.pitch, -4.0, 5)
            assertions.assertAlmostEqual(camera_settings.stiffness, 0.45, 5)
            assertions.assertAlmostEqual(camera_settings.swivel_speed, 4.2, 5)
            assertions.assertAlmostEqual(camera_settings.transition_speed, 1.0,
                                         5)