Play frequency tallies
This commit is contained in:
@@ -50,6 +50,21 @@ impl LogFile {
|
||||
(least_freq_action, frequency)
|
||||
}
|
||||
|
||||
pub fn frequency_of_plays(&self, team: Team) -> Vec<(Action, usize)> {
|
||||
let team_actions = self.team_actions(team.to_owned()).into_iter();
|
||||
let mut plays: Vec<(Action, usize)> = vec![];
|
||||
|
||||
Action::iter().for_each(|action| {
|
||||
plays.push((
|
||||
action.to_owned(),
|
||||
team_actions.clone().filter(|a| *a == action).count(),
|
||||
))
|
||||
});
|
||||
|
||||
plays.sort_by(|a, b| a.1.cmp(&b.1));
|
||||
plays
|
||||
}
|
||||
|
||||
pub fn most_effective_play(&self, team: Team) -> (Action, TerrainState) {
|
||||
let deltas = self
|
||||
.0
|
||||
|
||||
@@ -102,6 +102,7 @@ fn main() -> io::Result<()> {
|
||||
stats[team_idx].most_effective_play =
|
||||
Some(log.most_effective_play(team.to_owned()));
|
||||
*/
|
||||
stats[team_idx].play_frequencies = Some(log.frequency_of_plays(team.to_owned()))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,6 +148,7 @@ struct TeamStats {
|
||||
most_common_key: Option<Key>,
|
||||
least_common_key: Option<Key>,
|
||||
most_effective_play: Option<(Action, TerrainState)>,
|
||||
play_frequencies: Option<Vec<(Action, usize)>>,
|
||||
// Traits
|
||||
// Typical number of downs to achieve 10 yards.
|
||||
time_to_first_down: Option<Down>,
|
||||
@@ -167,6 +169,7 @@ impl TeamStats {
|
||||
most_common_key: None,
|
||||
least_common_key: None,
|
||||
most_effective_play: None,
|
||||
play_frequencies: None,
|
||||
time_to_first_down: None,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user