From 283d00d31a7c67259db3e5898de8674646069c5e Mon Sep 17 00:00:00 2001 From: Dandaedre Date: Sun, 5 Mar 2023 06:24:07 +0100 Subject: [PATCH 1/2] Fix(Rust) - Fix of a silly GIL mistake --- src/io.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/io.rs b/src/io.rs index 6c06e85..2fa3915 100644 --- a/src/io.rs +++ b/src/io.rs @@ -275,7 +275,7 @@ use crate::{solve_craft, Recipe, Stats}; /// ``` #[cfg(not(feature = "no_python"))] #[pyfunction] -pub fn solve_from_python(values: &PyAny) -> PyResult>> { +pub fn solve_from_python(py: Python<'_>, values: &PyAny) -> PyResult>> { // Create Recipe let recipe = Recipe { durability: values.getattr("durability")?.extract()?, @@ -304,8 +304,10 @@ pub fn solve_from_python(values: &PyAny) -> PyResult>> }; // println!("{:?} len: {:?} ",values,values.getattr("len()")); - let res = solve_craft(recipe, stats, param); - Ok(res) + py.allow_threads(move || { + let res = solve_craft(recipe, stats, param); + Ok(res) + }) } #[cfg(test)] -- 2.45.1 From a54c09bc66e8244aa1e340b8a5b4a4e30aaf9d88 Mon Sep 17 00:00:00 2001 From: Dandaedre Date: Mon, 6 Mar 2023 03:13:53 +0100 Subject: [PATCH 2/2] Coverage(WIP) - Deletes the html coverage report and addns specs coverage --- .gitignore | 1 + Cargo.lock | 2 +- coverage/html/badges/flat.svg | 8 +- coverage/html/badges/flat_square.svg | 6 +- coverage/html/badges/for_the_badge.svg | 6 +- coverage/html/badges/plastic.svg | 8 +- coverage/html/badges/social.svg | 8 +- coverage/html/coverage.json | 1 - coverage/html/index.html | 129 - coverage/html/src/action.rs.html | 4912 ------------------- coverage/html/src/bin/index.html | 81 - coverage/html/src/bin/xiv_csolver.rs.html | 1232 ----- coverage/html/src/craft.rs.html | 2400 ---------- coverage/html/src/index.html | 201 - coverage/html/src/io.rs.html | 5328 --------------------- coverage/html/src/lib.rs.html | 4496 ----------------- coverage/html/src/solver.rs.html | 3952 --------------- coverage/html/src/specs.rs.html | 2224 --------- coverage/html/tests/index.html | 105 - coverage/html/tests/io.rs.html | 64 - coverage/html/tests/lib.rs.html | 64 - src/craft.rs | 12 + src/io.rs | 2 +- src/specs.rs | 77 +- 24 files changed, 108 insertions(+), 25211 deletions(-) delete mode 100644 coverage/html/coverage.json delete mode 100644 coverage/html/index.html delete mode 100644 coverage/html/src/action.rs.html delete mode 100644 coverage/html/src/bin/index.html delete mode 100644 coverage/html/src/bin/xiv_csolver.rs.html delete mode 100644 coverage/html/src/craft.rs.html delete mode 100644 coverage/html/src/index.html delete mode 100644 coverage/html/src/io.rs.html delete mode 100644 coverage/html/src/lib.rs.html delete mode 100644 coverage/html/src/solver.rs.html delete mode 100644 coverage/html/src/specs.rs.html delete mode 100644 coverage/html/tests/index.html delete mode 100644 coverage/html/tests/io.rs.html delete mode 100644 coverage/html/tests/lib.rs.html diff --git a/.gitignore b/.gitignore index 44bf683..04a3981 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ releases/* .whl pyinstaller_log.txt llvm/* +/coverage/* # Byte-compiled / optimized / DLL files __pycache__/ diff --git a/Cargo.lock b/Cargo.lock index f5b5874..18a2bae 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -590,7 +590,7 @@ checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" [[package]] name = "xiv_csolver" -version = "0.2.0" +version = "0.1.6" dependencies = [ "clap", "lazy_static", diff --git a/coverage/html/badges/flat.svg b/coverage/html/badges/flat.svg index ca7e6f8..d9147e7 100644 --- a/coverage/html/badges/flat.svg +++ b/coverage/html/badges/flat.svg @@ -1,6 +1,6 @@ - coverage: 10% + xmlns:xlink="http://www.w3.org/1999/xlink" width="96" height="20" role="img" aria-label="coverage: 22%"> + coverage: 22% @@ -16,8 +16,8 @@ coverage - - 10% + + 22% \ No newline at end of file diff --git a/coverage/html/badges/flat_square.svg b/coverage/html/badges/flat_square.svg index 9f2ccbb..76037e6 100644 --- a/coverage/html/badges/flat_square.svg +++ b/coverage/html/badges/flat_square.svg @@ -1,13 +1,13 @@ - coverage: 10% + xmlns:xlink="http://www.w3.org/1999/xlink" width="96" height="20" role="img" aria-label="coverage: 22%"> + coverage: 22% coverage - 10% + 22% \ No newline at end of file diff --git a/coverage/html/badges/for_the_badge.svg b/coverage/html/badges/for_the_badge.svg index 17ec9e4..53a73bc 100644 --- a/coverage/html/badges/for_the_badge.svg +++ b/coverage/html/badges/for_the_badge.svg @@ -1,13 +1,13 @@ - COVERAGE: 10% + xmlns:xlink="http://www.w3.org/1999/xlink" width="142.5" height="28" role="img" aria-label="COVERAGE: 22%"> + COVERAGE: 22% COVERAGE - 10% + 22% \ No newline at end of file diff --git a/coverage/html/badges/plastic.svg b/coverage/html/badges/plastic.svg index a127f7c..1296731 100644 --- a/coverage/html/badges/plastic.svg +++ b/coverage/html/badges/plastic.svg @@ -1,6 +1,6 @@ - coverage: 10% + xmlns:xlink="http://www.w3.org/1999/xlink" width="96" height="18" role="img" aria-label="coverage: 22%"> + coverage: 22% @@ -18,8 +18,8 @@ coverage - - 10% + + 22% \ No newline at end of file diff --git a/coverage/html/badges/social.svg b/coverage/html/badges/social.svg index 81f5278..5dc8ab7 100644 --- a/coverage/html/badges/social.svg +++ b/coverage/html/badges/social.svg @@ -1,6 +1,6 @@ - Coverage: 10% + xmlns:xlink="http://www.w3.org/1999/xlink" width="99" height="20" role="img" aria-label="Coverage: 22%"> + Coverage: 22% @@ -20,8 +20,8 @@ Coverage - - 10% + + 22% \ No newline at end of file diff --git a/coverage/html/coverage.json b/coverage/html/coverage.json deleted file mode 100644 index b3f9229..0000000 --- a/coverage/html/coverage.json +++ /dev/null @@ -1 +0,0 @@ -{"schemaVersion":1,"label":"coverage","message":"10%","color":"red"} \ No newline at end of file diff --git a/coverage/html/index.html b/coverage/html/index.html deleted file mode 100644 index efa6e0b..0000000 --- a/coverage/html/index.html +++ /dev/null @@ -1,129 +0,0 @@ - - - - - Grcov report - top_level - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
DirectoryLine CoverageFunctionsBranches
src - - 10.84% - - - 10.84% - - 115 / 1061 - 8.53%29 / 340 100%0 / 0
src/bin - - 1.64% - - - 1.64% - - 1 / 61 - 20%1 / 5 100%0 / 0
tests - - 100% - - - 100% - - 2 / 2 - 100%2 / 2 100%0 / 0
-
-
-

Date: 2023-03-01 23:03

-
-
- - diff --git a/coverage/html/src/action.rs.html b/coverage/html/src/action.rs.html deleted file mode 100644 index f402e3a..0000000 --- a/coverage/html/src/action.rs.html +++ /dev/null @@ -1,4912 +0,0 @@ - - - - - Grcov report - action.rs - - -
- - - -
-
- 1 -
-
- -
-
-
use crate::craft::Craft;
-
-
-
- 2 -
-
- -
-
-
use crate::specs::{Buff, Success};
-
-
-
- 3 -
-
- -
-
-
use lazy_static::lazy_static;
-
-
-
- 4 -
-
- -
-
-
#[allow(dead_code)]
-
-
-
- 5 -
-
- -
-
-
use std::fmt::Debug;
-
-
-
- 6 -
-
- -
-
-

-            
-
-
- 7 -
-
- -
-
-
pub struct Action {
-
-
-
- 8 -
-
- -
-
-
    pub name: String,
-
-
-
- 9 -
-
- -
-
-
    pub dur: u32,
-
-
-
- 10 -
-
- -
-
-
    pub cp: u32,
-
-
-
- 11 -
-
- -
-
-
    pub progress: u32,
-
-
-
- 12 -
-
- -
-
-
    pub quality: u32,
-
-
-
- 13 -
-
- -
-
-
    pub buff: Option<(Buff, u8)>,
-
-
-
- 14 -
-
- -
-
-
    pub short_name: String,
-
-
-
- 15 -
-
- -
-
-
}
-
-
-
- 16 -
-
- -
-
-

-            
-
-
- 17 -
-
- -
-
-
pub struct ActionBuilder {
-
-
-
- 18 -
-
- -
-
-
    action: Action,
-
-
-
- 19 -
-
- -
-
-
}
-
-
-
- 20 -
-
- -
-
-

-            
-
-
- 21 -
-
- -
-
-
impl ActionBuilder {
-
-
-
- 22 -
-
- -
-
-
    pub fn new(name: &str) -> Self {
-
-
-
- 23 -
-
- -
-
-
        let mut short_name = name.to_string();
-
-
-
- 24 -
-
- -
-
-
        short_name = short_name.replace("II", "2");
-
-
-
- 25 -
-
- -
-
-
        short_name.retain(|c| !c.is_whitespace() && c != '\'');
-
-
-
- 26 -
-
- -
-
-
        short_name[0..1].make_ascii_lowercase();
-
-
-
- 27 -
-
- -
-
-
        if name == "Basic Synthesis" {
-
-
-
- 28 -
-
- -
-
-
            short_name = "basicSynth2".to_string();
-
-
-
- 29 -
-
- -
-
-
        }
-
-
-
- 30 -
-
- -
-
-
        if name == "Groundwork" {
-
-
-
- 31 -
-
- -
-
-
            short_name = "groundwork".to_string();
-
-
-
- 32 -
-
- -
-
-
        }
-
-
-
- 33 -
-
- -
-
-
        if name == "Careful Synthesis" {
-
-
-
- 34 -
-
- -
-
-
            short_name = "carefulSynthesis".to_string();
-
-
-
- 35 -
-
- -
-
-
        }
-
-
-
- 36 -
-
- -
-
-

-            
-
-
- 37 -
-
- -
-
-
        Self {
-
-
-
- 38 -
-
- -
-
-
            action: Action {
-
-
-
- 39 -
-
- -
-
-
                name: name.to_string(),
-
-
-
- 40 -
-
- -
-
-
                dur: 10,
-
-
-
- 41 -
-
- -
-
-
                cp: 0,
-
-
-
- 42 -
-
- -
-
-
                progress: 0,
-
-
-
- 43 -
-
- -
-
-
                quality: 0,
-
-
-
- 44 -
-
- -
-
-
                buff: None,
-
-
-
- 45 -
-
- -
-
-
                short_name,
-
-
-
- 46 -
-
- -
-
-
            },
-
-
-
- 47 -
-
- -
-
-
        }
-
-
-
- 48 -
-
- -
-
-
    }
-
-
-
- 49 -
-
- -
-
-
    pub fn dur(mut self, dur: u32) -> Self {
-
-
-
- 50 -
-
- -
-
-
        self.action.dur = dur;
-
-
-
- 51 -
-
- -
-
-
        self
-
-
-
- 52 -
-
- -
-
-
    }
-
-
-
- 53 -
-
- -
-
-
    pub fn cp(mut self, cp: u32) -> Self {
-
-
-
- 54 -
-
- -
-
-
        self.action.cp = cp;
-
-
-
- 55 -
-
- -
-
-
        self
-
-
-
- 56 -
-
- -
-
-
    }
-
-
-
- 57 -
-
- -
-
-
    pub fn progress(mut self, progress: u32) -> Self {
-
-
-
- 58 -
-
- -
-
-
        self.action.progress = progress;
-
-
-
- 59 -
-
- -
-
-
        self
-
-
-
- 60 -
-
- -
-
-
    }
-
-
-
- 61 -
-
- -
-
-
    pub fn quality(mut self, quality: u32) -> Self {
-
-
-
- 62 -
-
- -
-
-
        self.action.quality = quality;
-
-
-
- 63 -
-
- -
-
-
        self
-
-
-
- 64 -
-
- -
-
-
    }
-
-
-
- 65 -
-
- -
-
-
    pub fn buff(mut self, buff: Option<(Buff, u8)>) -> Self {
-
-
-
- 66 -
-
- -
-
-
        self.action.buff = buff;
-
-
-
- 67 -
-
- -
-
-
        self
-
-
-
- 68 -
-
- -
-
-
    }
-
-
-
- 69 -
-
- -
-
-
    pub fn build(self) -> Action {
-
-
-
- 70 -
-
- -
-
-
        self.action
-
-
-
- 71 -
-
- -
-
-
    }
-
-
-
- 72 -
-
- -
-
-
}
-
-
-
- 73 -
-
- -
-
-

-            
-
-
- 74 -
-
- -
-
-
impl PartialEq for Action {
-
-
-
- 75 -
-
- -
-
-
    fn eq(&self, other: &Self) -> bool {
-
-
-
- 76 -
-
- -
-
-
        self.cp == other.cp
-
-
-
- 77 -
-
- -
-
-
            && self.dur == other.dur
-
-
-
- 78 -
-
- -
-
-
            && self.progress == other.progress
-
-
-
- 79 -
-
- -
-
-
            && self.quality == other.quality
-
-
-
- 80 -
-
- -
-
-
    }
-
-
-
- 81 -
-
- -
-
-
}
-
-
-
- 82 -
-
- -
-
-

-            
-
-
- 83 -
-
- -
-
-
impl Action {
-
-
-
- 84 -
-
- -
-
-
    pub fn get_name(&self) -> String {
-
-
-
- 85 -
-
- -
-
-
        self.name.clone()
-
-
-
- 86 -
-
- -
-
-
    }
-
-
-
- 87 -
-
- -
-
-
    pub fn get_cp_cost(&self, _craft: &Craft) -> u32 {
-
-
-
- 88 -
-
- -
-
-
        if self == &ACTIONS.standard_touch && _craft.buffs.basic_touch > 0 {
-
-
-
- 89 -
-
- -
-
-
            return 18;
-
-
-
- 90 -
-
- -
-
-
        };
-
-
-
- 91 -
-
- -
-
-
        if self == &ACTIONS.advanced_touch && _craft.buffs.standard_touch > 0 {
-
-
-
- 92 -
-
- -
-
-
            return 18;
-
-
-
- 93 -
-
- -
-
-
        };
-
-
-
- 94 -
-
- -
-
-
        self.cp
-
-
-
- 95 -
-
- -
-
-
    }
-
-
-
- 96 -
-
- -
-
-
    pub fn get_durability_cost(&self, _craft: &Craft) -> u32 {
-
-
-
- 97 -
-
- -
-
-
        if self == &ACTIONS.masters_mend {
-
-
-
- 98 -
-
- -
-
-
            return 30;
-
-
-
- 99 -
-
- -
-
-
        }
-
-
-
- 100 -
-
- -
-
-
        if self.dur == 0 || self.progress == 0 && self.quality == 0 {
-
-
-
- 101 -
-
- -
-
-
            return 0;
-
-
-
- 102 -
-
- -
-
-
        }
-
-
-
- 103 -
-
- -
-
-
        let mut dur = self.dur;
-
-
-
- 104 -
-
- -
-
-
        if _craft.buffs.waste_not > 0 {
-
-
-
- 105 -
-
- -
-
-
            dur /= 2;
-
-
-
- 106 -
-
- -
-
-
        }
-
-
-
- 107 -
-
- -
-
-
        if dur < 5 {
-
-
-
- 108 -
-
- -
-
-
            dur = 5;
-
-
-
- 109 -
-
- -
-
-
        }
-
-
-
- 110 -
-
- -
-
-
        dur
-
-
-
- 111 -
-
- -
-
-
    }
-
-
-
- 112 -
-
- -
-
-
    pub fn get_progress(&self, _craft: &Craft) -> u32 {
-
-
-
- 113 -
-
- -
-
-
        let mut prog = self.progress as f64;
-
-
-
- 114 -
-
- -
-
-
        if self.dur == 20 && _craft.durability < self.get_durability_cost(_craft) as i32 {
-
-
-
- 115 -
-
- -
-
-
            prog /= 2.0;
-
-
-
- 116 -
-
- -
-
-
        }
-
-
-
- 117 -
-
- -
-
-
        let mut mult = 1.0;
-
-
-
- 118 -
-
- -
-
-
        if _craft.buffs.muscle_memory > 0 {
-
-
-
- 119 -
-
- -
-
-
            mult += 1.0;
-
-
-
- 120 -
-
- -
-
-
        }
-
-
-
- 121 -
-
- -
-
-
        if _craft.buffs.veneration > 0 {
-
-
-
- 122 -
-
- -
-
-
            mult += 0.5;
-
-
-
- 123 -
-
- -
-
-
        }
-
-
-
- 124 -
-
- -
-
-
        (prog * mult).floor() as u32
-
-
-
- 125 -
-
- -
-
-
    }
-
-
-
- 126 -
-
- -
-
-
    pub fn get_quality(&self, _craft: &Craft) -> u32 {
-
-
-
- 127 -
-
- -
-
-
        let mut qual = self.quality as f64;
-
-
-
- 128 -
-
- -
-
-
        if self == &ACTIONS.byregot_blessing {
-
-
-
- 129 -
-
- -
-
-
            qual = (100 + 20 * _craft.buffs.inner_quiet as u32) as f64;
-
-
-
- 130 -
-
- -
-
-
        }
-
-
-
- 131 -
-
- -
-
-
        if self.dur == 20 && _craft.durability < self.get_durability_cost(_craft) as i32 {
-
-
-
- 132 -
-
- -
-
-
            qual /= 2.0;
-
-
-
- 133 -
-
- -
-
-
        }
-
-
-
- 134 -
-
- -
-
-
        let mut mult = 1.0;
-
-
-
- 135 -
-
- -
-
-
        if _craft.buffs.great_strides > 0 {
-
-
-
- 136 -
-
- -
-
-
            mult += 1.0;
-
-
-
- 137 -
-
- -
-
-
        }
-
-
-
- 138 -
-
- -
-
-
        if _craft.buffs.innovation > 0 {
-
-
-
- 139 -
-
- -
-
-
            mult += 0.5;
-
-
-
- 140 -
-
- -
-
-
        }
-
-
-
- 141 -
-
- -
-
-
        let iq_mult = (_craft.buffs.inner_quiet as f64 * 0.1) + 1.0;
-
-
-
- 142 -
-
- -
-
-
        (qual * mult * iq_mult).floor() as u32
-
-
-
- 143 -
-
- -
-
-
    }
-
-
-
- 144 -
-
- -
-
-
    pub fn get_buff(&self) -> Option<(Buff, u8)> {
-
-
-
- 145 -
-
- -
-
-
        self.buff
-
-
-
- 146 -
-
- -
-
-
    }
-
-
-
- 147 -
-
- -
-
-
    pub fn can_use(&self, _craft: &Craft) -> bool {
-
-
-
- 148 -
-
- -
-
-
        if self.get_cp_cost(_craft) > _craft.cp as u32 {
-
-
-
- 149 -
-
- -
-
-
            return false;
-
-
-
- 150 -
-
- -
-
-
        }
-
-
-
- 151 -
-
- -
-
-
        if _craft.success != Success::Pending {
-
-
-
- 152 -
-
- -
-
-
            return false;
-
-
-
- 153 -
-
- -
-
-
        }
-
-
-
- 154 -
-
- -
-
-
        if self == &ACTIONS.byregot_blessing {
-
-
-
- 155 -
-
- -
-
-
            return _craft.buffs.inner_quiet > 0;
-
-
-
- 156 -
-
- -
-
-
        }
-
-
-
- 157 -
-
- -
-
-
        if self == &ACTIONS.muscle_memory || self == &ACTIONS.reflect {
-
-
-
- 158 -
-
- -
-
-
            return _craft.step_count == 0;
-
-
-
- 159 -
-
- -
-
-
        }
-
-
-
- 160 -
-
- -
-
-
        if self == &ACTIONS.trained_finesse {
-
-
-
- 161 -
-
- -
-
-
            return _craft.buffs.inner_quiet >= 10;
-
-
-
- 162 -
-
- -
-
-
        }
-
-
-
- 163 -
-
- -
-
-
        true
-
-
-
- 164 -
-
- -
-
-
    }
-
-
-
- 165 -
-
- -
-
-
}
-
-
-
- 166 -
-
- -
-
-

