StrainConstants

Struct StrainConstants 

Source
pub struct StrainConstants {
    pub constant_variables: Vec<ConstantVariable>,
}
Expand description

Constant Variables for any specific Gamemode that the Strain Solver can use to solve.

Fields§

§constant_variables: Vec<ConstantVariable>

List of Constant Variables for the current Solver.

Implementations§

Source§

impl StrainConstants

Source

pub fn new_constant(&mut self, name: String, value: f32) -> f32

Create a new constant variable for difficulty calculation and optimization.

Source

pub fn get_info_from_variables(&self) -> String

Returns a string of Constant Variable info mainly used for debugging and optimization

Source

pub fn new(constant_variables: Option<Vec<ConstantVariable>>) -> Self

Constructor

Examples found in repository?
examples/basic_usage.rs (line 18)
3fn main() -> Result<(), Box<dyn std::error::Error>> {
4    println!("Parsing .qua file...");
5    
6    // Parse the .qua file
7    let qua = Qua::from_file("assets/171402.qua")?;
8    
9    println!("Map: {} - {}", qua.metadata.title, qua.metadata.artist);
10    println!("Creator: {}", qua.metadata.creator);
11    println!("Difficulty: {}", qua.metadata.difficulty_name);
12    println!("Mode: {:?}", qua.metadata.mode);
13    println!("Hit Objects: {}", qua.hit_objects.len());
14    println!("Timing Points: {}", qua.timing_points.len());
15    
16    // Calculate difficulty
17    println!("\nCalculating difficulty...");
18    let constants = StrainConstants::new(None);
19    let mut processor = DifficultyProcessor::new(qua, constants, ModIdentifier::NONE);
20    processor.calculate_difficulty(ModIdentifier::NONE);
21    
22    println!("Overall Difficulty: {:.2}", processor.overall_difficulty);
23    println!("Average Note Density: {:.2}", processor.average_note_density);
24    println!("Map Length: {:.2}", processor.map.length());
25    println!("Hit Objects Count: {}", processor.map.hit_objects.len());
26    println!("Timing Points Count: {}", processor.map.timing_points.len());
27    
28    Ok(())
29}

Trait Implementations§

Source§

impl Clone for StrainConstants

Source§

fn clone(&self) -> StrainConstants

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for StrainConstants

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.