ravenous-tools/crates/weaponry/src/strategy.rs

88 lines
2.2 KiB
Rust

// Workspace: weaponry
// File: weaponry/src/strategy.rs
//! All different algorythms and strategies to create a weapon
//!
//! These strategies can lock a parameter to allow a more fine tuned balancing
//! or balancing specifically one parameter (balancing materials, balencing finishes etc..)
//! These strategies must take into account the level of the fighter (hence his precision) and of the craftsman (hence a difficulty diminution)
//!
#![allow(dead_code)]
/// Generation strategy, how to generate all the data, instead of a full permutation
pub enum EquipementStrategy {
/// Full permutation, generate all possible outcomes
GenerateAll,
/// Generate all the named equipements
GenerateNamed,
/// Do not add finishing touches
NoFinishes,
}
/// Which material to select
pub enum MaterialsStrategy {
/// Add all materials to the mix
AllMaterials,
/// Add only tier one material
OnlyTier1,
/// Add only easy materials
OnlyEasy,
/// Add only cheap materials
OnlyCheap,
/// Add only one material
OnlyOne,
}
/// Filter to apply after the generation
pub enum EquipementFilter {
/// Don't filter anything
All,
/// Filter all outliers
Outiliers,
/// Filter in all the named
Named,
}
// /// D
// struct Gen<T>
// where
// T: Send,
// {
// /// E
// elem: Vec<T>,
// }
// impl<T: Send> ParallelIterator for Gen<T> {
// type Item = T;
// fn drive_unindexed<C>(self, consumer: C) -> C::Result
// where
// C: rayon::iter::plumbing::UnindexedConsumer<Self::Item>,
// {
// let _ = consumer;
// todo!()
// }
// }
// /// Default full generation strategy
// pub fn default_generation() -> impl ParallelIterator {
// Gen::<u8> { elem: Vec::new() }
// }
/// Default full generation strategy
pub fn default_generation<T: Copy>(a: Vec<T>, b: Vec<T>) -> Vec<(T, T)> {
a.iter()
.flat_map(|e| b.iter().map(|f| (*e, *f)).collect::<Vec<(T, T)>>())
// .collect::<Vec<Vec<(T, T)>>>()
// .flatten()
.collect()
}
#[cfg(test)]
mod test {
use super::*;
#[test]
fn test_creator() {
let t = default_generation(vec![1, 2, 3], vec![5, 6, 7]);
println!("{:?}", t);
// panic!()
}
}