-            
-
-
- 167 -
-
- -
-
-
impl Debug for Action {
-
-
-
- 168 -
-
- -
-
-
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
-
-
-
- 169 -
-
- -
-
-
        f.write_str(&self.name)
-
-
-
- 170 -
-
- -
-
-
    }
-
-
-
- 171 -
-
- -
-
-
}
-
-
-
- 172 -
-
- -
-
-

-            
-
-
- 173 -
-
- -
-
-
pub struct ActionList {
-
-
-
- 174 -
-
- -
-
-
    pub muscle_memory: Action,
-
-
-
- 175 -
-
- -
-
-
    pub reflect: Action,
-
-
-
- 176 -
-
- -
-
-
    pub basic_synthesis: Action,
-
-
-
- 177 -
-
- -
-
-
    pub careful_synthesis: Action,
-
-
-
- 178 -
-
- -
-
-
    pub groundwork: Action,
-
-
-
- 179 -
-
- -
-
-
    pub prudent_synthesis: Action,
-
-
-
- 180 -
-
- -
-
-
    pub delicate_synthesis: Action,
-
-
-
- 181 -
-
- -
-
-
    pub basic_touch: Action,
-
-
-
- 182 -
-
- -
-
-
    pub standard_touch: Action,
-
-
-
- 183 -
-
- -
-
-
    pub byregot_blessing: Action,
-
-
-
- 184 -
-
- -
-
-
    pub prudent_touch: Action,
-
-
-
- 185 -
-
- -
-
-
    pub preparatory_touch: Action,
-
-
-
- 186 -
-
- -
-
-
    pub advanced_touch: Action,
-
-
-
- 187 -
-
- -
-
-
    pub trained_finesse: Action,
-
-
-
- 188 -
-
- -
-
-
    pub masters_mend: Action,
-
-
-
- 189 -
-
- -
-
-
    pub waste_not: Action,
-
-
-
- 190 -
-
- -
-
-
    pub waste_not_ii: Action,
-
-
-
- 191 -
-
- -
-
-
    pub manipulation: Action,
-
-
-
- 192 -
-
- -
-
-
    pub veneration: Action,
-
-
-
- 193 -
-
- -
-
-
    pub great_strides: Action,
-
-
-
- 194 -
-
- -
-
-
    pub innovation: Action,
-
-
-
- 195 -
-
- -
-
-
    //pub observe: Action,
-
-
-
- 196 -
-
- -
-
-
    //pub focused_synthesis: Action,
-
-
-
- 197 -
-
- -
-
-
}
-
-
-
- 198 -
-
- -
-
-

-            
-
-
- 199 -
-
- -
-
-
impl Default for ActionList {
-
-
-
- 200 -
-
- -
-
-
    fn default() -> Self {
-
-
-
- 201 -
-
- -
-
-
        Self {
-
-
-
- 202 -
-
- -
-
-
            muscle_memory: ActionBuilder::new("Muscle Memory")
-
-
-
- 203 -
-
- -
-
-
                .cp(6)
-
-
-
- 204 -
-
- -
-
-
                .progress(300)
-
-
-
- 205 -
-
- -
-
-
                .buff(Some((Buff::MuscleMemory, 5)))
-
-
-
- 206 -
-
- -
-
-
                .build(),
-
-
-
- 207 -
-
- -
-
-
            reflect: ActionBuilder::new("Reflect")
-
-
-
- 208 -
-
- -
-
-
                .cp(6)
-
-
-
- 209 -
-
- -
-
-
                .quality(100)
-
-
-
- 210 -
-
- -
-
-
                .buff(Some((Buff::InnerQuiet, 1)))
-
-
-
- 211 -
-
- -
-
-
                .build(),
-
-
-
- 212 -
-
- -
-
-

-            
-
-
- 213 -
-
- -
-
-
            basic_synthesis: ActionBuilder::new("Basic Synthesis").progress(120).build(),
-
-
-
- 214 -
-
- -
-
-
            careful_synthesis: ActionBuilder::new("Careful Synthesis")
-
-
-
- 215 -
-
- -
-
-
                .cp(7)
-
-
-
- 216 -
-
- -
-
-
                .progress(180)
-
-
-
- 217 -
-
- -
-
-
                .build(),
-
-
-
- 218 -
-
- -
-
-
            groundwork: ActionBuilder::new("Groundwork")
-
-
-
- 219 -
-
- -
-
-
                .cp(18)
-
-
-
- 220 -
-
- -
-
-
                .dur(20)
-
-
-
- 221 -
-
- -
-
-
                .progress(360)
-
-
-
- 222 -
-
- -
-
-
                .build(),
-
-
-
- 223 -
-
- -
-
-
            prudent_synthesis: ActionBuilder::new("Prudent Synthesis")
-
-
-
- 224 -
-
- -
-
-
                .cp(18)
-
-
-
- 225 -
-
- -
-
-
                .dur(5)
-
-
-
- 226 -
-
- -
-
-
                .progress(180)
-
-
-
- 227 -
-
- -
-
-
                .build(),
-
-
-
- 228 -
-
- -
-
-
            delicate_synthesis: ActionBuilder::new("Delicate Synthesis")
-
-
-
- 229 -
-
- -
-
-
                .cp(32)
-
-
-
- 230 -
-
- -
-
-
                .progress(100)
-
-
-
- 231 -
-
- -
-
-
                .quality(100)
-
-
-
- 232 -
-
- -
-
-
                .build(),
-
-
-
- 233 -
-
- -
-
-

-            
-
-
- 234 -
-
- -
-
-
            basic_touch: ActionBuilder::new("Basic Touch")
-
-
-
- 235 -
-
- -
-
-
                .cp(18)
-
-
-
- 236 -
-
- -
-
-
                .quality(100)
-
-
-
- 237 -
-
- -
-
-
                .buff(Some((Buff::BasicTouch, 1)))
-
-
-
- 238 -
-
- -
-
-
                .build(),
-
-
-
- 239 -
-
- -
-
-
            standard_touch: ActionBuilder::new("Standard Touch")
-
-
-
- 240 -
-
- -
-
-
                .quality(125)
-
-
-
- 241 -
-
- -
-
-
                .cp(32)
-
-
-
- 242 -
-
- -
-
-
                .buff(Some((Buff::StandardTouch, 1)))
-
-
-
- 243 -
-
- -
-
-
                .build(),
-
-
-
- 244 -
-
- -
-
-
            byregot_blessing: ActionBuilder::new("Byregot's Blessing")
-
-
-
- 245 -
-
- -
-
-
                .cp(24)
-
-
-
- 246 -
-
- -
-
-
                .quality(100)
-
-
-
- 247 -
-
- -
-
-
                .buff(Some((Buff::InnerQuiet, 0)))
-
-
-
- 248 -
-
- -
-
-
                .build(),
-
-
-
- 249 -
-
- -
-
-
            prudent_touch: ActionBuilder::new("Prudent Touch")
-
-
-
- 250 -
-
- -
-
-
                .cp(25)
-
-
-
- 251 -
-
- -
-
-
                .dur(5)
-
-
-
- 252 -
-
- -
-
-
                .quality(100)
-
-
-
- 253 -
-
- -
-
-
                .build(),
-
-
-
- 254 -
-
- -
-
-
            preparatory_touch: ActionBuilder::new("Preparatory Touch")
-
-
-
- 255 -
-
- -
-
-
                .cp(40)
-
-
-
- 256 -
-
- -
-
-
                .dur(20)
-
-
-
- 257 -
-
- -
-
-
                .quality(200)
-
-
-
- 258 -
-
- -
-
-
                .buff(Some((Buff::InnerQuiet, 1)))
-
-
-
- 259 -
-
- -
-
-
                .build(),
-
-
-
- 260 -
-
- -
-
-
            advanced_touch: ActionBuilder::new("Advanced Touch")
-
-
-
- 261 -
-
- -
-
-
                .quality(150)
-
-
-
- 262 -
-
- -
-
-
                .cp(46)
-
-
-
- 263 -
-
- -
-
-
                .build(),
-
-
-
- 264 -
-
- -
-
-
            trained_finesse: ActionBuilder::new("Trained Finesse")
-
-
-
- 265 -
-
- -
-
-
                .cp(32)
-
-
-
- 266 -
-
- -
-
-
                .quality(100)
-
-
-
- 267 -
-
- -
-
-
                .dur(0)
-
-
-
- 268 -
-
- -
-
-
                .build(),
-
-
-
- 269 -
-
- -
-
-

-            
-
-
- 270 -
-
- -
-
-
            masters_mend: ActionBuilder::new("Master's Mend").cp(88).build(),
-
-
-
- 271 -
-
- -
-
-
            waste_not: ActionBuilder::new("Waste Not")
-
-
-
- 272 -
-
- -
-
-
                .cp(56)
-
-
-
- 273 -
-
- -
-
-
                .buff(Some((Buff::WasteNot, 4)))
-
-
-
- 274 -
-
- -
-
-
                .build(),
-
-
-
- 275 -
-
- -
-
-
            waste_not_ii: ActionBuilder::new("Waste Not II")
-
-
-
- 276 -
-
- -
-
-
                .cp(98)
-
-
-
- 277 -
-
- -
-
-
                .buff(Some((Buff::WasteNot, 8)))
-
-
-
- 278 -
-
- -
-
-
                .build(),
-
-
-
- 279 -
-
- -
-
-
            manipulation: ActionBuilder::new("Manipulation")
-
-
-
- 280 -
-
- -
-
-
                .cp(96)
-
-
-
- 281 -
-
- -
-
-
                .buff(Some((Buff::Manipulation, 8)))
-
-
-
- 282 -
-
- -
-
-
                .build(),
-
-
-
- 283 -
-
- -
-
-
            veneration: ActionBuilder::new("Veneration")
-
-
-
- 284 -
-
- -
-
-
                .cp(18)
-
-
-
- 285 -
-
- -
-
-
                .buff(Some((Buff::Veneration, 4)))
-
-
-
- 286 -
-
- -
-
-
                .build(),
-
-
-
- 287 -
-
- -
-
-
            great_strides: ActionBuilder::new("Great Strides")
-
-
-
- 288 -
-
- -
-
-
                .cp(32)
-
-
-
- 289 -
-
- -
-
-
                .buff(Some((Buff::GreatStrides, 3)))
-
-
-
- 290 -
-
- -
-
-
                .build(),
-
-
-
- 291 -
-
- -
-
-
            innovation: ActionBuilder::new("Innovation")
-
-
-
- 292 -
-
- -
-
-
                .cp(18)
-
-
-
- 293 -
-
- -
-
-
                .buff(Some((Buff::Innovation, 4)))
-
-
-
- 294 -
-
- -
-
-
                .build(),
-
-
-
- 295 -
-
- -
-
-
            // Todo: Add back
-
-
-
- 296 -
-
- -
-
-
            //observe: ActionBuilder::new("observe").cp(18).buff(Some((Buff::Observe, 1))).build(),
-
-
-
- 297 -
-
- -
-
-
            //focused_synthesis: ActionBuilder::new("focused_synthesis").cp(18).quality(100).build(),
-
-
-
- 298 -
-
- -
-
-
        }
-
-
-
- 299 -
-
- -
-
-
    }
-
-
-
- 300 -
-
- -
-
-
}
-
-
-
- 301 -
-
- -
-
-

-            
-
-
- 302 -
-
- -
-
-
lazy_static! {
-
-
-
- 303 -
-
- -
-
-
    pub static ref ACTIONS: ActionList = ActionList::default();
-
-
-
- 304 -
-
- -
-
-
}
-
-
-
-
-
-

Date: 2023-03-01 23:03

-
-
- - diff --git a/coverage/html/src/bin/index.html b/coverage/html/src/bin/index.html deleted file mode 100644 index 1c5c163..0000000 --- a/coverage/html/src/bin/index.html +++ /dev/null @@ -1,81 +0,0 @@ - - - - - Grcov report - src/bin - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
FileLine CoverageFunctionsBranches
xiv_csolver.rs - - 1.64% - - - 1.64% - - 1 / 61 - 20%1 / 5 100%0 / 0
-
-
-

Date: 2023-03-01 23:03

-
-
- - diff --git a/coverage/html/src/bin/xiv_csolver.rs.html b/coverage/html/src/bin/xiv_csolver.rs.html deleted file mode 100644 index 07f2639..0000000 --- a/coverage/html/src/bin/xiv_csolver.rs.html +++ /dev/null @@ -1,1232 +0,0 @@ - - - - - Grcov report - xiv_csolver.rs - - -
- - - -
-
- 1 -
-
- 11 -
-
-
// #![warn(missing_docs,unsafe_code,unstable_features,)]
-
-
-
- 2 -
-
- -
-
-
// #![feature(no_coverage)]
-
-
-
- 3 -
-
- -
-
-
// #![warn(missing_docs)]
-
-
-
- 4 -
-
- -
-
-

-            
-
-
- 5 -
-
- -
-
-
use clap::Parser;
-
-
-
- 6 -
-
- -
-
-
use std::time::Instant;
-
-
-
- 7 -
-
- -
-
-
use xiv_csolver_lib;
-
-
-
- 8 -
-
- -
-
-

-            
-
-
- 9 -
-
- -
-
-
#[derive(Debug)]
-
-
-
- 10 -
-
- -
-
-
struct CustomError(String);
-
-
-
- 11 -
-
- -
-
-

