use crate::motion::config::MotionPlannerConfig;
use crate::motion::types::PathCache;
use crate::tonnetz::StdHyperTonnetz;
use core::hash::Hash;
pub struct MotionPlanner<'a, T = usize>
where
T: Eq + Hash,
{
pub(crate) cache: PathCache<T>,
pub(crate) tonnetz: &'a StdHyperTonnetz<T>,
pub(crate) config: MotionPlannerConfig,
}
#[cfg(test)]
mod tests {
use super::MotionPlanner;
use crate::tonnetz::HyperTonnetz;
use crate::triad::Triad;
use rstmt_core::Octave;
#[test]
fn test_motion_planner() -> crate::Result<()> {
let mut tonnetz = HyperTonnetz::new();
let _ = tonnetz.scaffold_layer(Octave(4))?;
let c_major = Triad::major(0).dynamic(); let c_major_idx = tonnetz.add_triad(c_major)?;
let mut planner = MotionPlanner::new(&tonnetz).with_max_depth(4);
let target_note = 1; let paths = planner.find_paths_to_pitch(c_major_idx, target_note);
assert!(!paths.is_empty());
for path in paths {
assert!(path.triads().last().unwrap().contains(&target_note));
}
Ok(())
}
}