Finish tasks to bring calculation capabilities in line with last interval.
This commit is contained in:
@@ -47,10 +47,10 @@ I figured, that since I already had to digitize every note, that I was required
|
|||||||
|
|
||||||
=== Miller:
|
=== Miller:
|
||||||
* [ ] Mathematics
|
* [ ] Mathematics
|
||||||
** [ ] Avg. Terrain Gain
|
** [*] Avg. Terrain Gain
|
||||||
** [ ] Avg. Terrain Loss
|
** [*] Avg. Terrain Loss
|
||||||
** [ ] Avg. Terrain Delta
|
** [*] Avg. Terrain Delta
|
||||||
** [ ] Avg. Offence Plays per quarter
|
** [*] Avg. Offence Plays per quarter
|
||||||
** [ ] Avg. Offence Plays per game
|
** [ ] Avg. Offence Plays per game
|
||||||
** [ ] Avg. Penalties per game
|
** [ ] Avg. Penalties per game
|
||||||
* [ ] Play Trend Analysis
|
* [ ] Play Trend Analysis
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
periods: [
|
periods: [
|
||||||
Period(
|
Period(
|
||||||
start: First,
|
start: First,
|
||||||
end: Third,
|
end: Second,
|
||||||
events: [
|
events: [
|
||||||
Kickoff(ArizonaState),
|
Kickoff(ArizonaState),
|
||||||
Play(
|
Play(
|
||||||
@@ -83,6 +83,12 @@
|
|||||||
down: First,
|
down: First,
|
||||||
terrain: Yards(10),
|
terrain: Yards(10),
|
||||||
),
|
),
|
||||||
|
]
|
||||||
|
),
|
||||||
|
Period(
|
||||||
|
start: Third,
|
||||||
|
end: None,
|
||||||
|
events: [
|
||||||
Kickoff(TexasAnM),
|
Kickoff(TexasAnM),
|
||||||
Play(
|
Play(
|
||||||
action: Unknown, // PA Comebacks or Curls? Original note: Spike Centre
|
action: Unknown, // PA Comebacks or Curls? Original note: Spike Centre
|
||||||
@@ -619,7 +625,6 @@
|
|||||||
down: First,
|
down: First,
|
||||||
terrain: GoalLine,
|
terrain: GoalLine,
|
||||||
),
|
),
|
||||||
// Touchdown
|
|
||||||
Score(Touchdown),
|
Score(Touchdown),
|
||||||
Score(PatSafety),
|
Score(PatSafety),
|
||||||
Kickoff(Iowa),
|
Kickoff(Iowa),
|
||||||
|
|||||||
@@ -65,8 +65,7 @@ impl Game {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn team_plays(&self, team: Team) -> usize {
|
pub fn team_plays(&self, team: Team) -> usize {
|
||||||
let quarterly_plays: Vec<usize> = self
|
self.periods
|
||||||
.periods
|
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|period| {
|
.filter_map(|period| {
|
||||||
if !period.is_overtime() {
|
if !period.is_overtime() {
|
||||||
@@ -76,13 +75,9 @@ impl Game {
|
|||||||
None
|
None
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.collect::<Vec<usize>>();
|
.collect::<Vec<usize>>()
|
||||||
|
.iter()
|
||||||
let mut summation = 0_usize;
|
.sum::<usize>()
|
||||||
|
|
||||||
quarterly_plays.iter().for_each(|value| summation += value);
|
|
||||||
|
|
||||||
summation
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The average number of plays in a quarter.
|
/// The average number of plays in a quarter.
|
||||||
@@ -145,6 +140,30 @@ impl Game {
|
|||||||
|
|
||||||
deltas.iter().sum::<i8>() as f32 / deltas.len() as f32
|
deltas.iter().sum::<i8>() as f32 / deltas.len() as f32
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn penalties(&self, team: Team) -> usize {
|
||||||
|
self.periods
|
||||||
|
.iter()
|
||||||
|
.filter_map(|period| {
|
||||||
|
Some(
|
||||||
|
period
|
||||||
|
.team_events(team.to_owned(), None)
|
||||||
|
.ok()?
|
||||||
|
.iter()
|
||||||
|
.filter_map(|event| {
|
||||||
|
if let Event::Penalty(_) = event {
|
||||||
|
Some(event.to_owned())
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.collect::<Vec<Event>>(),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.collect::<Vec<Vec<Event>>>()
|
||||||
|
.concat()
|
||||||
|
.len()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, Clone, PartialEq)]
|
#[derive(Debug, Deserialize, Clone, PartialEq)]
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
use clap::Parser;
|
use clap::{ArgAction, Parser};
|
||||||
use core::panic;
|
use core::panic;
|
||||||
use gamelog::{Action, Flags, LogFile, Team};
|
use gamelog::{Action, Flags, Key, LogFile, Team};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
#[derive(Debug, Parser)]
|
#[derive(Debug, Parser)]
|
||||||
|
#[clap(author, version, about)]
|
||||||
struct Args {
|
struct Args {
|
||||||
/// Path to source file or block device
|
/// Path to source file or block device
|
||||||
#[arg(
|
#[arg(
|
||||||
@@ -17,6 +18,12 @@ struct Args {
|
|||||||
.unwrap())
|
.unwrap())
|
||||||
)]
|
)]
|
||||||
logfile_path: PathBuf,
|
logfile_path: PathBuf,
|
||||||
|
|
||||||
|
// Behaviour is backwards.
|
||||||
|
// ArgAction::SetFalse by default evaluates to true,
|
||||||
|
// ArgAction::SetTrue by default evaluates to false.
|
||||||
|
#[arg(short, long, action=ArgAction::SetFalse)]
|
||||||
|
display_results: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
@@ -39,6 +46,7 @@ fn main() {
|
|||||||
TeamStats::new(Team::TexasAnM),
|
TeamStats::new(Team::TexasAnM),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// Work on knocking down the nesting here?
|
||||||
for game in log.0.iter() {
|
for game in log.0.iter() {
|
||||||
if let Ok(teams) = game.teams() {
|
if let Ok(teams) = game.teams() {
|
||||||
for team in teams {
|
for team in teams {
|
||||||
@@ -70,13 +78,22 @@ fn main() {
|
|||||||
stats[team_idx]
|
stats[team_idx]
|
||||||
.plays_per_quarter
|
.plays_per_quarter
|
||||||
.push(game.avg_plays_per_quarter(team.to_owned()));
|
.push(game.avg_plays_per_quarter(team.to_owned()));
|
||||||
|
|
||||||
|
stats[team_idx]
|
||||||
|
.plays_per_game
|
||||||
|
.push(game.team_plays(team.to_owned()));
|
||||||
|
|
||||||
|
stats[team_idx]
|
||||||
|
.penalties_per_game
|
||||||
|
.push(game.penalties(team.to_owned()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for team in stats {
|
if dbg!(config.display_results) {
|
||||||
dbg!(team);
|
// :#? for pretty-printing.
|
||||||
|
stats.iter().for_each(|team| println!("{:#?}", team));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,13 +108,15 @@ struct TeamStats {
|
|||||||
plays_per_quarter: Vec<f32>,
|
plays_per_quarter: Vec<f32>,
|
||||||
plays_per_game: Vec<usize>,
|
plays_per_game: Vec<usize>,
|
||||||
// Penalties
|
// Penalties
|
||||||
penalties_per_game: Vec<u8>,
|
penalties_per_game: Vec<usize>,
|
||||||
// Score
|
// Score
|
||||||
points_per_quarter: Vec<u8>,
|
points_per_quarter: Vec<u8>,
|
||||||
points_per_game: Vec<u8>,
|
points_per_game: Vec<u8>,
|
||||||
// Biases
|
// Biases
|
||||||
most_common_play: Option<Action>,
|
most_common_play: Option<Action>,
|
||||||
least_common_play: Option<Action>,
|
least_common_play: Option<Action>,
|
||||||
|
most_common_key: Option<Key>,
|
||||||
|
least_common_key: Option<Key>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TeamStats {
|
impl TeamStats {
|
||||||
@@ -114,6 +133,8 @@ impl TeamStats {
|
|||||||
points_per_game: vec![],
|
points_per_game: vec![],
|
||||||
most_common_play: None,
|
most_common_play: None,
|
||||||
least_common_play: None,
|
least_common_play: None,
|
||||||
|
most_common_key: None,
|
||||||
|
least_common_key: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user