-            
-
-
- 12 -
-
- -
-
-
fn main() {
-
-
-
- 13 -
-
- -
-
-
    let args = xiv_csolver_lib::io::Args::parse();
-
-
-
- 14 -
-
- -
-
-
    let params = xiv_csolver_lib::io::Parameters::from_args(&args);
-
-
-
- 15 -
-
- -
-
-

-            
-
-
- 16 -
-
- -
-
-
    // Start timer
-
-
-
- 17 -
-
- -
-
-
    let now = Instant::now();
-
-
-
- 18 -
-
- -
-
-
    println!("Solving...");
-
-
-
- 19 -
-
- -
-
-

-            
-
-
- 20 -
-
- -
-
-
    // Solve from config
-
-
-
- 21 -
-
- -
-
-
    let (recipe, stats) =
-
-
-
- 22 -
-
- -
-
-
        xiv_csolver_lib::load_from_config(&args.recipe_name, &args.file_name, &args.character_name);
-
-
-
- 23 -
-
- -
-
-
    let results = xiv_csolver_lib::solve_craft(recipe, stats, params);
-
-
-
- 24 -
-
- -
-
-

-            
-
-
- 25 -
-
- -
-
-
    // Stop timer
-
-
-
- 26 -
-
- -
-
-
    let t_final = now.elapsed().as_millis();
-
-
-
- 27 -
-
- -
-
-

-            
-
-
- 28 -
-
- -
-
-
    // Show best result depending on selected value
-
-
-
- 29 -
-
- -
-
-
    match results {
-
-
-
- 30 -
-
- -
-
-
        None => {
-
-
-
- 31 -
-
- -
-
-
            println!(
-
-
-
- 32 -
-
- -
-
-
                "[Error] No solutions found for craft '{}' with crafter '{}' (ms)",
-
-
-
- 33 -
-
- -
-
-
                args.recipe_name, args.character_name
-
-
-
- 34 -
-
- -
-
-
            );
-
-
-
- 35 -
-
- -
-
-
            return;
-
-
-
- 36 -
-
- -
-
-
        }
-
-
-
- 37 -
-
- -
-
-
        Some(ref res) => {
-
-
-
- 38 -
-
- -
-
-
            // Show best results
-
-
-
- 39 -
-
- -
-
-
            if args.verbose > 0 {
-
-
-
- 40 -
-
- -
-
-
                println!("[Final] {} results were found:", res.len());
-
-
-
- 41 -
-
- -
-
-
                #[cfg(feature = "verbose")]
-
-
-
- 42 -
-
- -
-
-
                if args.verbose > 1 {
-
-
-
- 43 -
-
- -
-
-
                    xiv_csolver_lib::print_routes(&results);
-
-
-
- 44 -
-
- -
-
-
                }
-
-
-
- 45 -
-
- -
-
-
            }
-
-
-
- 46 -
-
- -
-
-
        }
-
-
-
- 47 -
-
- -
-
-
    }
-
-
-
- 48 -
-
- -
-
-
    println!("\n > SOLUTION [Least steps] <");
-
-
-
- 49 -
-
- -
-
-
    xiv_csolver_lib::find_fast_route(&results)
-
-
-
- 50 -
-
- -
-
-
        .unwrap()
-
-
-
- 51 -
-
- -
-
-
        .pretty_print();
-
-
-
- 52 -
-
- -
-
-
    println!("\n > SOLUTION [Most durability] <");
-
-
-
- 53 -
-
- -
-
-
    xiv_csolver_lib::find_safe_route(&results)
-
-
-
- 54 -
-
- -
-
-
        .unwrap()
-
-
-
- 55 -
-
- -
-
-
        .pretty_print();
-
-
-
- 56 -
-
- -
-
-
    println!("\n > SOLUTION [Most quality] < ");
-
-
-
- 57 -
-
- -
-
-
    xiv_csolver_lib::find_quality_route(&results)
-
-
-
- 58 -
-
- -
-
-
        .unwrap()
-
-
-
- 59 -
-
- -
-
-
        .pretty_print();
-
-
-
- 60 -
-
- -
-
-

-            
-
-
- 61 -
-
- -
-
-
    // #[cfg(feature = "verbose")]
-
-
-
- 62 -
-
- -
-
-
    // if params.verbose>2{
-
-
-
- 63 -
-
- -
-
-
    //     println!("[F] Top routes {:?}",results);
-
-
-
- 64 -
-
- -
-
-
    // }
-
-
-
- 65 -
-
- -
-
-

-            
-
-
- 66 -
-
- -
-
-
    // Wait for user input
-
-
-
- 67 -
-
- -
-
-
    println!(
-
-
-
- 68 -
-
- -
-
-
        "\nProgram finished successfully in {}ms\nPress enter to exit...",
-
-
-
- 69 -
-
- -
-
-
        t_final
-
-
-
- 70 -
-
- -
-
-
    );
-
-
-
- 71 -
-
- -
-
-
    let mut input = String::new();
-
-
-
- 72 -
-
- -
-
-
    std::io::stdin().read_line(&mut input).unwrap();
-
-
-
- 73 -
-
- -
-
-
    ()
-
-
-
- 74 -
-
- -
-
-
}
-
-
-
-
-
-

Date: 2023-03-01 23:03

-
-
- - diff --git a/coverage/html/src/craft.rs.html b/coverage/html/src/craft.rs.html deleted file mode 100644 index d3e70e2..0000000 --- a/coverage/html/src/craft.rs.html +++ /dev/null @@ -1,2400 +0,0 @@ - - - - - Grcov report - craft.rs - - -
- - - -
-
- 1 -
-
- -
-
-
use crate::action::Action;
-
-
-
- 2 -
-
- -
-
-
use crate::specs::{Buff, BuffState, Recipe, Stats, Success};
-
-
-
- 3 -
-
- -
-
-
use crate::Parameters;
-
-
-
- 4 -
-
- -
-
-
use std::fmt::{Debug, Display, Formatter};
-
-
-
- 5 -
-
- -
-
-

-            
-
-
- 6 -
-
- -
-
-
#[derive(Clone)]
-
-
-
- 7 -
-
- -
-
-
pub struct Craft<'a> {
-
-
-
- 8 -
-
- -
-
-
    pub recipe: Recipe,
-
-
-
- 9 -
-
- -
-
-
    pub stats: Stats,
-
-
-
- 10 -
-
- -
-
-
    pub buffs: BuffState,
-
-
-
- 11 -
-
- -
-
-
    pub step_count: u32,
-
-
-
- 12 -
-
- -
-
-
    pub durability: i32,
-
-
-
- 13 -
-
- -
-
-
    pub progression: u32,
-
-
-
- 14 -
-
- -
-
-
    pub quality: u32,
-
-
-
- 15 -
-
- -
-
-
    pub cp: i32,
-
-
-
- 16 -
-
- -
-
-
    pub success: Success,
-
-
-
- 17 -
-
- -
-
-
    pub actions: Vec<&'a Action>,
-
-
-
- 18 -
-
- -
-
-
    pub args: Parameters,
-
-
-
- 19 -
-
- -
-
-
}
-
-
-
- 20 -
-
- -
-
-

-            
-
-
- 21 -
-
- -
-
-
impl<'a> Craft<'a> {
-
-
-
- 22 -
-
- -
-
-
    pub fn new(recipe: Recipe, stats: Stats, params: Parameters) -> Craft<'a> {
-
-
-
- 23 -
-
- -
-
-
        Self {
-
-
-
- 24 -
-
- -
-
-
            recipe,
-
-
-
- 25 -
-
- -
-
-
            stats,
-
-
-
- 26 -
-
- -
-
-
            buffs: BuffState::default(),
-
-
-
- 27 -
-
- -
-
-
            step_count: 0,
-
-
-
- 28 -
-
- -
-
-
            durability: recipe.durability as i32,
-
-
-
- 29 -
-
- -
-
-
            progression: 0,
-
-
-
- 30 -
-
- -
-
-
            quality: 0,
-
-
-
- 31 -
-
- -
-
-
            cp: stats.max_cp as i32,
-
-
-
- 32 -
-
- -
-
-
            success: Success::Pending,
-
-
-
- 33 -
-
- -
-
-
            actions: Vec::new(),
-
-
-
- 34 -
-
- -
-
-
            args: params,
-
-
-
- 35 -
-
- -
-
-
        }
-
-
-
- 36 -
-
- -
-
-
    }
-
-
-
- 37 -
-
- -
-
-

-            
-
-
- 38 -
-
- -
-
-
    pub fn get_base_progression(&self) -> u32 {
-
-
-
- 39 -
-
- -
-
-
        let base_value = (self.stats.craftsmanship as f64 / 10.0)
-
-
-
- 40 -
-
- -
-
-
            / (self.recipe.progress_divider as f64 / 100.0)
-
-
-
- 41 -
-
- -
-
-
            + 2.0;
-
-
-
- 42 -
-
- -
-
-
        (base_value * (self.recipe.progress_modifier as f64 / 100.0) as f64).floor() as u32
-
-
-
- 43 -
-
- -
-
-
    }
-
-
-
- 44 -
-
- -
-
-

-            
-
-
- 45 -
-
- -
-
-
    pub fn get_base_quality(&self) -> u32 {
-
-
-
- 46 -
-
- -
-
-
        let base_value = (self.stats.control as f64 / 10.0)
-
-
-
- 47 -
-
- -
-
-
            / (self.recipe.quality_divider as f64 / 100.0)
-
-
-
- 48 -
-
- -
-
-
            + 35.0;
-
-
-
- 49 -
-
- -
-
-
        (base_value * (self.recipe.quality_modifier as f64 / 100.0) as f64).floor() as u32
-
-
-
- 50 -
-
- -
-
-
    }
-
-
-
- 51 -
-
- -
-
-

-            
-
-
- 52 -
-
- -
-
-
    pub fn run_action(&mut self, action: &'a Action) -> &mut Craft<'a> {
-
-
-
- 53 -
-
- -
-
-
        if !action.can_use(self) {
-
-
-
- 54 -
-
- -
-
-
            self.success = Success::Failure;
-
-
-
- 55 -
-
- -
-
-
            return self;
-
-
-
- 56 -
-
- -
-
-
        }
-
-
-
- 57 -
-
- -
-
-
        self.step_count += 1;
-
-
-
- 58 -
-
- -
-
-
        self.cp -= action.get_cp_cost(self) as i32;
-
-
-
- 59 -
-
- -
-
-
        self.durability -= action.get_durability_cost(self) as i32;
-
-
-
- 60 -
-
- -
-
-
        self.progression += (action.get_progress(self) as f64
-
-
-
- 61 -
-
- -
-
-
            * (self.get_base_progression() as f64 / 100.0))
-
-
-
- 62 -
-
- -
-
-
            .floor() as u32;
-
-
-
- 63 -
-
- -
-
-
        self.quality += (action.get_quality(self) as f64 * (self.get_base_quality() as f64 / 100.0))
-
-
-
- 64 -
-
- -
-
-
            .floor() as u32;
-
-
-
- 65 -
-
- -
-
-
        if self.progression >= self.recipe.progress {
-
-
-
- 66 -
-
- -
-
-
            self.success = Success::Success;
-
-
-
- 67 -
-
- -
-
-
        }
-
-
-
- 68 -
-
- -
-
-
        if self.durability <= 0 {
-
-
-
- 69 -
-
- -
-
-
            self.success = Success::Failure;
-
-
-
- 70 -
-
- -
-
-
        }
-
-
-
- 71 -
-
- -
-
-
        if self.buffs.manipulation > 0 {
-
-
-
- 72 -
-
- -
-
-
            self.durability += 5;
-
-
-
- 73 -
-
- -
-
-
        }
-
-
-
- 74 -
-
- -
-
-
        if action.quality > 0 {
-
-
-
- 75 -
-
- -
-
-
            self.buffs.inner_quiet += 1;
-
-
-
- 76 -
-
- -
-
-
        }
-
-
-
- 77 -
-
- -
-
-
        self.buffs.tick();
-
-
-
- 78 -
-
- -
-
-
        if action.progress > 0 {
-
-
-
- 79 -
-
- -
-
-
            self.buffs.remove(Buff::MuscleMemory);
-
-
-
- 80 -
-
- -
-
-
        }
-
-
-
- 81 -
-
- -
-
-
        if action.quality > 0 {
-
-
-
- 82 -
-
- -
-
-
            self.buffs.remove(Buff::GreatStrides);
-
-
-
- 83 -
-
- -
-
-
        }
-
-
-
- 84 -
-
- -
-
-
        if let Some((buff, duration)) = action.get_buff() {
-
-
-
- 85 -
-
- -
-
-
            self.buffs.apply(buff, duration);
-
-
-
- 86 -
-
- -
-
-
        }
-
-
-
- 87 -
-
- -
-
-
        if self.durability > self.recipe.durability as i32 {
-
-
-
- 88 -
-
- -
-
-
            self.durability = self.recipe.durability as i32;
-
-
-
- 89 -
-
- -
-
-
        }
-
-
-
- 90 -
-
- -
-
-
        if self.buffs.inner_quiet > 10 {
-
-
-
- 91 -
-
- -
-
-
            self.buffs.inner_quiet = 10;
-
-
-
- 92 -
-
- -
-
-
        }
-
-
-
- 93 -
-
- -
-
-

-            
-
-
- 94 -
-
- -
-
-
        self.actions.push(action);
-
-
-
- 95 -
-
- -
-
-
        return self;
-
-
-
- 96 -
-
- -
-
-
    }
-
-
-
- 97 -
-
- -
-
-

-            
-
-
- 98 -
-
- -
-
-
    // Assumes the craft is finished and tries to add the last actions
-
-
-
- 99 -
-
- -
-
-
    // pub fn add_last_actions(&mut self)->&Self{
-
-
-
- 100 -
-
- -
-
-
    //     let arg = (self.recipe.progress as f32 - self.progression as f32) / self.get_base_progression() as f32;
-
-
-
- 101 -
-
- -
-
-
    //     self.durability+=10;
-
-
-
- 102 -
-
- -
-
-
    //     if 0.0 < arg && arg < 1.2 { self.run_action(&ACTIONS.basic_synthesis);}
-
-
-
- 103 -
-
- -
-
-
    //     if 1.2 <= arg && arg < 1.8 { self.cp+=7; self.run_action(&ACTIONS.careful_synthesis); }
-
-
-
- 104 -
-
- -
-
-
    //     if 1.8 <= arg && arg < 2.0 {
-
-
-
- 105 -
-
- -
-
-
    //         self.cp+=12;
-
-
-
- 106 -
-
- -
-
-
    //         self.run_action(&ACTIONS.observe);
-
-
-
- 107 -
-
- -
-
-
    //         self.run_action(&ACTIONS.focused_synthesis);
-
-
-
- 108 -
-
- -
-
-
    //     }
-
-
-
- 109 -
-
- -
-
-
    //     self
-
-
-
- 110 -
-
- -
-
-
    // }
-
-
-
- 111 -
-
- -
-
-
}
-
-
-
- 112 -
-
- -
-
-

-            
-
-
- 113 -
-
- -
-
-
impl<'a> Debug for Craft<'a> {
-
-
-
- 114 -
-
- -
-
-
    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
-
-
-
- 115 -
-
- -
-
-
        let mut binding = f.debug_struct("");
-
-
-
- 116 -
-
- -
-
-
        binding
-
-
-
- 117 -
-
- -
-
-
            .field("step_count", &self.step_count)
-
-
-
- 118 -
-
- -
-
-
            .field("progression", &format!("{:?}/{:?}", &self.progression, &self.recipe.progress))
-
-
-
- 119 -
-
- -
-
-
            .field("quality", &format!("{:?}/{:?}", &self.quality, &self.recipe.quality))
-
-
-
- 120 -
-
- -
-
-
            .field("durability", &format!("{:?}/{:?}", &self.durability, &self.recipe.durability))
-
-
-
- 121 -
-
- -
-
-
            // .field("cp", &format!("{:?}/{:?}", &self.cp, &self.stats.max_cp))
-
-
-
- 122 -
-
- -
-
-
        ;
-
-
-
- 123 -
-
- -
-
-
        binding.field("actions", &self.actions);
-
-
-
- 124 -
-
- -
-
-
        binding.finish()
-
-
-
- 125 -
-
- -
-
-
    }
-
-
-
- 126 -
-
- -
-
-
}
-
-
-
- 127 -
-
- -
-
-

-            
-
-
- 128 -
-
- -
-
-
impl<'a> Display for Craft<'a> {
-
-
-
- 129 -
-
- -
-
-
    fn fmt(&self, f: &mut Formatter) -> std::fmt::Result {
-
-
-
- 130 -
-
- -
-
-
        f.debug_struct("Craft")
-
-
-
- 131 -
-
- -
-
-
            .field("step_count", &self.step_count)
-
-
-
- 132 -
-
- -
-
-
            .field(
-
-
-
- 133 -
-
- -
-
-
                "progression",
-
-
-
- 134 -
-
- -
-
-
                &format!("{:?}/{:?}", &self.progression, &self.recipe.progress),
-
-
-
- 135 -
-
- -
-
-
            )
-
-
-
- 136 -
-
- -
-
-
            .field(
-
-
-
- 137 -
-
- -
-
-
                "quality",
-
-
-
- 138 -
-
- -
-
-
                &format!("{:?}/{:?}", &self.quality, &self.recipe.quality),
-
-
-
- 139 -
-
- -
-
-
            )
-
-
-
- 140 -
-
- -
-
-
            .field(
-
-
-
- 141 -
-
- -
-
-
                "durability",
-
-
-
- 142 -
-
- -
-
-
                &format!("{:?}/{:?}", &self.durability, &self.recipe.durability),
-
-
-
- 143 -
-
- -
-
-
            )
-
-
-
- 144 -
-
- -
-
-
            .field("cp", &format!("{:?}/{:?}", &self.cp, &self.stats.max_cp))
-
-
-
- 145 -
-
- -
-
-
            .finish()
-
-
-
- 146 -
-
- -
-
-
    }
-
-
-
- 147 -
-
- -
-
-
}
-
-
-
-
-
-

Date: 2023-03-01 23:03

-
-
- - diff --git a/coverage/html/src/index.html b/coverage/html/src/index.html deleted file mode 100644 index e016d84..0000000 --- a/coverage/html/src/index.html +++ /dev/null @@ -1,201 +0,0 @@ - - - - - Grcov report - src - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FileLine CoverageFunctionsBranches
action.rs - - 0% - - - 0% - - 0 / 239 - 0%0 / 36 100%0 / 0
craft.rs - - 0% - - - 0% - - 0 / 102 - 0%0 / 14 100%0 / 0
io.rs - - 53.77% - - - 53.77% - - 114 / 212 - 13.4%28 / 209 100%0 / 0
lib.rs - - 0.43% - - - 0.43% - - 1 / 230 - 4.76%1 / 21 100%0 / 0
solver.rs - - 0% - - - 0% - - 0 / 203 - 0%0 / 12 100%0 / 0
specs.rs - - 0% - - - 0% - - 0 / 75 - 0%0 / 48 100%0 / 0
-
-
-

Date: 2023-03-01 23:03

-
-
- - diff --git a/coverage/html/src/io.rs.html b/coverage/html/src/io.rs.html deleted file mode 100644 index efb11ac..0000000 --- a/coverage/html/src/io.rs.html +++ /dev/null @@ -1,5328 +0,0 @@ - - - - - Grcov report - io.rs - - -
- - - -
-
- 1 -
-
- -
-
-
#[warn(missing_docs)]
-
-
-
- 2 -
-
- -
-
-

-            
-
-
- 3 -
-
- -
-
-
use crate::Craft;
-
-
-
- 4 -
-
- -
-
-
use clap::Parser;
-
-
-
- 5 -
-
- -
-
-
use core::fmt::Display;
-
-
-
- 6 -
-
- -
-
-

-            
-
-
- 7 -
-
- -
-
-
// #[cfg(not(feature = "no_python"))]
-
-
-
- 8 -
-
- -
-
-
use pyo3::prelude::*;
-
-
-
- 9 -
-
- -
-
-

-            
-
-
- 10 -
-
- 1 -
-
-
#[derive(Debug, Clone, Copy)]
-
-
-
- 11 -
-
- -
-
-
pub struct Parameters {
-
-
-
- 12 -
-
- -
-
-
    pub threads: usize,
-
-
-
- 13 -
-
- -
-
-
    pub verbose: u8,
-
-
-
- 14 -
-
- -
-
-
    pub depth: u32,
-
-
-
- 15 -
-
- -
-
-
    pub desperate: bool,
-
-
-
- 16 -
-
- -
-
-
    pub byregot_step: u8,
-
-
-
- 17 -
-
- -
-
-
}
-
-
-
- 18 -
-
- -
-
-

-            
-
-
- 19 -
-
- 8 -
-
-
#[derive(Parser, Debug, Clone)]
-
-
-
- 20 -
-
- -
-
-
#[command(author, version, about, long_about = None)]
-
-
-
- 21 -
-
- -
-
-
pub struct Args {
-
-
-
- 22 -
-
- -
-
-
    /// Name of the receipe
-
-
-
- 23 -
-
- 1 -
-
-
    #[arg(short, long, default_value_t = String::from("default_recipe"))]
-
-
-
- 24 -
-
- -
-
-
    pub recipe_name: String,
-
-
-
- 25 -
-
- -
-
-

-            
-
-
- 26 -
-
- -
-
-
    /// Name of the character
-
-
-
- 27 -
-
- 1 -
-
-
    #[arg(short, long, default_value_t = String::from("default_character"))]
-
-
-
- 28 -
-
- -
-
-
    pub character_name: String,
-
-
-
- 29 -
-
- -
-
-

-            
-
-
- 30 -
-
- -
-
-
    /// The ml file name
-
-
-
- 31 -
-
- 1 -
-
-
    #[arg(short, long, default_value_t = String::from("craft.toml"))]
-
-
-
- 32 -
-
- -
-
-
    pub file_name: String,
-
-
-
- 33 -
-
- -
-
-

-            
-
-
- 34 -
-
- -
-
-
    /// The verbose flag
-
-
-
- 35 -
-
- -
-
-
    #[arg(short, long, action = clap::ArgAction::Count)]
-
-
-
- 36 -
-
- -
-
-
    pub verbose: u8,
-
-
-
- 37 -
-
- -
-
-

-            
-
-
- 38 -
-
- -
-
-
    /// The depth of the first pass
-
-
-
- 39 -
-
- 1 -
-
-
    #[arg(short, long, default_value_t = 8)]
-
-
-
- 40 -
-
- -
-
-
    pub depth: u32,
-
-
-
- 41 -
-
- -
-
-

-            
-
-
- 42 -
-
- -
-
-
    /// Thread counts, default is 4
-
-
-
- 43 -
-
- 1 -
-
-
    #[arg(short, long, default_value_t = 4)]
-
-
-
- 44 -
-
- -
-
-
    pub threads: usize,
-
-
-
- 45 -
-
- -
-
-

-            
-
-
- 46 -
-
- -
-
-
    /// Desperate mode, will try to finish the craft above all
-
-
-
- 47 -
-
- 1 -
-
-
    #[arg(short = 'D', long, default_value_t = false)]
-
-
-
- 48 -
-
- -
-
-
    pub desperate: bool,
-
-
-
- 49 -
-
- -
-
-

-            
-
-
- 50 -
-
- -
-
-
    /// Long mode, will try to find more solutions, at the expense of time
-
-
-
- 51 -
-
- 1 -
-
-
    #[arg(short = 'l', long, default_value_t = false)]
-
-
-
- 52 -
-
- -
-
-
    pub long: bool,
-
-
-
- 53 -
-
- -
-
-
}
-
-
-
- 54 -
-
- -
-
-

-            
-
-
- 55 -
-
- -
-
-
/// A final stripped down version of a craft
-
-
-
- 56 -
-
- -
-
-
/// used for final print and talking with python
-
-
-
- 57 -
-
- 1 -
-
-
#[derive(Debug)]
-
-
-
- 58 -
-
- -
-
-
#[pyclass]
-
-
-
- 59 -
-
- -
-
-
pub struct SolverResult {
-
-
-
- 60 -
-
- -
-
-
    #[pyo3(get)]
-
-
-
- 61 -
-
- -
-
-
    pub steps: u32,
-
-
-
- 62 -
-
- -
-
-
    #[pyo3(get)]
-
-
-
- 63 -
-
- -
-
-
    pub quality: u32,
-
-
-
- 64 -
-
- -
-
-
    #[pyo3(get)]
-
-
-
- 65 -
-
- -
-
-
    pub progression: u32,
-
-
-
- 66 -
-
- -
-
-
    #[pyo3(get)]
-
-
-
- 67 -
-
- -
-
-
    pub durability: i32,
-
-
-
- 68 -
-
- -
-
-
    #[pyo3(get)]
-
-
-
- 69 -
-
- -
-
-
    pub cp: i32,
-
-
-
- 70 -
-
- -
-
-
    #[pyo3(get)]
-
-
-
- 71 -
-
- -
-
-
    pub total_cp: u32,
-
-
-
- 72 -
-
- -
-
-
    #[pyo3(get)]
-
-
-
- 73 -
-
- -
-
-
    pub total_progression: u32,
-
-
-
- 74 -
-
- -
-
-
    #[pyo3(get)]
-
-
-
- 75 -
-
- -
-
-
    pub total_quality: u32,
-
-
-
- 76 -
-
- -
-
-
    #[pyo3(get)]
-
-
-
- 77 -
-
- -
-
-
    pub total_durability: u32,
-
-
-
- 78 -
-
- -
-
-
    #[pyo3(get)]
-
-
-
- 79 -
-
- -
-
-
    pub actions: Vec<String>,
-
-
-
- 80 -
-
- -
-
-
    #[pyo3(get)]
-
-
-
- 81 -
-
- -
-
-
    pub step1_solutions: usize,
-
-
-
- 82 -
-
- -
-
-
    #[pyo3(get)]
-
-
-
- 83 -
-
- -
-
-
    pub step2_solutions: usize,
-
-
-
- 84 -
-
- -
-
-
    #[pyo3(get)]
-
-
-
- 85 -
-
- -
-
-
    pub found_100_percent: bool,
-
-
-
- 86 -
-
- -
-
-
}
-
-
-
- 87 -
-
- -
-
-

-            
-
-
- 88 -
-
- -
-
-
/// Pretty display for SolverResult
-
-
-
- 89 -
-
- -
-
-
impl Display for SolverResult {
-
-
-
- 90 -
-
- 2 -
-
-
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
-
-
-
- 91 -
-
- 2 -
-
-
        write!(f, "{:?}", self.actions)
-
-
-
- 92 -
-
- 2 -
-
-
    }
-
-
-
- 93 -
-
- -
-
-
}
-
-
-
- 94 -
-
- -
-
-

-            
-
-
- 95 -
-
- -
-
-
//#[pymethods]
-
-
-
- 96 -
-
- -
-
-
impl SolverResult {
-
-
-
- 97 -
-
- -
-
-
    pub fn from_craft(
-
-
-
- 98 -
-
- -
-
-
        craft: &Craft,
-
-
-
- 99 -
-
- -
-
-
        step1_solutions: usize,
-
-
-
- 100 -
-
- -
-
-
        step2_solutions: usize,
-
-
-
- 101 -
-
- -
-
-
        found_100_percent: bool,
-
-
-
- 102 -
-
- -
-
-
    ) -> SolverResult {
-
-
-
- 103 -
-
- -
-
-
        let mut actions = craft
-
-
-
- 104 -
-
- -
-
-
            .actions
-
-
-
- 105 -
-
- -
-
-
            .iter()
-
-
-
- 106 -
-
- -
-
-
            .map(|action| format!("{}", action.short_name))
-
-
-
- 107 -
-
- -
-
-
            .collect::<Vec<String>>();
-
-
-
- 108 -
-
- -
-
-
        let arg = (craft.recipe.progress as f32 - craft.progression as f32)
-
-
-
- 109 -
-
- -
-
-
            / craft.get_base_progression() as f32;
-
-
-
- 110 -
-
- -
-
-
        if 0.0 < arg && arg < 1.2 {
-
-
-
- 111 -
-
- -
-
-
            actions.push("basicSynth2".to_string());
-
-
-
- 112 -
-
- -
-
-
        }
-
-
-
- 113 -
-
- -
-
-
        if 1.2 <= arg && arg < 1.8 {
-
-
-
- 114 -
-
- -
-
-
            actions.push("carefulSynthesis".to_string());
-
-
-
- 115 -
-
- -
-
-
        }
-
-
-
- 116 -
-
- -
-
-
        if 1.8 <= arg && arg < 2.0 {
-
-
-
- 117 -
-
- -
-
-
            actions.push("observe".to_string());
-
-
-
- 118 -
-
- -
-
-
            actions.push("focusedSynthesis".to_string());
-
-
-
- 119 -
-
- -
-
-
        }
-
-
-
- 120 -
-
- -
-
-
        SolverResult {
-
-
-
- 121 -
-
- -
-
-
            steps: craft.step_count,
-
-
-
- 122 -
-
- -
-
-
            progression: craft.progression,
-
-
-
- 123 -
-
- -
-
-
            quality: craft.quality,
-
-
-
- 124 -
-
- -
-
-
            durability: craft.durability,
-
-
-
- 125 -
-
- -
-
-
            actions: actions,
-
-
-
- 126 -
-
- -
-
-
            step1_solutions,
-
-
-
- 127 -
-
- -
-
-
            step2_solutions,
-
-
-
- 128 -
-
- -
-
-
            found_100_percent,
-
-
-
- 129 -
-
- -
-
-
            total_progression: craft.recipe.progress,
-
-
-
- 130 -
-
- -
-
-
            total_quality: craft.recipe.quality,
-
-
-
- 131 -
-
- -
-
-
            total_durability: craft.recipe.durability,
-
-
-
- 132 -
-
- -
-
-
            cp: craft.cp,
-
-
-
- 133 -
-
- -
-
-
            total_cp: craft.stats.max_cp,
-
-
-
- 134 -
-
- -
-
-
        }
-
-
-
- 135 -
-
- -
-
-
    }
-
-
-
- 136 -
-
- -
-
-
}
-
-
-
- 137 -
-
- -
-
-

-            
-
-
- 138 -
-
- -
-
-
#[pymethods]
-
-
-
- 139 -
-
- -
-
-
impl SolverResult {
-
-
-
- 140 -
-
- -
-
-
    #[staticmethod]
-
-
-
- 141 -
-
- 2 -
-
-
    pub fn default() -> Self {
-
-
-
- 142 -
-
- 2 -
-
-
        Self {
-
-
-
- 143 -
-
- 2 -
-
-
            steps: 0,
-
-
-
- 144 -
-
- 2 -
-
-
            progression: 0,
-
-
-
- 145 -
-
- 2 -
-
-
            quality: 0,
-
-
-
- 146 -
-
- 2 -
-
-
            durability: 0,
-
-
-
- 147 -
-
- 2 -
-
-
            total_progression: 0,
-
-
-
- 148 -
-
- 2 -
-
-
            total_quality: 0,
-
-
-
- 149 -
-
- 2 -
-
-
            total_durability: 0,
-
-
-
- 150 -
-
- 2 -
-
-
            actions: vec!["Act1".to_string(), "Act2".to_string()],
-
-
-
- 151 -
-
- 2 -
-
-
            step1_solutions: 0,
-
-
-
- 152 -
-
- 2 -
-
-
            step2_solutions: 0,
-
-
-
- 153 -
-
- 2 -
-
-
            found_100_percent: false,
-
-
-
- 154 -
-
- 2 -
-
-
            cp: 0,
-
-
-
- 155 -
-
- 2 -
-
-
            total_cp: 0,
-
-
-
- 156 -
-
- 2 -
-
-
        }
-
-
-
- 157 -
-
- 2 -
-
-
    }
-
-
-
- 158 -
-
- -
-
-

-            
-
-
- 159 -
-
- 1 -
-
-
    pub fn pretty_print(&self) {
-
-
-
- 160 -
-
- 1 -
-
-
        println!(
-
-
-
- 161 -
-
- 1 -
-
-
            "Quality: [{}/{}] | Durability: [{}/{}] | Cp : [{}/{}] | Steps : {}",
-
-
-
- 162 -
-
- 1 -
-
-
            self.quality,
-
-
-
- 163 -
-
- 1 -
-
-
            self.total_quality,
-
-
-
- 164 -
-
- 1 -
-
-
            self.durability,
-
-
-
- 165 -
-
- 1 -
-
-
            self.total_durability,
-
-
-
- 166 -
-
- 1 -
-
-
            self.cp,
-
-
-
- 167 -
-
- 1 -
-
-
            self.total_cp,
-
-
-
- 168 -
-
- 1 -
-
-
            self.steps
-
-
-
- 169 -
-
- 1 -
-
-
        );
-
-
-
- 170 -
-
- 1 -
-
-
        println!("{:?}", self.actions);
-
-
-
- 171 -
-
- 1 -
-
-
    }
-
-
-
- 172 -
-
- -
-
-
}
-
-
-
- 173 -
-
- -
-
-

-            
-
-
- 174 -
-
- -
-
-
impl Parameters {
-
-
-
- 175 -
-
- -
-
-
    pub fn from_args(args: &Args) -> Self {
-
-
-
- 176 -
-
- -
-
-
        Self {
-
-
-
- 177 -
-
- -
-
-
            depth: if args.desperate { 11 } else { 8 },
-
-
-
- 178 -
-
- -
-
-
            threads: args.threads,
-
-
-
- 179 -
-
- -
-
-
            verbose: args.verbose,
-
-
-
- 180 -
-
- -
-
-
            desperate: args.desperate,
-
-
-
- 181 -
-
- -
-
-
            byregot_step: if args.long { 6 } else { 8 },
-
-
-
- 182 -
-
- -
-
-
        }
-
-
-
- 183 -
-
- -
-
-
    }
-
-
-
- 184 -
-
- -
-
-
}
-
-
-
- 185 -
-
- -
-
-

-            
-
-
- 186 -
-
- -
-
-
////// Python Bindings //////
-
-
-
- 187 -
-
- -
-
-

-            
-
-
- 188 -
-
- -
-
-
/// A Python module implemented in Rust.
-
-
-
- 189 -
-
- -
-
-
#[cfg(not(feature = "no_python"))]
-
-
-
- 190 -
-
- -
-
-
#[pymodule]
-
-
-
- 191 -
-
- -
-
-
fn xiv_csolver_lib(_py: Python, m: &PyModule) -> PyResult<()> {
-
-
-
- 192 -
-
- -
-
-
    m.add_function(wrap_pyfunction!(test_result, m)?)?;
-
-
-
- 193 -
-
- -
-
-
    m.add_function(wrap_pyfunction!(solve_from_python, m)?)?;
-
-
-
- 194 -
-
- -
-
-
    Ok(())
-
-
-
- 195 -
-
- -
-
-
}
-
-
-
- 196 -
-
- -
-
-

-            
-
-
- 197 -
-
- -
-
-
///
-
-
-
- 198 -
-
- -
-
-
#[cfg(not(feature = "no_python"))]
-
-
-
- 199 -
-
- -
-
-
#[pyfunction]
-
-
-
- 200 -
-
- -
-
-
pub fn test_result() -> SolverResult {
-
-
-
- 201 -
-
- -
-
-
    SolverResult::default()
-
-
-
- 202 -
-
- -
-
-
}
-
-
-
- 203 -
-
- -
-
-

-            
-
-
- 204 -
-
- -
-
-
/// Create a stat struct stats with the base values
-
-
-
- 205 -
-
- -
-
-
#[cfg(not(feature = "no_python"))]
-
-
-
- 206 -
-
- -
-
-
use crate::{solve_craft, Recipe, Stats};
-
-
-
- 207 -
-
- -
-
-

-            
-
-
- 208 -
-
- -
-
-
#[cfg(not(feature = "no_python"))]
-
-
-
- 209 -
-
- -
-
-
#[pyfunction]
-
-
-
- 210 -
-
- -
-
-
pub fn solve_from_python(values: &PyAny) -> PyResult<Option<Vec<SolverResult>>> {
-
-
-
- 211 -
-
- -
-
-
    // // Create Recipe
-
-
-
- 212 -
-
- -
-
-
    let recipe = Recipe {
-
-
-
- 213 -
-
- -
-
-
        durability: values.getattr("durability")?.extract()?,
-
-
-
- 214 -
-
- -
-
-
        progress: values.getattr("progress")?.extract()?,
-
-
-
- 215 -
-
- -
-
-
        progress_divider: values.getattr("progress_divider")?.extract()?,
-
-
-
- 216 -
-
- -
-
-
        progress_modifier: values.getattr("progress_modifier")?.extract()?,
-
-
-
- 217 -
-
- -
-
-
        quality: values.getattr("quality")?.extract()?,
-
-
-
- 218 -
-
- -
-
-
        quality_divider: values.getattr("quality_divider")?.extract()?,
-
-
-
- 219 -
-
- -
-
-
        quality_modifier: values.getattr("quality_modifier")?.extract()?,
-
-
-
- 220 -
-
- -
-
-
    };
-
-
-
- 221 -
-
- -
-
-

-            
-
-
- 222 -
-
- -
-
-
    // Create Stats
-
-
-
- 223 -
-
- -
-
-
    let stats = Stats {
-
-
-
- 224 -
-
- -
-
-
        craftsmanship: values.getattr("craftsmanship")?.extract()?,
-
-
-
- 225 -
-
- -
-
-
        control: values.getattr("control")?.extract()?,
-
-
-
- 226 -
-
- -
-
-
        max_cp: values.getattr("max_cp")?.extract()?,
-
-
-
- 227 -
-
- -
-
-
    };
-
-
-
- 228 -
-
- -
-
-

-            
-
-
- 229 -
-
- -
-
-
    // Create parameters
-
-
-
- 230 -
-
- -
-
-
    let param = Parameters {
-
-
-
- 231 -
-
- -
-
-
        depth: values.getattr("depth")?.extract()?,
-
-
-
- 232 -
-
- -
-
-
        byregot_step: values.getattr("byregot_step")?.extract()?,
-
-
-
- 233 -
-
- -
-
-
        desperate: values.getattr("desperate")?.extract()?,
-
-
-
- 234 -
-
- -
-
-
        threads: values.getattr("threads")?.extract()?,
-
-
-
- 235 -
-
- -
-
-
        verbose: values.getattr("verbose")?.extract()?,
-
-
-
- 236 -
-
- -
-
-
    };
-
-
-
- 237 -
-
- -
-
-

-            
-
-
- 238 -
-
- -
-
-
    // println!("{:?} len: {:?} ",values,values.getattr("len()"));
-
-
-
- 239 -
-
- -
-
-
    let res = solve_craft(recipe, stats, param);
-
-
-
- 240 -
-
- -
-
-
    Ok(res)
-
-
-
- 241 -
-
- -
-
-
}
-
-
-
- 242 -
-
- -
-
-

-            
-
-
- 243 -
-
- -
-
-
#[cfg(test)]
-
-
-
- 244 -
-
- -
-
-
mod tests {
-
-
-
- 245 -
-
- -
-
-
    use crate::io::Args;
-
-
-
- 246 -
-
- -
-
-
    use crate::{Parameters, SolverResult};
-
-
-
- 247 -
-
- -
-
-
    use pretty_assertions::{assert_eq, assert_ne};
-
-
-
- 248 -
-
- -
-
-
    use clap::Parser;
-
-
-
- 249 -
-
- -
-
-

-            
-
-
- 250 -
-
- -
-
-
    impl PartialEq for Parameters {
-
-
-
- 251 -
-
- 1 -
-
-
        fn eq(&self, rhs: &Parameters) -> bool {
-
-
-
- 252 -
-
- 1 -
-
-
            (self.byregot_step == rhs.byregot_step)
-
-
-
- 253 -
-
- 1 -
-
-
                & (self.depth == rhs.depth)
-
-
-
- 254 -
-
- 1 -
-
-
                & (self.desperate == rhs.desperate)
-
-
-
- 255 -
-
- 1 -
-
-
                & (self.threads == rhs.threads)
-
-
-
- 256 -
-
- 1 -
-
-
        }
-
-
-
- 257 -
-
- -
-
-
    }
-
-
-
- 258 -
-
- -
-
-

-            
-
-
- 259 -
-
- 1 -
-
-
    #[test]
-
-
-
- 260 -
-
- 1 -
-
-
    pub fn test_parameters_derived_attributes() {
-
-
-
- 261 -
-
- 1 -
-
-
        let def = Parameters {
-
-
-
- 262 -
-
- 1 -
-
-
            byregot_step: 0,
-
-
-
- 263 -
-
- 1 -
-
-
            depth: 0,
-
-
-
- 264 -
-
- 1 -
-
-
            desperate: false,
-
-
-
- 265 -
-
- 1 -
-
-
            threads: 42,
-
-
-
- 266 -
-
- 1 -
-
-
            verbose: 1,
-
-
-
- 267 -
-
- 1 -
-
-
        };
-
-
-
- 268 -
-
- 1 -
-
-
        let def2 = def;
-
-
-
- 269 -
-
- 1 -
-
-
        let def3 = def2.clone();
-
-
-
- 270 -
-
- 1 -
-
-

-            
-
-
- 271 -
-
- 1 -
-
-
        assert_eq!(def2, def3);
-
-
-
- 272 -
-
- 1 -
-
-
    }
-
-
-
- 273 -
-
- -
-
-

-            
-
-
- 274 -
-
- 1 -
-
-
    #[test]
-
-
-
- 275 -
-
- 1 -
-
-
    pub fn test_display() {
-
-
-
- 276 -
-
- 1 -
-
-
        let def = SolverResult::default();
-
-
-
- 277 -
-
- 1 -
-
-
        assert_ne!(def.to_string(), "");
-
-
-
- 278 -
-
- 1 -
-
-
        assert_eq!(def.to_string(), "[\"Act1\", \"Act2\"]");
-
-
-
- 279 -
-
- 1 -
-
-
        def.pretty_print();
-
-
-
- 280 -
-
- 1 -
-
-
    }
-
-
-
- 281 -
-
- -
-
-

-            
-
-
- 282 -
-
- 1 -
-
-
    #[test]
-
-
-
- 283 -
-
- 1 -
-
-
    pub fn test_debug() {
-
-
-
- 284 -
-
- 1 -
-
-
        let def = SolverResult::default();
-
-
-
- 285 -
-
- 1 -
-
-
        assert_eq!(format!("{:?}", def),"SolverResult { steps: 0, quality: 0, progression: 0, durability: 0, cp: 0, total_cp: 0, total_progression: 0, total_quality: 0, total_durability: 0, actions: [\"Act1\", \"Act2\"], step1_solutions: 0, step2_solutions: 0, found_100_percent: false }");
-
-
-
- 286 -
-
- 1 -
-
-
    }
-
-
-
- 287 -
-
- -
-
-

-            
-
-
- 288 -
-
- 1 -
-
-
    #[test]
-
-
-
- 289 -
-
- 1 -
-
-
    pub fn test_arguments() {
-
-
-
- 290 -
-
- 1 -
-
-
        // Create false argument parameter
-
-
-
- 291 -
-
- 1 -
-
-
        let a = Args {
-
-
-
- 292 -
-
- 1 -
-
-
            character_name: "Bob GZ".to_string(),
-
-
-
- 293 -
-
- 1 -
-
-
            depth: 77,
-
-
-
- 294 -
-
- 1 -
-
-
            desperate: false,
-
-
-
- 295 -
-
- 1 -
-
-
            file_name: "test.toml".to_string(),
-
-
-
- 296 -
-
- 1 -
-
-
            long: false,
-
-
-
- 297 -
-
- 1 -
-
-
            recipe_name: "Belladone".to_string(),
-
-
-
- 298 -
-
- 1 -
-
-
            threads: 11,
-
-
-
- 299 -
-
- 1 -
-
-
            verbose: 1,
-
-
-
- 300 -
-
- 1 -
-
-
        };
-
-
-
- 301 -
-
- 1 -
-
-
        let a2 = a.clone();
-
-
-
- 302 -
-
- 1 -
-
-
        println!("{:?}",a2);
-
-
-
- 303 -
-
- 1 -
-
-
        // Test Custom recipe
-
-
-
- 304 -
-
- 1 -
-
-
        let a3 = Args::parse_from(["ultraman","-r", "recipe","-c","dan","-f","bigfile.toml","-d","45","-t","4","-D","-l","-vvv"]);
-
-
-
- 305 -
-
- 1 -
-
-
        let _ = Args::parse_from(["-V"]);
-
-
-
- 306 -
-
- 1 -
-
-
        let _ = Args::parse_from(["-H"]);
-
-
-
- 307 -
-
- 1 -
-
-
        assert_eq!(a3.recipe_name,"recipe");
-
-
-
- 308 -
-
- 1 -
-
-
        assert_eq!(a3.character_name,"dan");
-
-
-
- 309 -
-
- 1 -
-
-
        assert_eq!(a3.file_name,"bigfile.toml");
-
-
-
- 310 -
-
- 1 -
-
-
        assert_eq!(a3.verbose,3);
-
-
-
- 311 -
-
- 1 -
-
-
        assert_eq!(a3.depth,45);
-
-
-
- 312 -
-
- 1 -
-
-
        assert_eq!(a3.threads,4);
-
-
-
- 313 -
-
- 1 -
-
-
        assert_eq!(a3.desperate,true);
-
-
-
- 314 -
-
- 1 -
-
-
        assert_eq!(a3.long,true);
-
-
-
- 315 -
-
- -
-
-

-            
-
-
- 316 -
-
- -
-
-
        // Test default parameters
-
-
-
- 317 -
-
- 1 -
-
-
        let a4 = Args::parse_from(["bobGZ"]); 
-
-
-
- 318 -
-
- 1 -
-
-
        assert_eq!(a4.recipe_name,"default_recipe");
-
-
-
- 319 -
-
- 1 -
-
-
        assert_eq!(a4.character_name,"default_character");
-
-
-
- 320 -
-
- 1 -
-
-
        assert_eq!(a4.file_name,"craft.toml");
-
-
-
- 321 -
-
- 1 -
-
-
        assert_eq!(a4.verbose,0);
-
-
-
- 322 -
-
- 1 -
-
-
        assert_eq!(a4.depth,8);
-
-
-
- 323 -
-
- 1 -
-
-
        assert_eq!(a4.threads,4);
-
-
-
- 324 -
-
- 1 -
-
-
        assert_eq!(a4.desperate,false);
-
-
-
- 325 -
-
- 1 -
-
-
        assert_eq!(a4.long,false);
-
-
-
- 326 -
-
- 1 -
-
-
    }
-
-
-
- 327 -
-
- -
-
-

-            
-
-
- 328 -
-
- 1 -
-
-
    #[test]
-
-
-
- 329 -
-
- 1 -
-
-
    pub fn test_parameters() {}
-
-
-
- 330 -
-
- -
-
-
}
-
-
-
-
-
-

Date: 2023-03-01 23:03

-
-
- - diff --git a/coverage/html/src/lib.rs.html b/coverage/html/src/lib.rs.html deleted file mode 100644 index 7d6d9fb..0000000 --- a/coverage/html/src/lib.rs.html +++ /dev/null @@ -1,4496 +0,0 @@ - - - - - Grcov report - lib.rs - - -
- - - -
-
- 1 -
-
- 1 -
-
-
use crate::io::SolverResult;
-
-
-
- 2 -
-
- -
-
-
use crate::{
-
-
-
- 3 -
-
- -
-
-
    craft::Craft,
-
-
-
- 4 -
-
- -
-
-
    io::Parameters,
-
-
-
- 5 -
-
- -
-
-
    specs::{Recipe, Stats},
-
-
-
- 6 -
-
- -
-
-
};
-
-
-
- 7 -
-
- -
-
-
use std::sync::{Arc, Mutex};
-
-
-
- 8 -
-
- -
-
-
use threadpool::ThreadPool;
-
-
-
- 9 -
-
- -
-
-

-            
-
-
- 10 -
-
- -
-
-
pub mod action;
-
-
-
- 11 -
-
- -
-
-
pub mod craft;
-
-
-
- 12 -
-
- -
-
-
pub mod io;
-
-
-
- 13 -
-
- -
-
-
mod solver;
-
-
-
- 14 -
-
- -
-
-
mod specs;
-
-
-
- 15 -
-
- -
-
-

-            
-
-
- 16 -
-
- -
-
-
/// Solve the craft with given arguments, this functions calls threads and must own it's values
-
-
-
- 17 -
-
- -
-
-
pub fn solve_craft<'a>(
-
-
-
- 18 -
-
- -
-
-
    recipe: Recipe,
-
-
-
- 19 -
-
- -
-
-
    stats: Stats,
-
-
-
- 20 -
-
- -
-
-
    params: Parameters,
-
-
-
- 21 -
-
- -
-
-
) -> Option<Vec<SolverResult>> {
-
-
-
- 22 -
-
- -
-
-
    // Load the craft with given arguments
-
-
-
- 23 -
-
- -
-
-
    let craft = Craft::new(recipe, stats, params);
-
-
-
- 24 -
-
- -
-
-

-            
-
-
- 25 -
-
- -
-
-
    // Start a threadpool
-
-
-
- 26 -
-
- -
-
-
    let pool = ThreadPool::new(params.threads);
-
-
-
- 27 -
-
- -
-
-

-            
-
-
- 28 -
-
- -
-
-
    #[cfg(feature = "verbose")]
-
-
-
- 29 -
-
- -
-
-
    if params.verbose > 0 {
-
-
-
- 30 -
-
- -
-
-
        println!("[P1] Starting phase 1...");
-
-
-
- 31 -
-
- -
-
-
    }
-
-
-
- 32 -
-
- -
-
-

-            
-
-
- 33 -
-
- -
-
-
    let phase1_routes = solver::generate_routes_phase1(craft);
-
-
-
- 34 -
-
- -
-
-
    let nb_p1 = phase1_routes.len();
-
-
-
- 35 -
-
- -
-
-

-            
-
-
- 36 -
-
- -
-
-
    #[cfg(feature = "verbose")]
-
-
-
- 37 -
-
- -
-
-
    if params.verbose > 0 {
-
-
-
- 38 -
-
- -
-
-
        println!(
-
-
-
- 39 -
-
- -
-
-
            "[P1] Found {} routes, testing them all...",
-
-
-
- 40 -
-
- -
-
-
            phase1_routes.len()
-
-
-
- 41 -
-
- -
-
-
        );
-
-
-
- 42 -
-
- -
-
-
        if params.verbose > 1 {
-
-
-
- 43 -
-
- -
-
-
            for r in &phase1_routes {
-
-
-
- 44 -
-
- -
-
-
                println!(
-
-
-
- 45 -
-
- -
-
-
                    "[P1] {:?} p:{}% q:{}% c:{} d:{}",
-
-
-
- 46 -
-
- -
-
-
                    r.actions,
-
-
-
- 47 -
-
- -
-
-
                    r.progression,
-
-
-
- 48 -
-
- -
-
-
                    r.quality * 100 / r.recipe.quality,
-
-
-
- 49 -
-
- -
-
-
                    r.cp,
-
-
-
- 50 -
-
- -
-
-
                    r.durability
-
-
-
- 51 -
-
- -
-
-
                );
-
-
-
- 52 -
-
- -
-
-
            }
-
-
-
- 53 -
-
- -
-
-
        }
-
-
-
- 54 -
-
- -
-
-
    }
-
-
-
- 55 -
-
- -
-
-

-            
-
-
- 56 -
-
- -
-
-
    // Core algorithm, fill all found routes with the best route (doesn't branch, just replace)
-
-
-
- 57 -
-
- -
-
-
    let arc_phase2_routes = Arc::new(Mutex::new(Vec::<Craft>::new()));
-
-
-
- 58 -
-
- -
-
-

-            
-
-
- 59 -
-
- -
-
-
    for route in phase1_routes {
-
-
-
- 60 -
-
- -
-
-
        let _phase2_routes = Arc::clone(&arc_phase2_routes);
-
-
-
- 61 -
-
- -
-
-

-            
-
-
- 62 -
-
- -
-
-
        pool.execute(move || {
-
-
-
- 63 -
-
- -
-
-
            if let Some(mut _route) = solver::generate_routes_phase2(route) {
-
-
-
- 64 -
-
- -
-
-
                let mut shared = _phase2_routes.lock().unwrap();
-
-
-
- 65 -
-
- -
-
-
                shared.append(&mut _route);
-
-
-
- 66 -
-
- -
-
-
            };
-
-
-
- 67 -
-
- -
-
-
        });
-
-
-
- 68 -
-
- -
-
-
    }
-
-
-
- 69 -
-
- -
-
-

-            
-
-
- 70 -
-
- -
-
-
    pool.join();
-
-
-
- 71 -
-
- -
-
-
    let phase2_routes = arc_phase2_routes.lock().unwrap();
-
-
-
- 72 -
-
- -
-
-
    let nb_p2 = phase2_routes.len();
-
-
-
- 73 -
-
- -
-
-

-            
-
-
- 74 -
-
- -
-
-
    // Drop on empty results
-
-
-
- 75 -
-
- -
-
-
    if phase2_routes.len() == 0 {
-
-
-
- 76 -
-
- -
-
-
        return None;
-
-
-
- 77 -
-
- -
-
-
    }
-
-
-
- 78 -
-
- -
-
-

-            
-
-
- 79 -
-
- -
-
-
    // Print the results if verbose
-
-
-
- 80 -
-
- -
-
-
    #[cfg(feature = "verbose")]
-
-
-
- 81 -
-
- -
-
-
    if params.verbose > 0 {
-
-
-
- 82 -
-
- -
-
-
        println!("[P2] Found {} solutions, sorting", phase2_routes.len());
-
-
-
- 83 -
-
- -
-
-
        if params.verbose > 1 {
-
-
-
- 84 -
-
- -
-
-
            for r in phase2_routes.iter() {
-
-
-
- 85 -
-
- -
-
-
                println!(
-
-
-
- 86 -
-
- -
-
-
                    "[P2] {:?} p:{}% q:{}% d:{}",
-
-
-
- 87 -
-
- -
-
-
                    r.actions,
-
-
-
- 88 -
-
- -
-
-
                    r.progression * 100 / r.recipe.progress,
-
-
-
- 89 -
-
- -
-
-
                    r.quality * 100 / r.recipe.quality,
-
-
-
- 90 -
-
- -
-
-
                    r.durability
-
-
-
- 91 -
-
- -
-
-
                );
-
-
-
- 92 -
-
- -
-
-
            }
-
-
-
- 93 -
-
- -
-
-
        }
-
-
-
- 94 -
-
- -
-
-
    }
-
-
-
- 95 -
-
- -
-
-

-            
-
-
- 96 -
-
- -
-
-
    // Prune the results for analysis
-
-
-
- 97 -
-
- -
-
-
    // let mut valid_routes : Vec<Craft> = vec![];
-
-
-
- 98 -
-
- -
-
-
    let mut valid_solutions: Vec<SolverResult> = vec![];
-
-
-
- 99 -
-
- -
-
-
    for route in phase2_routes.iter() {
-
-
-
- 100 -
-
- -
-
-
        if route.quality >= route.recipe.quality {
-
-
-
- 101 -
-
- -
-
-
            // valid_routes.push(route.clone());
-
-
-
- 102 -
-
- -
-
-
            valid_solutions.push(SolverResult::from_craft(route, nb_p1, nb_p2, true));
-
-
-
- 103 -
-
- -
-
-
        }
-
-
-
- 104 -
-
- -
-
-
    }
-
-
-
- 105 -
-
- -
-
-
    // If no craft can make it to 100% HQ, fallback to base results
-
-
-
- 106 -
-
- -
-
-
    if valid_solutions.len() == 0 {
-
-
-
- 107 -
-
- -
-
-
        for route in phase2_routes.iter() {
-
-
-
- 108 -
-
- -
-
-
            valid_solutions.push(SolverResult::from_craft(route, nb_p1, nb_p2, false));
-
-
-
- 109 -
-
- -
-
-
        }
-
-
-
- 110 -
-
- -
-
-
    }
-
-
-
- 111 -
-
- -
-
-

-            
-
-
- 112 -
-
- -
-
-
    Some(valid_solutions)
-
-
-
- 113 -
-
- -
-
-
}
-
-
-
- 114 -
-
- -
-
-

-            
-
-
- 115 -
-
- -
-
-
/// Load the config from args and make a craft from it
-
-
-
- 116 -
-
- -
-
-
pub fn load_from_config<'a>(
-
-
-
- 117 -
-
- -
-
-
    recipe_name: &str,
-
-
-
- 118 -
-
- -
-
-
    file_name: &str,
-
-
-
- 119 -
-
- -
-
-
    character_name: &str,
-
-
-
- 120 -
-
- -
-
-
) -> (Recipe, Stats) {
-
-
-
- 121 -
-
- -
-
-
    //read craft.toml
-
-
-
- 122 -
-
- -
-
-
    let config: toml::Value = toml::from_str(
-
-
-
- 123 -
-
- -
-
-
        &std::fs::read_to_string(file_name).expect(&format!("Can't open {}", file_name)),
-
-
-
- 124 -
-
- -
-
-
    )
-
-
-
- 125 -
-
- -
-
-
    .unwrap();
-
-
-
- 126 -
-
- -
-
-

-            
-
-
- 127 -
-
- -
-
-
    let recp = match config.get(recipe_name) {
-
-
-
- 128 -
-
- -
-
-
        Some(r) => r,
-
-
-
- 129 -
-
- -
-
-
        None => panic!("Can't find value '{}' in '{}'", recipe_name, file_name),
-
-
-
- 130 -
-
- -
-
-
    };
-
-
-
- 131 -
-
- -
-
-

-            
-
-
- 132 -
-
- -
-
-
    // Load receipe values
-
-
-
- 133 -
-
- -
-
-
    let recipe = Recipe {
-
-
-
- 134 -
-
- -
-
-
        durability: recp
-
-
-
- 135 -
-
- -
-
-
            .get("durability")
-
-
-
- 136 -
-
- -
-
-
            .expect(&format!(
-
-
-
- 137 -
-
- -
-
-
                "Can't find 'durability' in recipe '{}' on file '{}'",
-
-
-
- 138 -
-
- -
-
-
                recipe_name, file_name
-
-
-
- 139 -
-
- -
-
-
            ))
-
-
-
- 140 -
-
- -
-
-
            .as_integer()
-
-
-
- 141 -
-
- -
-
-
            .expect("Can't convert durability as an integer") as u32,
-
-
-
- 142 -
-
- -
-
-
        progress: recp
-
-
-
- 143 -
-
- -
-
-
            .get("progress")
-
-
-
- 144 -
-
- -
-
-
            .expect(&format!(
-
-
-
- 145 -
-
- -
-
-
                "Can't find 'progress' in recipe '{}' on '{}'",
-
-
-
- 146 -
-
- -
-
-
                recipe_name, file_name
-
-
-
- 147 -
-
- -
-
-
            ))
-
-
-
- 148 -
-
- -
-
-
            .as_integer()
-
-
-
- 149 -
-
- -
-
-
            .expect("Can't convert progress as an integer") as u32,
-
-
-
- 150 -
-
- -
-
-
        quality: recp
-
-
-
- 151 -
-
- -
-
-
            .get("quality")
-
-
-
- 152 -
-
- -
-
-
            .expect(&format!(
-
-
-
- 153 -
-
- -
-
-
                "Can't find 'quality' in recipe '{}' on '{}'",
-
-
-
- 154 -
-
- -
-
-
                recipe_name, file_name
-
-
-
- 155 -
-
- -
-
-
            ))
-
-
-
- 156 -
-
- -
-
-
            .as_integer()
-
-
-
- 157 -
-
- -
-
-
            .expect("Can't convert quality as an integer") as u32,
-
-
-
- 158 -
-
- -
-
-
        progress_divider: recp
-
-
-
- 159 -
-
- -
-
-
            .get("progress_divider")
-
-
-
- 160 -
-
- -
-
-
            .expect(&format!(
-
-
-
- 161 -
-
- -
-
-
                "Can't find 'progress_divider' in recipe '{}' on '{}'",
-
-
-
- 162 -
-
- -
-
-
                recipe_name, file_name
-
-
-
- 163 -
-
- -
-
-
            ))
-
-
-
- 164 -
-
- -
-
-
            .as_integer()
-
-
-
- 165 -
-
- -
-
-
            .expect("Can't convert progress_divider as an integer")
-
-
-
- 166 -
-
- -
-
-
            as u32,
-
-
-
- 167 -
-
- -
-
-
        quality_divider: recp
-
-
-
- 168 -
-
- -
-
-
            .get("quality_divider")
-
-
-
- 169 -
-
- -
-
-
            .expect(&format!(
-
-
-
- 170 -
-
- -
-
-
                "Can't find 'quality_divider' in recipe '{}' on '{}'",
-
-
-
- 171 -
-
- -
-
-
                recipe_name, file_name
-
-
-
- 172 -
-
- -
-
-
            ))
-
-
-
- 173 -
-
- -
-
-
            .as_integer()
-
-
-
- 174 -
-
- -
-
-
            .expect("Can't convert quality_divider as an integer") as u32,
-
-
-
- 175 -
-
- -
-
-
        progress_modifier: recp
-
-
-
- 176 -
-
- -
-
-
            .get("progress_modifier")
-
-
-
- 177 -
-
- -
-
-
            .expect(&format!(
-
-
-
- 178 -
-
- -
-
-
                "Can't find 'progress_modifier' in recipe '{}' on '{}'",
-
-
-
- 179 -
-
- -
-
-
                recipe_name, file_name
-
-
-
- 180 -
-
- -
-
-
            ))
-
-
-
- 181 -
-
- -
-
-
            .as_integer()
-
-
-
- 182 -
-
- -
-
-
            .expect("Can't convert progress_modifier as an integer")
-
-
-
- 183 -
-
- -
-
-
            as u32,
-
-
-
- 184 -
-
- -
-
-
        quality_modifier: recp
-
-
-
- 185 -
-
- -
-
-
            .get("quality_modifier")
-
-
-
- 186 -
-
- -
-
-
            .expect(&format!(
-
-
-
- 187 -
-
- -
-
-
                "Can't find 'quality_modifier' in recipe '{}' on '{}'",
-
-
-
- 188 -
-
- -
-
-
                recipe_name, file_name
-
-
-
- 189 -
-
- -
-
-
            ))
-
-
-
- 190 -
-
- -
-
-
            .as_integer()
-
-
-
- 191 -
-
- -
-
-
            .expect("Can't convert quality_modifier as an integer")
-
-
-
- 192 -
-
- -
-
-
            as u32,
-
-
-
- 193 -
-
- -
-
-
    };
-
-
-
- 194 -
-
- -
-
-

-            
-
-
- 195 -
-
- -
-
-
    let cfg = match config.get(character_name) {
-
-
-
- 196 -
-
- -
-
-
        Some(c) => c,
-
-
-
- 197 -
-
- -
-
-
        None => panic!("Can't find '{}' in file '{}'", character_name, file_name),
-
-
-
- 198 -
-
- -
-
-
    };
-
-
-
- 199 -
-
- -
-
-
    let stats = Stats {
-
-
-
- 200 -
-
- -
-
-
        craftsmanship: cfg
-
-
-
- 201 -
-
- -
-
-
            .get("craftsmanship")
-
-
-
- 202 -
-
- -
-
-
            .expect(&format!(
-
-
-
- 203 -
-
- -
-
-
                "Can't find 'craftsmanship' in character '{}' on file '{}'",
-
-
-
- 204 -
-
- -
-
-
                character_name, file_name
-
-
-
- 205 -
-
- -
-
-
            ))
-
-
-
- 206 -
-
- -
-
-
            .as_integer()
-
-
-
- 207 -
-
- -
-
-
            .expect("Can't convert craftsmanship as an integer") as u32,
-
-
-
- 208 -
-
- -
-
-
        control: cfg
-
-
-
- 209 -
-
- -
-
-
            .get("control")
-
-
-
- 210 -
-
- -
-
-
            .expect(&format!(
-
-
-
- 211 -
-
- -
-
-
                "Can't find 'control' in character '{}' on file '{}'",
-
-
-
- 212 -
-
- -
-
-
                character_name, file_name
-
-
-
- 213 -
-
- -
-
-
            ))
-
-
-
- 214 -
-
- -
-
-
            .as_integer()
-
-
-
- 215 -
-
- -
-
-
            .expect("Can't convert control as an integer") as u32,
-
-
-
- 216 -
-
- -
-
-
        max_cp: cfg
-
-
-
- 217 -
-
- -
-
-
            .get("max_cp")
-
-
-
- 218 -
-
- -
-
-
            .expect(&format!(
-
-
-
- 219 -
-
- -
-
-
                "Can't find 'max_cp' in character '{}' on file '{}'",
-
-
-
- 220 -
-
- -
-
-
                character_name, file_name
-
-
-
- 221 -
-
- -
-
-
            ))
-
-
-
- 222 -
-
- -
-
-
            .as_integer()
-
-
-
- 223 -
-
- -
-
-
            .expect("Can't convert max_cp as an integer") as u32,
-
-
-
- 224 -
-
- -
-
-
    };
-
-
-
- 225 -
-
- -
-
-
    (recipe, stats)
-
-
-
- 226 -
-
- -
-
-
}
-
-
-
- 227 -
-
- -
-
-

-            
-
-
- 228 -
-
- -
-
-
/// Print all routes in the vect, verbose
-
-
-
- 229 -
-
- -
-
-
pub fn print_routes<'a>(routes: &Option<Vec<SolverResult>>) {
-
-
-
- 230 -
-
- -
-
-
    match routes {
-
-
-
- 231 -
-
- -
-
-
        Some(r) => {
-
-
-
- 232 -
-
- -
-
-
            println!("Showing {} routes", r.len());
-
-
-
- 233 -
-
- -
-
-
            for c in r.iter() {
-
-
-
- 234 -
-
- -
-
-
                println!(
-
-
-
- 235 -
-
- -
-
-
                    "\n[{}¤][{}@][{}#] {:?} ",
-
-
-
- 236 -
-
- -
-
-
                    c.quality, c.durability, c.steps, c.actions
-
-
-
- 237 -
-
- -
-
-
                )
-
-
-
- 238 -
-
- -
-
-
            }
-
-
-
- 239 -
-
- -
-
-
        }
-
-
-
- 240 -
-
- -
-
-
        None => println!("No routes to print"),
-
-
-
- 241 -
-
- -
-
-
    }
-
-
-
- 242 -
-
- -
-
-
}
-
-
-
- 243 -
-
- -
-
-

-            
-
-
- 244 -
-
- -
-
-
/// Find the route with the least amount of steps
-
-
-
- 245 -
-
- -
-
-
pub fn find_fast_route(routes: &Option<Vec<SolverResult>>) -> Option<&SolverResult> {
-
-
-
- 246 -
-
- -
-
-
    match routes {
-
-
-
- 247 -
-
- -
-
-
        Some(_routes) => {
-
-
-
- 248 -
-
- -
-
-
            if _routes.len() > 0 {
-
-
-
- 249 -
-
- -
-
-
                _routes.iter().min_by_key(|key| key.steps)
-
-
-
- 250 -
-
- -
-
-
            } else {
-
-
-
- 251 -
-
- -
-
-
                None
-
-
-
- 252 -
-
- -
-
-
            }
-
-
-
- 253 -
-
- -
-
-
        }
-
-
-
- 254 -
-
- -
-
-
        None => None,
-
-
-
- 255 -
-
- -
-
-
    }
-
-
-
- 256 -
-
- -
-
-
}
-
-
-
- 257 -
-
- -
-
-

-            
-
-
- 258 -
-
- -
-
-
/// Find the route with the maximum amount of quality
-
-
-
- 259 -
-
- -
-
-
pub fn find_quality_route(routes: &Option<Vec<SolverResult>>) -> Option<&SolverResult> {
-
-
-
- 260 -
-
- -
-
-
    match routes {
-
-
-
- 261 -
-
- -
-
-
        Some(_routes) => _routes.iter().max_by_key(|key| key.quality),
-
-
-
- 262 -
-
- -
-
-
        None => None,
-
-
-
- 263 -
-
- -
-
-
    }
-
-
-
- 264 -
-
- -
-
-
}
-
-
-
- 265 -
-
- -
-
-

-            
-
-
- 266 -
-
- -
-
-
/// Find the route with the maximum of durability left
-
-
-
- 267 -
-
- -
-
-
pub fn find_safe_route(routes: &Option<Vec<SolverResult>>) -> Option<&SolverResult> {
-
-
-
- 268 -
-
- -
-
-
    match routes {
-
-
-
- 269 -
-
- -
-
-
        Some(_routes) => {
-
-
-
- 270 -
-
- -
-
-
            if _routes.len() > 0 {
-
-
-
- 271 -
-
- -
-
-
                _routes.iter().max_by_key(|key| key.durability)
-
-
-
- 272 -
-
- -
-
-
            } else {
-
-
-
- 273 -
-
- -
-
-
                None
-
-
-
- 274 -
-
- -
-
-
            }
-
-
-
- 275 -
-
- -
-
-
        }
-
-
-
- 276 -
-
- -
-
-
        None => None,
-
-
-
- 277 -
-
- -
-
-
    }
-
-
-
- 278 -
-
- -
-
-
}
-
-
-
-
-
-

Date: 2023-03-01 23:03

-
-
- - diff --git a/coverage/html/src/solver.rs.html b/coverage/html/src/solver.rs.html deleted file mode 100644 index 8acb7c9..0000000 --- a/coverage/html/src/solver.rs.html +++ /dev/null @@ -1,3952 +0,0 @@ - - - - - Grcov report - solver.rs - - -
- - - -
-
- 1 -
-
- -
-
-
use crate::action::{Action, ACTIONS};
-
-
-
- 2 -
-
- -
-
-
use crate::craft::Craft;
-
-
-
- 3 -
-
- -
-
-
use crate::specs::Success;
-
-
-
- 4 -
-
- -
-
-
use std::collections::VecDeque;
-
-
-
- 5 -
-
- -
-
-
use std::ops::Not;
-
-
-
- 6 -
-
- -
-
-

-            
-
-
- 7 -
-
- -
-
-
macro_rules! action_vec {
-
-
-
- 8 -
-
- -
-
-
    ($($tt:expr),*) => { vec![ $(Some(&$tt),)*]};
-
-
-
- 9 -
-
- -
-
-
}
-
-
-
- 10 -
-
- -
-
-

-            
-
-
- 11 -
-
- -
-
-
/// Find the next authorised action for this step of the craft
-
-
-
- 12 -
-
- -
-
-
pub fn next_action_picker_1<'a>(craft: &Craft<'a>) -> Vec<Option<&'a Action>> {
-
-
-
- 13 -
-
- -
-
-
    if craft.success != Success::Pending {
-
-
-
- 14 -
-
- -
-
-
        return vec![None];
-
-
-
- 15 -
-
- -
-
-
    }
-
-
-
- 16 -
-
- -
-
-
    let mut available_actions = Vec::<Option<&'a Action>>::new();
-
-
-
- 17 -
-
- -
-
-
    let mut forbidden_actions = Vec::<Option<&'a Action>>::new();
-
-
-
- 18 -
-
- -
-
-

-            
-
-
- 19 -
-
- -
-
-
    // Optimize the first three steps for massive time save
-
-
-
- 20 -
-
- -
-
-
    if craft.step_count == 0 {
-
-
-
- 21 -
-
- -
-
-
        return action_vec![ACTIONS.muscle_memory];
-
-
-
- 22 -
-
- -
-
-
    }
-
-
-
- 23 -
-
- -
-
-
    if craft.step_count == 1 {
-
-
-
- 24 -
-
- -
-
-
        return action_vec![ACTIONS.manipulation];
-
-
-
- 25 -
-
- -
-
-
    }
-
-
-
- 26 -
-
- -
-
-

-            
-
-
- 27 -
-
- -
-
-
    // Prune some actions if not requested by --long
-
-
-
- 28 -
-
- -
-
-
    if craft.step_count == 2 {
-
-
-
- 29 -
-
- -
-
-
        return action_vec![/*ACTIONS.waste_not, ACTIONS.waste_not_ii, */ ACTIONS.veneration];
-
-
-
- 30 -
-
- -
-
-
    }
-
-
-
- 31 -
-
- -
-
-
    if craft.step_count == 3 {
-
-
-
- 32 -
-
- -
-
-
        available_actions.append(&mut action_vec![
-
-
-
- 33 -
-
- -
-
-
            ACTIONS.waste_not_ii /*,ACTIONS.waste_not*/
-
-
-
- 34 -
-
- -
-
-
        ])
-
-
-
- 35 -
-
- -
-
-
    }
-
-
-
- 36 -
-
- -
-
-

-            
-
-
- 37 -
-
- -
-
-
    // Groundwork mostly for wn / mm
-
-
-
- 38 -
-
- -
-
-
    if craft.buffs.waste_not > 0 || craft.buffs.muscle_memory > 0 {
-
-
-
- 39 -
-
- -
-
-
        available_actions.append(&mut action_vec![ACTIONS.groundwork])
-
-
-
- 40 -
-
- -
-
-
    }
-
-
-
- 41 -
-
- -
-
-

-            
-
-
- 42 -
-
- -
-
-
    // Forbidding actions depending on buffs
-
-
-
- 43 -
-
- -
-
-
    if craft.buffs.muscle_memory > 0 {
-
-
-
- 44 -
-
- -
-
-
        forbidden_actions.append(&mut action_vec![
-
-
-
- 45 -
-
- -
-
-
            ACTIONS.basic_synthesis,
-
-
-
- 46 -
-
- -
-
-
            ACTIONS.careful_synthesis,
-
-
-
- 47 -
-
- -
-
-
            ACTIONS.prudent_synthesis,
-
-
-
- 48 -
-
- -
-
-
            ACTIONS.delicate_synthesis
-
-
-
- 49 -
-
- -
-
-
        ])
-
-
-
- 50 -
-
- -
-
-
    }
-
-
-
- 51 -
-
- -
-
-
    if craft.buffs.waste_not > 0 {
-
-
-
- 52 -
-
- -
-
-
        forbidden_actions.append(&mut action_vec![ACTIONS.prudent_synthesis])
-
-
-
- 53 -
-
- -
-
-
    }
-
-
-
- 54 -
-
- -
-
-
    available_actions.append(&mut action_vec![
-
-
-
- 55 -
-
- -
-
-
        ACTIONS.basic_synthesis,
-
-
-
- 56 -
-
- -
-
-
        ACTIONS.careful_synthesis,
-
-
-
- 57 -
-
- -
-
-
        ACTIONS.prudent_synthesis,
-
-
-
- 58 -
-
- -
-
-
        ACTIONS.delicate_synthesis
-
-
-
- 59 -
-
- -
-
-
    ]);
-
-
-
- 60 -
-
- -
-
-

-            
-
-
- 61 -
-
- -
-
-
    // ACTIONS.groundwork for the --pls
-
-
-
- 62 -
-
- -
-
-
    if craft.args.desperate {
-
-
-
- 63 -
-
- -
-
-
        available_actions.append(&mut action_vec![ACTIONS.groundwork]);
-
-
-
- 64 -
-
- -
-
-
    }
-
-
-
- 65 -
-
- -
-
-

-            
-
-
- 66 -
-
- -
-
-
    // For long first run
-
-
-
- 67 -
-
- -
-
-
    if craft.step_count > 8 {
-
-
-
- 68 -
-
- -
-
-
        available_actions.append(&mut action_vec![ACTIONS.waste_not_ii, ACTIONS.waste_not])
-
-
-
- 69 -
-
- -
-
-
    };
-
-
-
- 70 -
-
- -
-
-

-            
-
-
- 71 -
-
- -
-
-
    // Pruning the actions with the forbidden ones
-
-
-
- 72 -
-
- -
-
-
    let mut result_actions = Vec::<Option<&'a Action>>::new();
-
-
-
- 73 -
-
- -
-
-
    for action in available_actions {
-
-
-
- 74 -
-
- -
-
-
        if !forbidden_actions.contains(&action)
-
-
-
- 75 -
-
- -
-
-
            && action.unwrap().can_use(&craft)
-
-
-
- 76 -
-
- -
-
-
            && result_actions
-
-
-
- 77 -
-
- -
-
-
                .iter()
-
-
-
- 78 -
-
- -
-
-
                .any(|x| x.unwrap() == action.unwrap())
-
-
-
- 79 -
-
- -
-
-
                .not()
-
-
-
- 80 -
-
- -
-
-
        {
-
-
-
- 81 -
-
- -
-
-
            result_actions.push(action);
-
-
-
- 82 -
-
- -
-
-
        }
-
-
-
- 83 -
-
- -
-
-
    }
-
-
-
- 84 -
-
- -
-
-

-            
-
-
- 85 -
-
- -
-
-
    result_actions
-
-
-
- 86 -
-
- -
-
-
}
-
-
-
- 87 -
-
- -
-
-

-            
-
-
- 88 -
-
- -
-
-
/// Find all routes that can finish in one more action
-
-
-
- 89 -
-
- -
-
-
pub fn generate_routes_phase1<'a>(craft: Craft<'a>) -> Vec<Craft<'a>> {
-
-
-
- 90 -
-
- -
-
-
    let mut queue = Vec::new();
-
-
-
- 91 -
-
- -
-
-
    queue.push(craft);
-
-
-
- 92 -
-
- -
-
-
    let mut routes = Vec::new();
-
-
-
- 93 -
-
- -
-
-
    while !queue.is_empty() {
-
-
-
- 94 -
-
- -
-
-
        let craft = queue.pop().unwrap();
-
-
-
- 95 -
-
- -
-
-
        for action in next_action_picker_1(&craft) {
-
-
-
- 96 -
-
- -
-
-
            let mut craft = craft.clone();
-
-
-
- 97 -
-
- -
-
-

-            
-
-
- 98 -
-
- -
-
-
            match action {
-
-
-
- 99 -
-
- -
-
-
                Some(a) => craft.run_action(a),
-
-
-
- 100 -
-
- -
-
-
                None => break,
-
-
-
- 101 -
-
- -
-
-
            };
-
-
-
- 102 -
-
- -
-
-

-            
-
-
- 103 -
-
- -
-
-
            let remaining_prog = (craft.recipe.progress as f32 - craft.progression as f32)
-
-
-
- 104 -
-
- -
-
-
                / craft.get_base_progression() as f32;
-
-
-
- 105 -
-
- -
-
-
            if remaining_prog <= 2.0 {
-
-
-
- 106 -
-
- -
-
-
                if remaining_prog <= 0.0 {
-
-
-
- 107 -
-
- -
-
-
                    continue;
-
-
-
- 108 -
-
- -
-
-
                } else if 0.0 < remaining_prog && remaining_prog <= 1.2 {
-
-
-
- 109 -
-
- -
-
-
                    // pass         // Will finish with basicSynth2 (free)
-
-
-
- 110 -
-
- -
-
-
                } else if 1.2 < remaining_prog && remaining_prog <= 1.2 {
-
-
-
- 111 -
-
- -
-
-
                    craft.cp -= 7; // Will finish with carefulSynthesis (7cp)
-
-
-
- 112 -
-
- -
-
-
                } else if 1.2 < remaining_prog && remaining_prog <= 2.0 {
-
-
-
- 113 -
-
- -
-
-
                    craft.cp -= 12; // Will finish with observe+focusedSynthesis (12cp)
-
-
-
- 114 -
-
- -
-
-
                }
-
-
-
- 115 -
-
- -
-
-
                craft.durability -= 10; // Save the final step, since we always aim to end with -5dur, it doesn't matter
-
-
-
- 116 -
-
- -
-
-
                routes.push(craft);
-
-
-
- 117 -
-
- -
-
-
                continue;
-
-
-
- 118 -
-
- -
-
-
            }
-
-
-
- 119 -
-
- -
-
-

-            
-
-
- 120 -
-
- -
-
-
            // Keep adding initial routes with several pass, we must be able to finish in one step
-
-
-
- 121 -
-
- -
-
-
            // 8 Seemed to be a good initial guess with enouth to use a good amount of WN / WNII to get close
-
-
-
- 122 -
-
- -
-
-
            // A higher value will yield more initial guesses with minimal benefits
-
-
-
- 123 -
-
- -
-
-
            // A lover value will yield less initial guesses and might spent too much CP to get to the required progression
-
-
-
- 124 -
-
- -
-
-
            if craft.step_count < craft.args.depth {
-
-
-
- 125 -
-
- -
-
-
                queue.push(craft);
-
-
-
- 126 -
-
- -
-
-
            }
-
-
-
- 127 -
-
- -
-
-
        }
-
-
-
- 128 -
-
- -
-
-
    }
-
-
-
- 129 -
-
- -
-
-
    routes
-
-
-
- 130 -
-
- -
-
-
}
-
-
-
- 131 -
-
- -
-
-

-            
-
-
- 132 -
-
- -
-
-
/// Find the list of authorised actions for this step
-
-
-
- 133 -
-
- -
-
-
pub fn next_action_phase_2<'a>(craft: &Craft<'a>) -> Vec<Option<&'a Action>> {
-
-
-
- 134 -
-
- -
-
-
    let mut available_actions = vec![
-
-
-
- 135 -
-
- -
-
-
        &ACTIONS.basic_touch,
-
-
-
- 136 -
-
- -
-
-
        &ACTIONS.prudent_touch,
-
-
-
- 137 -
-
- -
-
-
        &ACTIONS.preparatory_touch,
-
-
-
- 138 -
-
- -
-
-
    ];
-
-
-
- 139 -
-
- -
-
-
    let mut forbidden_actions = Vec::new();
-
-
-
- 140 -
-
- -
-
-
    if craft.success != Success::Pending {
-
-
-
- 141 -
-
- -
-
-
        return vec![None];
-
-
-
- 142 -
-
- -
-
-
    }
-
-
-
- 143 -
-
- -
-
-
    if craft.buffs.innovation > 0 {
-
-
-
- 144 -
-
- -
-
-
        forbidden_actions.push(&ACTIONS.innovation);
-
-
-
- 145 -
-
- -
-
-
    } else {
-
-
-
- 146 -
-
- -
-
-
        if craft.buffs.inner_quiet >= 2 {
-
-
-
- 147 -
-
- -
-
-
            forbidden_actions.append(&mut vec![
-
-
-
- 148 -
-
- -
-
-
                &ACTIONS.basic_touch,
-
-
-
- 149 -
-
- -
-
-
                &ACTIONS.standard_touch,
-
-
-
- 150 -
-
- -
-
-
                &ACTIONS.advanced_touch,
-
-
-
- 151 -
-
- -
-
-
                &ACTIONS.trained_finesse,
-
-
-
- 152 -
-
- -
-
-
                &ACTIONS.prudent_touch,
-
-
-
- 153 -
-
- -
-
-
                &ACTIONS.preparatory_touch,
-
-
-
- 154 -
-
- -
-
-
                &ACTIONS.byregot_blessing,
-
-
-
- 155 -
-
- -
-
-
            ]);
-
-
-
- 156 -
-
- -
-
-
        }
-
-
-
- 157 -
-
- -
-
-
        available_actions.push(&ACTIONS.innovation);
-
-
-
- 158 -
-
- -
-
-
    }
-
-
-
- 159 -
-
- -
-
-
    if craft.buffs.manipulation == 0
-
-
-
- 160 -
-
- -
-
-
        && craft.buffs.basic_touch == 0
-
-
-
- 161 -
-
- -
-
-
        && craft.buffs.standard_touch == 0
-
-
-
- 162 -
-
- -
-
-
        && craft.buffs.inner_quiet < 8
-
-
-
- 163 -
-
- -
-
-
    {
-
-
-
- 164 -
-
- -
-
-
        available_actions.push(&ACTIONS.manipulation);
-
-
-
- 165 -
-
- -
-
-
    }
-
-
-
- 166 -
-
- -
-
-
    if craft.buffs.waste_not > 0 {
-
-
-
- 167 -
-
- -
-
-
        available_actions.push(&ACTIONS.preparatory_touch);
-
-
-
- 168 -
-
- -
-
-
        forbidden_actions.push(&ACTIONS.prudent_touch);
-
-
-
- 169 -
-
- -
-
-
    } else {
-
-
-
- 170 -
-
- -
-
-
        available_actions.push(&ACTIONS.prudent_touch);
-
-
-
- 171 -
-
- -
-
-
        forbidden_actions.push(&ACTIONS.preparatory_touch);
-
-
-
- 172 -
-
- -
-
-
    }
-
-
-
- 173 -
-
- -
-
-
    if craft.buffs.basic_touch > 0 {
-
-
-
- 174 -
-
- -
-
-
        available_actions.push(&ACTIONS.standard_touch);
-
-
-
- 175 -
-
- -
-
-
        forbidden_actions.push(&ACTIONS.basic_touch);
-
-
-
- 176 -
-
- -
-
-
    }
-
-
-
- 177 -
-
- -
-
-
    if craft.buffs.standard_touch > 0 {
-
-
-
- 178 -
-
- -
-
-
        available_actions.push(&ACTIONS.advanced_touch);
-
-
-
- 179 -
-
- -
-
-
        forbidden_actions.push(&ACTIONS.basic_touch);
-
-
-
- 180 -
-
- -
-
-
    }
-
-
-
- 181 -
-
- -
-
-

-            
-
-
- 182 -
-
- -
-
-
    if craft.buffs.inner_quiet >= craft.args.byregot_step {
-
-
-
- 183 -
-
- -
-
-
        // 10
-
-
-
- 184 -
-
- -
-
-
        available_actions.push(&ACTIONS.trained_finesse);
-
-
-
- 185 -
-
- -
-
-
        available_actions.push(&ACTIONS.great_strides);
-
-
-
- 186 -
-
- -
-
-
    }
-
-
-
- 187 -
-
- -
-
-
    if craft.buffs.great_strides > 0 {
-
-
-
- 188 -
-
- -
-
-
        forbidden_actions.push(&ACTIONS.trained_finesse);
-
-
-
- 189 -
-
- -
-
-
        forbidden_actions.push(&ACTIONS.great_strides);
-
-
-
- 190 -
-
- -
-
-
        if craft.buffs.innovation > 0 {
-
-
-
- 191 -
-
- -
-
-
            available_actions.push(&ACTIONS.byregot_blessing);
-
-
-
- 192 -
-
- -
-
-
        }
-
-
-
- 193 -
-
- -
-
-
    }
-
-
-
- 194 -
-
- -
-
-
    let mut final_actions: Vec<Option<&Action>> = Vec::new();
-
-
-
- 195 -
-
- -
-
-

-            
-
-
- 196 -
-
- -
-
-
    for action in available_actions {
-
-
-
- 197 -
-
- -
-
-
        if !forbidden_actions.contains(&action)
-
-
-
- 198 -
-
- -
-
-
            && !final_actions.iter().any(|a| a.unwrap() == action)
-
-
-
- 199 -
-
- -
-
-
        {
-
-
-
- 200 -
-
- -
-
-
            final_actions.push(Some(action));
-
-
-
- 201 -
-
- -
-
-
        }
-
-
-
- 202 -
-
- -
-
-
    }
-
-
-
- 203 -
-
- -
-
-
    final_actions
-
-
-
- 204 -
-
- -
-
-
}
-
-
-
- 205 -
-
- -
-
-

-            
-
-
- 206 -
-
- -
-
-
/// Apply all actions to the current route
-
-
-
- 207 -
-
- -
-
-
pub fn generate_routes_phase2<'a>(craft: Craft<'a>) -> Option<Vec<Craft<'a>>> {
-
-
-
- 208 -
-
- -
-
-
    let mut queue = VecDeque::new();
-
-
-
- 209 -
-
- -
-
-

-            
-
-
- 210 -
-
- -
-
-
    let mut top_route: Craft<'a> = craft.clone(); // Default route, no hq on that one
-
-
-
- 211 -
-
- -
-
-
    let mut top_routes: Vec<Craft<'a>> = vec![];
-
-
-
- 212 -
-
- -
-
-

-            
-
-
- 213 -
-
- -
-
-
    queue.push_back(craft);
-
-
-
- 214 -
-
- -
-
-

-            
-
-
- 215 -
-
- -
-
-
    while !queue.is_empty() {
-
-
-
- 216 -
-
- -
-
-
        let _craft = queue.pop_front().unwrap();
-
-
-
- 217 -
-
- -
-
-
        for action in next_action_phase_2(&_craft) {
-
-
-
- 218 -
-
- -
-
-
            if _craft.success != Success::Pending
-
-
-
- 219 -
-
- -
-
-
                || action.is_none()
-
-
-
- 220 -
-
- -
-
-
                || !action.unwrap().can_use(&_craft)
-
-
-
- 221 -
-
- -
-
-
            {
-
-
-
- 222 -
-
- -
-
-
                continue;
-
-
-
- 223 -
-
- -
-
-
            }
-
-
-
- 224 -
-
- -
-
-
            let mut craft = _craft.clone();
-
-
-
- 225 -
-
- -
-
-
            craft.run_action(action.unwrap());
-
-
-
- 226 -
-
- -
-
-
            if action.unwrap() == &ACTIONS.byregot_blessing {
-
-
-
- 227 -
-
- -
-
-
                #[cfg(not(feature = "fast"))]
-
-
-
- 228 -
-
- -
-
-
                if top_route.quality >= craft.recipe.quality {
-
-
-
- 229 -
-
- -
-
-
                    top_routes.push(craft.clone()); // Me memory
-
-
-
- 230 -
-
- -
-
-
                }
-
-
-
- 231 -
-
- -
-
-
                if top_route.quality < craft.quality {
-
-
-
- 232 -
-
- -
-
-
                    #[cfg(feature = "fast")]
-
-
-
- 233 -
-
- -
-
-
                    top_routes.push(craft.clone());
-
-
-
- 234 -
-
- -
-
-
                    top_route = craft;
-
-
-
- 235 -
-
- -
-
-
                }
-
-
-
- 236 -
-
- -
-
-
            } else {
-
-
-
- 237 -
-
- -
-
-
                queue.push_back(craft);
-
-
-
- 238 -
-
- -
-
-
            }
-
-
-
- 239 -
-
- -
-
-
        }
-
-
-
- 240 -
-
- -
-
-
    }
-
-
-
- 241 -
-
- -
-
-
    // Let's not forget the best result
-
-
-
- 242 -
-
- -
-
-
    top_routes.push(top_route);
-
-
-
- 243 -
-
- -
-
-
    Some(top_routes)
-
-
-
- 244 -
-
- -
-
-
}
-
-
-
-
-
-

Date: 2023-03-01 23:03

-
-
- - diff --git a/coverage/html/src/specs.rs.html b/coverage/html/src/specs.rs.html deleted file mode 100644 index d2ea3c1..0000000 --- a/coverage/html/src/specs.rs.html +++ /dev/null @@ -1,2224 +0,0 @@ - - - - - Grcov report - specs.rs - - -
- - - -
-
- 1 -
-
- -
-
-
use std::fmt::Debug;
-
-
-
- 2 -
-
- -
-
-
use strum_macros::EnumIter;
-
-
-
- 3 -
-
- -
-
-

-            
-
-
- 4 -
-
- -
-
-
#[derive(Debug, Clone, Copy)]
-
-
-
- 5 -
-
- -
-
-
pub struct Recipe {
-
-
-
- 6 -
-
- -
-
-
    pub durability: u32,
-
-
-
- 7 -
-
- -
-
-
    pub progress: u32,
-
-
-
- 8 -
-
- -
-
-
    pub quality: u32,
-
-
-
- 9 -
-
- -
-
-
    pub progress_divider: u32,
-
-
-
- 10 -
-
- -
-
-
    pub quality_divider: u32,
-
-
-
- 11 -
-
- -
-
-
    pub progress_modifier: u32,
-
-
-
- 12 -
-
- -
-
-
    pub quality_modifier: u32,
-
-
-
- 13 -
-
- -
-
-
}
-
-
-
- 14 -
-
- -
-
-

-            
-
-
- 15 -
-
- -
-
-
#[derive(Debug, Clone, Copy)]
-
-
-
- 16 -
-
- -
-
-
pub struct Stats {
-
-
-
- 17 -
-
- -
-
-
    pub craftsmanship: u32,
-
-
-
- 18 -
-
- -
-
-
    pub control: u32,
-
-
-
- 19 -
-
- -
-
-
    pub max_cp: u32,
-
-
-
- 20 -
-
- -
-
-
}
-
-
-
- 21 -
-
- -
-
-

-            
-
-
- 22 -
-
- -
-
-
#[derive(Debug, Clone, Copy, PartialEq, EnumIter)]
-
-
-
- 23 -
-
- -
-
-
pub enum Buff {
-
-
-
- 24 -
-
- -
-
-
    InnerQuiet,
-
-
-
- 25 -
-
- -
-
-
    WasteNot,
-
-
-
- 26 -
-
- -
-
-
    GreatStrides,
-
-
-
- 27 -
-
- -
-
-
    Innovation,
-
-
-
- 28 -
-
- -
-
-
    Veneration,
-
-
-
- 29 -
-
- -
-
-
    Manipulation,
-
-
-
- 30 -
-
- -
-
-
    MuscleMemory,
-
-
-
- 31 -
-
- -
-
-
    // v Hidden v
-
-
-
- 32 -
-
- -
-
-
    BasicTouch,
-
-
-
- 33 -
-
- -
-
-
    StandardTouch,
-
-
-
- 34 -
-
- -
-
-
    Observe,
-
-
-
- 35 -
-
- -
-
-
}
-
-
-
- 36 -
-
- -
-
-

-            
-
-
- 37 -
-
- -
-
-
#[derive(Debug, Clone, Copy)]
-
-
-
- 38 -
-
- -
-
-
pub struct BuffState {
-
-
-
- 39 -
-
- -
-
-
    pub inner_quiet: u8,
-
-
-
- 40 -
-
- -
-
-
    pub waste_not: u8,
-
-
-
- 41 -
-
- -
-
-
    pub great_strides: u8,
-
-
-
- 42 -
-
- -
-
-
    pub innovation: u8,
-
-
-
- 43 -
-
- -
-
-
    pub veneration: u8,
-
-
-
- 44 -
-
- -
-
-
    pub manipulation: u8,
-
-
-
- 45 -
-
- -
-
-
    pub muscle_memory: u8,
-
-
-
- 46 -
-
- -
-
-
    pub basic_touch: u8,
-
-
-
- 47 -
-
- -
-
-
    pub standard_touch: u8,
-
-
-
- 48 -
-
- -
-
-
    pub observe: u8,
-
-
-
- 49 -
-
- -
-
-
}
-
-
-
- 50 -
-
- -
-
-

-            
-
-
- 51 -
-
- -
-
-
impl BuffState {
-
-
-
- 52 -
-
- -
-
-
    pub fn default() -> Self {
-
-
-
- 53 -
-
- -
-
-
        Self {
-
-
-
- 54 -
-
- -
-
-
            inner_quiet: 0,
-
-
-
- 55 -
-
- -
-
-
            waste_not: 0,
-
-
-
- 56 -
-
- -
-
-
            great_strides: 0,
-
-
-
- 57 -
-
- -
-
-
            innovation: 0,
-
-
-
- 58 -
-
- -
-
-
            veneration: 0,
-
-
-
- 59 -
-
- -
-
-
            manipulation: 0,
-
-
-
- 60 -
-
- -
-
-
            muscle_memory: 0,
-
-
-
- 61 -
-
- -
-
-
            basic_touch: 0,
-
-
-
- 62 -
-
- -
-
-
            standard_touch: 0,
-
-
-
- 63 -
-
- -
-
-
            observe: 0,
-
-
-
- 64 -
-
- -
-
-
        }
-
-
-
- 65 -
-
- -
-
-
    }
-
-
-
- 66 -
-
- -
-
-

-            
-
-
- 67 -
-
- -
-
-
    pub fn remove(&mut self, buff: Buff) {
-
-
-
- 68 -
-
- -
-
-
        match buff {
-
-
-
- 69 -
-
- -
-
-
            Buff::InnerQuiet => self.inner_quiet = 0,
-
-
-
- 70 -
-
- -
-
-
            Buff::WasteNot => self.waste_not = 0,
-
-
-
- 71 -
-
- -
-
-
            Buff::GreatStrides => self.great_strides = 0,
-
-
-
- 72 -
-
- -
-
-
            Buff::Innovation => self.innovation = 0,
-
-
-
- 73 -
-
- -
-
-
            Buff::Veneration => self.veneration = 0,
-
-
-
- 74 -
-
- -
-
-
            Buff::Manipulation => self.manipulation = 0,
-
-
-
- 75 -
-
- -
-
-
            Buff::MuscleMemory => self.muscle_memory = 0,
-
-
-
- 76 -
-
- -
-
-
            Buff::BasicTouch => self.basic_touch = 0,
-
-
-
- 77 -
-
- -
-
-
            Buff::StandardTouch => self.standard_touch = 0,
-
-
-
- 78 -
-
- -
-
-
            Buff::Observe => self.observe = 0,
-
-
-
- 79 -
-
- -
-
-
        }
-
-
-
- 80 -
-
- -
-
-
    }
-
-
-
- 81 -
-
- -
-
-

-            
-
-
- 82 -
-
- -
-
-
    pub fn apply(&mut self, buff: Buff, value: u8) {
-
-
-
- 83 -
-
- -
-
-
        match buff {
-
-
-
- 84 -
-
- -
-
-
            Buff::InnerQuiet => {
-
-
-
- 85 -
-
- -
-
-
                if value == 0 {
-
-
-
- 86 -
-
- -
-
-
                    self.inner_quiet = 0;
-
-
-
- 87 -
-
- -
-
-
                } else {
-
-
-
- 88 -
-
- -
-
-
                    self.inner_quiet += value;
-
-
-
- 89 -
-
- -
-
-
                }
-
-
-
- 90 -
-
- -
-
-
            }
-
-
-
- 91 -
-
- -
-
-
            Buff::WasteNot => self.waste_not = value,
-
-
-
- 92 -
-
- -
-
-
            Buff::GreatStrides => self.great_strides = value,
-
-
-
- 93 -
-
- -
-
-
            Buff::Innovation => self.innovation = value,
-
-
-
- 94 -
-
- -
-
-
            Buff::Veneration => self.veneration = value,
-
-
-
- 95 -
-
- -
-
-
            Buff::Manipulation => self.manipulation = value,
-
-
-
- 96 -
-
- -
-
-
            Buff::MuscleMemory => self.muscle_memory = value,
-
-
-
- 97 -
-
- -
-
-
            Buff::BasicTouch => self.basic_touch = value,
-
-
-
- 98 -
-
- -
-
-
            Buff::StandardTouch => self.standard_touch = value,
-
-
-
- 99 -
-
- -
-
-
            Buff::Observe => self.standard_touch = value,
-
-
-
- 100 -
-
- -
-
-
        }
-
-
-
- 101 -
-
- -
-
-
    }
-
-
-
- 102 -
-
- -
-
-

-            
-
-
- 103 -
-
- -
-
-
    pub fn tick(&mut self) {
-
-
-
- 104 -
-
- -
-
-
        if self.waste_not > 0 {
-
-
-
- 105 -
-
- -
-
-
            self.waste_not -= 1;
-
-
-
- 106 -
-
- -
-
-
        }
-
-
-
- 107 -
-
- -
-
-
        if self.great_strides > 0 {
-
-
-
- 108 -
-
- -
-
-
            self.great_strides -= 1;
-
-
-
- 109 -
-
- -
-
-
        }
-
-
-
- 110 -
-
- -
-
-
        if self.innovation > 0 {
-
-
-
- 111 -
-
- -
-
-
            self.innovation -= 1;
-
-
-
- 112 -
-
- -
-
-
        }
-
-
-
- 113 -
-
- -
-
-
        if self.veneration > 0 {
-
-
-
- 114 -
-
- -
-
-
            self.veneration -= 1;
-
-
-
- 115 -
-
- -
-
-
        }
-
-
-
- 116 -
-
- -
-
-
        if self.manipulation > 0 {
-
-
-
- 117 -
-
- -
-
-
            self.manipulation -= 1;
-
-
-
- 118 -
-
- -
-
-
        }
-
-
-
- 119 -
-
- -
-
-
        if self.muscle_memory > 0 {
-
-
-
- 120 -
-
- -
-
-
            self.muscle_memory -= 1;
-
-
-
- 121 -
-
- -
-
-
        }
-
-
-
- 122 -
-
- -
-
-
        if self.basic_touch > 0 {
-
-
-
- 123 -
-
- -
-
-
            self.basic_touch -= 1;
-
-
-
- 124 -
-
- -
-
-
        }
-
-
-
- 125 -
-
- -
-
-
        if self.standard_touch > 0 {
-
-
-
- 126 -
-
- -
-
-
            self.standard_touch -= 1;
-
-
-
- 127 -
-
- -
-
-
        }
-
-
-
- 128 -
-
- -
-
-
    }
-
-
-
- 129 -
-
- -
-
-
}
-
-
-
- 130 -
-
- -
-
-

-            
-
-
- 131 -
-
- -
-
-
#[derive(Debug, Clone, Copy, PartialEq)]
-
-
-
- 132 -
-
- -
-
-
pub enum Success {
-
-
-
- 133 -
-
- -
-
-
    Pending,
-
-
-
- 134 -
-
- -
-
-
    Success,
-
-
-
- 135 -
-
- -
-
-
    Failure,
-
-
-
- 136 -
-
- -
-
-
}
-
-
-
-
-
-

Date: 2023-03-01 23:03

-
-
- - diff --git a/coverage/html/tests/index.html b/coverage/html/tests/index.html deleted file mode 100644 index 74338e6..0000000 --- a/coverage/html/tests/index.html +++ /dev/null @@ -1,105 +0,0 @@ - - - - - Grcov report - tests - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FileLine CoverageFunctionsBranches
io.rs - - 100% - - - 100% - - 1 / 1 - 100%1 / 1 100%0 / 0
lib.rs - - 100% - - - 100% - - 1 / 1 - 100%1 / 1 100%0 / 0
-
-
-

Date: 2023-03-01 23:03

-
-
- - diff --git a/coverage/html/tests/io.rs.html b/coverage/html/tests/io.rs.html deleted file mode 100644 index c7289fb..0000000 --- a/coverage/html/tests/io.rs.html +++ /dev/null @@ -1,64 +0,0 @@ - - - - - Grcov report - io.rs - - -
- - - -
-
- 1 -
-
- 11 -
-
-

-            
-
-
-
-
-

Date: 2023-03-01 23:03

-
-
- - diff --git a/coverage/html/tests/lib.rs.html b/coverage/html/tests/lib.rs.html deleted file mode 100644 index cf779cc..0000000 --- a/coverage/html/tests/lib.rs.html +++ /dev/null @@ -1,64 +0,0 @@ - - - - - Grcov report - lib.rs - - -
- - - -
-
- 1 -
-
- 11 -
-
-

-            
-
-
-
-
-

Date: 2023-03-01 23:03

-
-
- - diff --git a/src/craft.rs b/src/craft.rs index b60e49f..c1c0446 100644 --- a/src/craft.rs +++ b/src/craft.rs @@ -183,3 +183,15 @@ impl<'a> Display for Craft<'a> { .finish() } } + + +#[cfg(test)] +mod test{ + // Struct Test + #[test] + pub fn struct_tests(){ + + } + + +} \ No newline at end of file diff --git a/src/io.rs b/src/io.rs index 2fa3915..4c6e038 100644 --- a/src/io.rs +++ b/src/io.rs @@ -307,7 +307,7 @@ pub fn solve_from_python(py: Python<'_>, values: &PyAny) -> PyResult self.muscle_memory = value, Buff::BasicTouch => self.basic_touch = value, Buff::StandardTouch => self.standard_touch = value, - Buff::Observe => self.standard_touch = value, + Buff::Observe => self.observe = value, } } @@ -186,7 +186,7 @@ impl BuffState { /// State the craft is in, used to keep track of wether the craft /// is to be worked on, added to the success vector or discarded -#[derive(Debug, Clone, Copy, PartialEq)] +#[derive(Debug,Clone,PartialEq)] pub enum Success { /// Pending success and therefor still ongoing Pending, @@ -195,3 +195,76 @@ pub enum Success { /// Finised because of lack of remaining durability Failure, } + +// Test unit +#[cfg(test)] +mod tests { + // Test default values + use pretty_assertions::{assert_eq}; + use strum::IntoEnumIterator; + + #[test] + pub fn test_structs() { + format!("{:?}",crate::specs::Recipe { + durability: 0, + progress: 0, + progress_divider: 0, + progress_modifier: 0, + quality: 0, + quality_divider: 0, + quality_modifier: 0, + }.clone()); + + format!("{:?}",crate::specs::Stats { + craftsmanship: 0, + control: 0, + max_cp: 0, + } + .clone()); + + let iq = crate::specs::Buff::InnerQuiet; + assert_eq!(crate::specs::Buff::InnerQuiet, iq); + for buff in crate::specs::Buff::iter(){ + format!("{:?}",buff); + } + format!("{:?}", crate::specs::BuffState::default().clone()); + + let sc = crate::specs::Success::Pending; + assert!(crate::specs::Success::Pending==sc); + assert!(crate::specs::Success::Success!=sc); + format!("{:?}",sc); + } + + #[test] + pub fn test_buffstate() { + let mut bbs = crate::specs::BuffState::default(); + for buff in crate::specs::Buff::iter(){ + bbs.apply(buff, 2); + } + assert_eq!(bbs.inner_quiet, 2); + assert_eq!(bbs.waste_not, 2); + assert_eq!(bbs.great_strides, 2); + assert_eq!(bbs.innovation, 2); + assert_eq!(bbs.veneration, 2); + assert_eq!(bbs.manipulation, 2); + assert_eq!(bbs.muscle_memory, 2); + assert_eq!(bbs.basic_touch, 2); + assert_eq!(bbs.standard_touch, 2); + assert_eq!(bbs.observe, 2); + bbs.apply(crate::specs::Buff::InnerQuiet, 0); + bbs.apply(crate::specs::Buff::Innovation, 5); + assert_eq!(bbs.inner_quiet, 0); + assert_eq!(bbs.innovation, 5); + bbs.apply(crate::specs::Buff::InnerQuiet, 2); + bbs.apply(crate::specs::Buff::InnerQuiet, 1); + assert_eq!(bbs.inner_quiet, 3); + bbs.tick(); + assert_eq!(bbs.inner_quiet, 3); + assert_eq!(bbs.innovation, 4); + for buff in crate::specs::Buff::iter(){ + bbs.remove(buff); + } + assert_eq!(bbs.inner_quiet, 0); + assert_eq!(bbs.innovation, 0); + } +} -- 2.45.1