diff --git a/.gitignore b/.gitignore
index 8634d9d..44bf683 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,6 +7,7 @@ expected_values.md
releases/*
.whl
pyinstaller_log.txt
+llvm/*
# Byte-compiled / optimized / DLL files
__pycache__/
diff --git a/Cargo.lock b/Cargo.lock
index 7de9c2e..50d1baf 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -63,6 +63,22 @@ dependencies = [
"os_str_bytes",
]
+[[package]]
+name = "ctor"
+version = "0.1.26"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6d2301688392eb071b0bf1a37be05c469d3cc4dbbd95df672fe28ab021e6a096"
+dependencies = [
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "diff"
+version = "0.1.13"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8"
+
[[package]]
name = "errno"
version = "0.2.8"
@@ -192,6 +208,15 @@ version = "6.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee"
+[[package]]
+name = "output_vt100"
+version = "0.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "628223faebab4e3e40667ee0b2336d34a5b960ff60ea743ddfdbcf7770bcfb66"
+dependencies = [
+ "winapi",
+]
+
[[package]]
name = "parking_lot"
version = "0.12.1"
@@ -215,6 +240,18 @@ dependencies = [
"windows-sys",
]
+[[package]]
+name = "pretty_assertions"
+version = "1.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a25e9bcb20aa780fd0bb16b72403a9064d6b3f22f026946029acb941a50af755"
+dependencies = [
+ "ctor",
+ "diff",
+ "output_vt100",
+ "yansi",
+]
+
[[package]]
name = "proc-macro-error"
version = "1.0.4"
@@ -557,9 +594,16 @@ version = "0.1.5"
dependencies = [
"clap",
"lazy_static",
+ "pretty_assertions",
"pyo3",
"strum",
"strum_macros",
"threadpool",
"toml",
]
+
+[[package]]
+name = "yansi"
+version = "0.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec"
diff --git a/Cargo.toml b/Cargo.toml
index 1eaf085..d4cd61c 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -27,6 +27,9 @@ pyo3 = { version = "0.18.0", features = ["extension-module"] }
# [build]
# target = ["x86_64-unknown-linux-gnu", "x86_64-unknown-windows-gnu"]
+[dev-dependencies]
+pretty_assertions = "1"
+
[profile.release]
panic = 'abort'
opt-level = 3
diff --git a/Makefile.toml b/Makefile.toml
index c53db5e..cf4c53b 100644
--- a/Makefile.toml
+++ b/Makefile.toml
@@ -23,6 +23,16 @@ install_crate = "rustfmt"
command = "cargo"
args = ["fmt", "--", "--emit=files"]
+[tasks.testcov]
+script_runner = "@shell"
+ignore_errors = true
+script = [
+"mkdir -p coverage",
+"mkdir -p coverage/html",
+"CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='llvm/cargo-test-%p-%m.profraw' cargo test",
+"grcov . --binary-path ./target/debug/deps/ -s . -t html --branch --ignore-not-existing --ignore '../*' --ignore '/*' -o coverage/html/"
+]
+
[tasks.clean]
command = "cargo"
args = ["clean"]
diff --git a/README.md b/README.md
index 48fafde..fb2e1c4 100644
--- a/README.md
+++ b/README.md
@@ -4,6 +4,9 @@ A rust program for solving FFXIV craft recipe.
Originaly written by [RikaKagurasaka](https://github.com/RikaKagurasaka/xiv_craft_solver),
it now is widely improved and provides python bindings for a GUI (or anything else really)
+
+
+
### Basic RUST CLI Usage
Everything is done through the regular cargo interface
1. Download the latest release.
@@ -43,6 +46,7 @@ Options:
-V, --version
Print version
```
+
## Developpement
Please remember to set and use a venv before building
While not mandatory, using ``cargo-make`` will provide you with the commands:
diff --git a/coverage/html/badges/flat.svg b/coverage/html/badges/flat.svg
new file mode 100644
index 0000000..ca7e6f8
--- /dev/null
+++ b/coverage/html/badges/flat.svg
@@ -0,0 +1,23 @@
+
\ No newline at end of file
diff --git a/coverage/html/badges/flat_square.svg b/coverage/html/badges/flat_square.svg
new file mode 100644
index 0000000..9f2ccbb
--- /dev/null
+++ b/coverage/html/badges/flat_square.svg
@@ -0,0 +1,13 @@
+
\ No newline at end of file
diff --git a/coverage/html/badges/for_the_badge.svg b/coverage/html/badges/for_the_badge.svg
new file mode 100644
index 0000000..17ec9e4
--- /dev/null
+++ b/coverage/html/badges/for_the_badge.svg
@@ -0,0 +1,13 @@
+
\ No newline at end of file
diff --git a/coverage/html/badges/plastic.svg b/coverage/html/badges/plastic.svg
new file mode 100644
index 0000000..a127f7c
--- /dev/null
+++ b/coverage/html/badges/plastic.svg
@@ -0,0 +1,25 @@
+
\ No newline at end of file
diff --git a/coverage/html/badges/social.svg b/coverage/html/badges/social.svg
new file mode 100644
index 0000000..81f5278
--- /dev/null
+++ b/coverage/html/badges/social.svg
@@ -0,0 +1,27 @@
+
\ No newline at end of file
diff --git a/coverage/html/coverage.json b/coverage/html/coverage.json
new file mode 100644
index 0000000..b3f9229
--- /dev/null
+++ b/coverage/html/coverage.json
@@ -0,0 +1 @@
+{"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
new file mode 100644
index 0000000..7ecf263
--- /dev/null
+++ b/coverage/html/index.html
@@ -0,0 +1,129 @@
+
+
+
+
+ Grcov report - top_level
+
+
+
+
+
+
+
+
+
+ | Directory |
+ Line Coverage |
+ Functions |
+ Branches |
+
+
+
+ | src |
+
+
+
+ |
+
+ 10.84%
+ |
+
+ 115 / 1061
+ |
+
+ 8.53% |
+ 29 / 340 |
+
+ 100% |
+ 0 / 0 |
+
+
+ | src/bin |
+
+
+
+ |
+
+ 1.64%
+ |
+
+ 1 / 61
+ |
+
+ 20% |
+ 1 / 5 |
+
+ 100% |
+ 0 / 0 |
+
+
+ | tests |
+
+
+
+ |
+
+ 100%
+ |
+
+ 2 / 2
+ |
+
+ 100% |
+ 2 / 2 |
+
+ 100% |
+ 0 / 0 |
+
+
+
+
+
+
diff --git a/coverage/html/src/action.rs.html b/coverage/html/src/action.rs.html
new file mode 100644
index 0000000..c482092
--- /dev/null
+++ b/coverage/html/src/action.rs.html
@@ -0,0 +1,4912 @@
+
+
+
+
+ Grcov report - action.rs
+
+
+
+
+
+
+
+
+
+
+
+
+
use crate::craft::Craft;
+
+
+
+
+
+
+
+
use crate::specs::{Buff, Success};
+
+
+
+
+
+
+
+
use lazy_static::lazy_static;
+
+
+
+
+
+
+
+
pub buff: Option<(Buff, u8)>,
+
+
+
+
+
+
+
+
pub short_name: String,
+
+
+
+
+
+
+
+
pub struct ActionBuilder {
+
+
+
+
+
+
+
+
pub fn new(name: &str) -> Self {
+
+
+
+
+
+
+
+
let mut short_name = name.to_string();
+
+
+
+
+
+
+
+
short_name = short_name.replace("II", "2");
+
+
+
+
+
+
+
+
short_name.retain(|c| !c.is_whitespace() && c != '\'');
+
+
+
+
+
+
+
+
short_name[0..1].make_ascii_lowercase();
+
+
+
+
+
+
+
+
if name == "Basic Synthesis" {
+
+
+
+
+
+
+
+
short_name = "basicSynth2".to_string();
+
+
+
+
+
+
+
+
if name == "Groundwork" {
+
+
+
+
+
+
+
+
short_name = "groundwork".to_string();
+
+
+
+
+
+
+
+
if name == "Careful Synthesis" {
+
+
+
+
+
+
+
+
short_name = "carefulSynthesis".to_string();
+
+
+
+
+
+
+
+
name: name.to_string(),
+
+
+
+
+
+
+
+
pub fn dur(mut self, dur: u32) -> Self {
+
+
+
+
+
+
+
+
self.action.dur = dur;
+
+
+
+
+
+
+
+
pub fn cp(mut self, cp: u32) -> Self {
+
+
+
+
+
+
+
+
pub fn progress(mut self, progress: u32) -> Self {
+
+
+
+
+
+
+
+
self.action.progress = progress;
+
+
+
+
+
+
+
+
pub fn quality(mut self, quality: u32) -> Self {
+
+
+
+
+
+
+
+
self.action.quality = quality;
+
+
+
+
+
+
+
+
pub fn buff(mut self, buff: Option<(Buff, u8)>) -> Self {
+
+
+
+
+
+
+
+
self.action.buff = buff;
+
+
+
+
+
+
+
+
pub fn build(self) -> Action {
+
+
+
+
+
+
+
+
impl PartialEq for Action {
+
+
+
+
+
+
+
+
fn eq(&self, other: &Self) -> bool {
+
+
+
+
+
+
+
+
&& self.dur == other.dur
+
+
+
+
+
+
+
+
&& self.progress == other.progress
+
+
+
+
+
+
+
+
&& self.quality == other.quality
+
+
+
+
+
+
+
+
pub fn get_name(&self) -> String {
+
+
+
+
+
+
+
+
pub fn get_cp_cost(&self, _craft: &Craft) -> u32 {
+
+
+
+
+
+
+
+
if self == &ACTIONS.standard_touch && _craft.buffs.basic_touch > 0 {
+
+
+
+
+
+
+
+
if self == &ACTIONS.advanced_touch && _craft.buffs.standard_touch > 0 {
+
+
+
+
+
+
+
+
pub fn get_durability_cost(&self, _craft: &Craft) -> u32 {
+
+
+
+
+
+
+
+
if self == &ACTIONS.masters_mend {
+
+
+
+
+
+
+
+
if self.dur == 0 || self.progress == 0 && self.quality == 0 {
+
+
+
+
+
+
+
+
let mut dur = self.dur;
+
+
+
+
+
+
+
+
if _craft.buffs.waste_not > 0 {
+
+
+
+
+
+
+
+
pub fn get_progress(&self, _craft: &Craft) -> u32 {
+
+
+
+
+
+
+
+
let mut prog = self.progress as f64;
+
+
+
+
+
+
+
+
if self.dur == 20 && _craft.durability < self.get_durability_cost(_craft) as i32 {
+
+
+
+
+
+
+
+
if _craft.buffs.muscle_memory > 0 {
+
+
+
+
+
+
+
+
if _craft.buffs.veneration > 0 {
+
+
+
+
+
+
+
+
(prog * mult).floor() as u32
+
+
+
+
+
+
+
+
pub fn get_quality(&self, _craft: &Craft) -> u32 {
+
+
+
+
+
+
+
+
let mut qual = self.quality as f64;
+
+
+
+
+
+
+
+
if self == &ACTIONS.byregot_blessing {
+
+
+
+
+
+
+
+
qual = (100 + 20 * _craft.buffs.inner_quiet as u32) as f64;
+
+
+
+
+
+
+
+
if self.dur == 20 && _craft.durability < self.get_durability_cost(_craft) as i32 {
+
+
+
+
+
+
+
+
if _craft.buffs.great_strides > 0 {
+
+
+
+
+
+
+
+
if _craft.buffs.innovation > 0 {
+
+
+
+
+
+
+
+
let iq_mult = (_craft.buffs.inner_quiet as f64 * 0.1) + 1.0;
+
+
+
+
+
+
+
+
(qual * mult * iq_mult).floor() as u32
+
+
+
+
+
+
+
+
pub fn get_buff(&self) -> Option<(Buff, u8)> {
+
+
+
+
+
+
+
+
pub fn can_use(&self, _craft: &Craft) -> bool {
+
+
+
+
+
+
+
+
if self.get_cp_cost(_craft) > _craft.cp as u32 {
+
+
+
+
+
+
+
+
if _craft.success != Success::Pending {
+
+
+
+
+
+
+
+
if self == &ACTIONS.byregot_blessing {
+
+
+
+
+
+
+
+
return _craft.buffs.inner_quiet > 0;
+
+
+
+
+
+
+
+
if self == &ACTIONS.muscle_memory || self == &ACTIONS.reflect {
+
+
+
+
+
+
+
+
return _craft.step_count == 0;
+
+
+
+
+
+
+
+
if self == &ACTIONS.trained_finesse {
+
+
+
+
+
+
+
+
return _craft.buffs.inner_quiet >= 10;
+
+
+
+
+
+
+
+
impl Debug for Action {
+
+
+
+
+
+
+
+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+
+
+
+
+
+
+
+
f.write_str(&self.name)
+
+
+
+
+
+
+
+
pub struct ActionList {
+
+
+
+
+
+
+
+
pub muscle_memory: Action,
+
+
+
+
+
+
+
+
pub basic_synthesis: Action,
+
+
+
+
+
+
+
+
pub careful_synthesis: Action,
+
+
+
+
+
+
+
+
pub groundwork: Action,
+
+
+
+
+
+
+
+
pub prudent_synthesis: Action,
+
+
+
+
+
+
+
+
pub delicate_synthesis: Action,
+
+
+
+
+
+
+
+
pub basic_touch: Action,
+
+
+
+
+
+
+
+
pub standard_touch: Action,
+
+
+
+
+
+
+
+
pub byregot_blessing: Action,
+
+
+
+
+
+
+
+
pub prudent_touch: Action,
+
+
+
+
+
+
+
+
pub preparatory_touch: Action,
+
+
+
+
+
+
+
+
pub advanced_touch: Action,
+
+
+
+
+
+
+
+
pub trained_finesse: Action,
+
+
+
+
+
+
+
+
pub masters_mend: Action,
+
+
+
+
+
+
+
+
pub waste_not: Action,
+
+
+
+
+
+
+
+
pub waste_not_ii: Action,
+
+
+
+
+
+
+
+
pub manipulation: Action,
+
+
+
+
+
+
+
+
pub veneration: Action,
+
+
+
+
+
+
+
+
pub great_strides: Action,
+
+
+
+
+
+
+
+
pub innovation: Action,
+
+
+
+
+
+
+
+
//pub observe: Action,
+
+
+
+
+
+
+
+
//pub focused_synthesis: Action,
+
+
+
+
+
+
+
+
impl Default for ActionList {
+
+
+
+
+
+
+
+
fn default() -> Self {
+
+
+
+
+
+
+
+
muscle_memory: ActionBuilder::new("Muscle Memory")
+
+
+
+
+
+
+
+
.buff(Some((Buff::MuscleMemory, 5)))
+
+
+
+
+
+
+
+
reflect: ActionBuilder::new("Reflect")
+
+
+
+
+
+
+
+
.buff(Some((Buff::InnerQuiet, 1)))
+
+
+
+
+
+
+
+
basic_synthesis: ActionBuilder::new("Basic Synthesis").progress(120).build(),
+
+
+
+
+
+
+
+
careful_synthesis: ActionBuilder::new("Careful Synthesis")
+
+
+
+
+
+
+
+
groundwork: ActionBuilder::new("Groundwork")
+
+
+
+
+
+
+
+
prudent_synthesis: ActionBuilder::new("Prudent Synthesis")
+
+
+
+
+
+
+
+
delicate_synthesis: ActionBuilder::new("Delicate Synthesis")
+
+
+
+
+
+
+
+
basic_touch: ActionBuilder::new("Basic Touch")
+
+
+
+
+
+
+
+
.buff(Some((Buff::BasicTouch, 1)))
+
+
+
+
+
+
+
+
standard_touch: ActionBuilder::new("Standard Touch")
+
+
+
+
+
+
+
+
.buff(Some((Buff::StandardTouch, 1)))
+
+
+
+
+
+
+
+
byregot_blessing: ActionBuilder::new("Byregot's Blessing")
+
+
+
+
+
+
+
+
.buff(Some((Buff::InnerQuiet, 0)))
+
+
+
+
+
+
+
+
prudent_touch: ActionBuilder::new("Prudent Touch")
+
+
+
+
+
+
+
+
preparatory_touch: ActionBuilder::new("Preparatory Touch")
+
+
+
+
+
+
+
+
.buff(Some((Buff::InnerQuiet, 1)))
+
+
+
+
+
+
+
+
advanced_touch: ActionBuilder::new("Advanced Touch")
+
+
+
+
+
+
+
+
trained_finesse: ActionBuilder::new("Trained Finesse")
+
+
+
+
+
+
+
+
masters_mend: ActionBuilder::new("Master's Mend").cp(88).build(),
+
+
+
+
+
+
+
+
waste_not: ActionBuilder::new("Waste Not")
+
+
+
+
+
+
+
+
.buff(Some((Buff::WasteNot, 4)))
+
+
+
+
+
+
+
+
waste_not_ii: ActionBuilder::new("Waste Not II")
+
+
+
+
+
+
+
+
.buff(Some((Buff::WasteNot, 8)))
+
+
+
+
+
+
+
+
manipulation: ActionBuilder::new("Manipulation")
+
+
+
+
+
+
+
+
.buff(Some((Buff::Manipulation, 8)))
+
+
+
+
+
+
+
+
veneration: ActionBuilder::new("Veneration")
+
+
+
+
+
+
+
+
.buff(Some((Buff::Veneration, 4)))
+
+
+
+
+
+
+
+
great_strides: ActionBuilder::new("Great Strides")
+
+
+
+
+
+
+
+
.buff(Some((Buff::GreatStrides, 3)))
+
+
+
+
+
+
+
+
innovation: ActionBuilder::new("Innovation")
+
+
+
+
+
+
+
+
.buff(Some((Buff::Innovation, 4)))
+
+
+
+
+
+
+
+
//observe: ActionBuilder::new("observe").cp(18).buff(Some((Buff::Observe, 1))).build(),
+
+
+
+
+
+
+
+
//focused_synthesis: ActionBuilder::new("focused_synthesis").cp(18).quality(100).build(),
+
+
+
+
+
+
+
+
pub static ref ACTIONS: ActionList = ActionList::default();
+
+
+
+
+
+
diff --git a/coverage/html/src/bin/index.html b/coverage/html/src/bin/index.html
new file mode 100644
index 0000000..a54d698
--- /dev/null
+++ b/coverage/html/src/bin/index.html
@@ -0,0 +1,81 @@
+
+
+
+
+ Grcov report - src/bin
+
+
+
+
+
+
+
+
+
+ | File |
+ Line Coverage |
+ Functions |
+ Branches |
+
+
+
+ | xiv_csolver.rs |
+
+
+
+ |
+
+ 1.64%
+ |
+
+ 1 / 61
+ |
+
+ 20% |
+ 1 / 5 |
+
+ 100% |
+ 0 / 0 |
+
+
+
+
+
+
diff --git a/coverage/html/src/bin/xiv_csolver.rs.html b/coverage/html/src/bin/xiv_csolver.rs.html
new file mode 100644
index 0000000..13b048e
--- /dev/null
+++ b/coverage/html/src/bin/xiv_csolver.rs.html
@@ -0,0 +1,1216 @@
+
+
+
+
+ Grcov report - xiv_csolver.rs
+
+
+
+
+
+
+
+
+
+ 10
+
+
+
// #![warn(missing_docs,unsafe_code,unstable_features,)]
+
+
+
+
+
+
+
+
// #![feature(no_coverage)]
+
+
+
+
+
+
+
+
use std::time::Instant;
+
+
+
+
+
+
+
+
struct CustomError(String);
+
+
+
+
+
+
+
+
let args = xiv_csolver_lib::io::Args::parse();
+
+
+
+
+
+
+
+
let params = xiv_csolver_lib::io::Parameters::from_args(&args);
+
+
+
+
+
+
+
+
let now = Instant::now();
+
+
+
+
+
+
+
+
println!("Solving...");
+
+
+
+
+
+
+
+
let (recipe, stats) =
+
+
+
+
+
+
+
+
xiv_csolver_lib::load_from_config(&args.recipe_name, &args.file_name, &args.character_name);
+
+
+
+
+
+
+
+
let results = xiv_csolver_lib::solve_craft(recipe, stats, params);
+
+
+
+
+
+
+
+
let t_final = now.elapsed().as_millis();
+
+
+
+
+
+
+
+
// Show best result depending on selected value
+
+
+
+
+
+
+
+
"[Error] No solutions found for craft '{}' with crafter '{}' (ms)",
+
+
+
+
+
+
+
+
args.recipe_name, args.character_name
+
+
+
+
+
+
+
+
if args.verbose > 0 {
+
+
+
+
+
+
+
+
println!("[Final] {} results were found:", res.len());
+
+
+
+
+
+
+
+
#[cfg(feature = "verbose")]
+
+
+
+
+
+
+
+
if args.verbose > 1 {
+
+
+
+
+
+
+
+
xiv_csolver_lib::print_routes(&results);
+
+
+
+
+
+
+
+
println!("\n > SOLUTION [Least steps] <");
+
+
+
+
+
+
+
+
xiv_csolver_lib::find_fast_route(&results)
+
+
+
+
+
+
+
+
println!("\n > SOLUTION [Most durability] <");
+
+
+
+
+
+
+
+
xiv_csolver_lib::find_safe_route(&results)
+
+
+
+
+
+
+
+
println!("\n > SOLUTION [Most quality] < ");
+
+
+
+
+
+
+
+
xiv_csolver_lib::find_quality_route(&results)
+
+
+
+
+
+
+
+
// #[cfg(feature = "verbose")]
+
+
+
+
+
+
+
+
// if params.verbose>2{
+
+
+
+
+
+
+
+
// println!("[F] Top routes {:?}",results);
+
+
+
+
+
+
+
+
// Wait for user input
+
+
+
+
+
+
+
+
"\nProgram finished successfully in {}ms\nPress enter to exit...",
+
+
+
+
+
+
+
+
let mut input = String::new();
+
+
+
+
+
+
+
+
std::io::stdin().read_line(&mut input).unwrap();
+
+
+
+
+
+
diff --git a/coverage/html/src/craft.rs.html b/coverage/html/src/craft.rs.html
new file mode 100644
index 0000000..7b9b7b3
--- /dev/null
+++ b/coverage/html/src/craft.rs.html
@@ -0,0 +1,2400 @@
+
+
+
+
+ Grcov report - craft.rs
+
+
+
+
+
+
+
+
+
+
+
+
+
use crate::action::Action;
+
+
+
+
+
+
+
+
use crate::specs::{Buff, BuffState, Recipe, Stats, Success};
+
+
+
+
+
+
+
+
use crate::Parameters;
+
+
+
+
+
+
+
+
use std::fmt::{Debug, Display, Formatter};
+
+
+
+
+
+
+
+
pub struct Craft<'a> {
+
+
+
+
+
+
+
+
pub buffs: BuffState,
+
+
+
+
+
+
+
+
pub progression: u32,
+
+
+
+
+
+
+
+
pub success: Success,
+
+
+
+
+
+
+
+
pub actions: Vec<&'a Action>,
+
+
+
+
+
+
+
+
pub args: Parameters,
+
+
+
+
+
+
+
+
pub fn new(recipe: Recipe, stats: Stats, params: Parameters) -> Craft<'a> {
+
+
+
+
+
+
+
+
buffs: BuffState::default(),
+
+
+
+
+
+
+
+
durability: recipe.durability as i32,
+
+
+
+
+
+
+
+
cp: stats.max_cp as i32,
+
+
+
+
+
+
+
+
success: Success::Pending,
+
+
+
+
+
+
+
+
pub fn get_base_progression(&self) -> u32 {
+
+
+
+
+
+
+
+
let base_value = (self.stats.craftsmanship as f64 / 10.0)
+
+
+
+
+
+
+
+
/ (self.recipe.progress_divider as f64 / 100.0)
+
+
+
+
+
+
+
+
(base_value * (self.recipe.progress_modifier as f64 / 100.0) as f64).floor() as u32
+
+
+
+
+
+
+
+
pub fn get_base_quality(&self) -> u32 {
+
+
+
+
+
+
+
+
let base_value = (self.stats.control as f64 / 10.0)
+
+
+
+
+
+
+
+
/ (self.recipe.quality_divider as f64 / 100.0)
+
+
+
+
+
+
+
+
(base_value * (self.recipe.quality_modifier as f64 / 100.0) as f64).floor() as u32
+
+
+
+
+
+
+
+
pub fn run_action(&mut self, action: &'a Action) -> &mut Craft<'a> {
+
+
+
+
+
+
+
+
if !action.can_use(self) {
+
+
+
+
+
+
+
+
self.success = Success::Failure;
+
+
+
+
+
+
+
+
self.step_count += 1;
+
+
+
+
+
+
+
+
self.cp -= action.get_cp_cost(self) as i32;
+
+
+
+
+
+
+
+
self.durability -= action.get_durability_cost(self) as i32;
+
+
+
+
+
+
+
+
self.progression += (action.get_progress(self) as f64
+
+
+
+
+
+
+
+
* (self.get_base_progression() as f64 / 100.0))
+
+
+
+
+
+
+
+
self.quality += (action.get_quality(self) as f64 * (self.get_base_quality() as f64 / 100.0))
+
+
+
+
+
+
+
+
if self.progression >= self.recipe.progress {
+
+
+
+
+
+
+
+
self.success = Success::Success;
+
+
+
+
+
+
+
+
if self.durability <= 0 {
+
+
+
+
+
+
+
+
self.success = Success::Failure;
+
+
+
+
+
+
+
+
if self.buffs.manipulation > 0 {
+
+
+
+
+
+
+
+
self.durability += 5;
+
+
+
+
+
+
+
+
if action.quality > 0 {
+
+
+
+
+
+
+
+
self.buffs.inner_quiet += 1;
+
+
+
+
+
+
+
+
if action.progress > 0 {
+
+
+
+
+
+
+
+
self.buffs.remove(Buff::MuscleMemory);
+
+
+
+
+
+
+
+
if action.quality > 0 {
+
+
+
+
+
+
+
+
self.buffs.remove(Buff::GreatStrides);
+
+
+
+
+
+
+
+
if let Some((buff, duration)) = action.get_buff() {
+
+
+
+
+
+
+
+
self.buffs.apply(buff, duration);
+
+
+
+
+
+
+
+
if self.durability > self.recipe.durability as i32 {
+
+
+
+
+
+
+
+
self.durability = self.recipe.durability as i32;
+
+
+
+
+
+
+
+
if self.buffs.inner_quiet > 10 {
+
+
+
+
+
+
+
+
self.buffs.inner_quiet = 10;
+
+
+
+
+
+
+
+
self.actions.push(action);
+
+
+
+
+
+
+
+
// Assumes the craft is finished and tries to add the last actions
+
+
+
+
+
+
+
+
// pub fn add_last_actions(&mut self)->&Self{
+
+
+
+
+
+
+
+
// let arg = (self.recipe.progress as f32 - self.progression as f32) / self.get_base_progression() as f32;
+
+
+
+
+
+
+
+
// self.durability+=10;
+
+
+
+
+
+
+
+
// if 0.0 < arg && arg < 1.2 { self.run_action(&ACTIONS.basic_synthesis);}
+
+
+
+
+
+
+
+
// if 1.2 <= arg && arg < 1.8 { self.cp+=7; self.run_action(&ACTIONS.careful_synthesis); }
+
+
+
+
+
+
+
+
// if 1.8 <= arg && arg < 2.0 {
+
+
+
+
+
+
+
+
// self.run_action(&ACTIONS.observe);
+
+
+
+
+
+
+
+
// self.run_action(&ACTIONS.focused_synthesis);
+
+
+
+
+
+
+
+
impl<'a> Debug for Craft<'a> {
+
+
+
+
+
+
+
+
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+
+
+
+
+
+
+
+
let mut binding = f.debug_struct("");
+
+
+
+
+
+
+
+
.field("step_count", &self.step_count)
+
+
+
+
+
+
+
+
.field("progression", &format!("{:?}/{:?}", &self.progression, &self.recipe.progress))
+
+
+
+
+
+
+
+
.field("quality", &format!("{:?}/{:?}", &self.quality, &self.recipe.quality))
+
+
+
+
+
+
+
+
.field("durability", &format!("{:?}/{:?}", &self.durability, &self.recipe.durability))
+
+
+
+
+
+
+
+
// .field("cp", &format!("{:?}/{:?}", &self.cp, &self.stats.max_cp))
+
+
+
+
+
+
+
+
binding.field("actions", &self.actions);
+
+
+
+
+
+
+
+
impl<'a> Display for Craft<'a> {
+
+
+
+
+
+
+
+
fn fmt(&self, f: &mut Formatter) -> std::fmt::Result {
+
+
+
+
+
+
+
+
f.debug_struct("Craft")
+
+
+
+
+
+
+
+
.field("step_count", &self.step_count)
+
+
+
+
+
+
+
+
&format!("{:?}/{:?}", &self.progression, &self.recipe.progress),
+
+
+
+
+
+
+
+
&format!("{:?}/{:?}", &self.quality, &self.recipe.quality),
+
+
+
+
+
+
+
+
&format!("{:?}/{:?}", &self.durability, &self.recipe.durability),
+
+
+
+
+
+
+
+
.field("cp", &format!("{:?}/{:?}", &self.cp, &self.stats.max_cp))
+
+
+
+
+
+
diff --git a/coverage/html/src/index.html b/coverage/html/src/index.html
new file mode 100644
index 0000000..9e7cef8
--- /dev/null
+++ b/coverage/html/src/index.html
@@ -0,0 +1,201 @@
+
+
+
+
+ Grcov report - src
+
+
+
+
+
+
+
+
+
+ | File |
+ Line Coverage |
+ Functions |
+ Branches |
+
+
+
+ | action.rs |
+
+
+
+ |
+
+ 0%
+ |
+
+ 0 / 239
+ |
+
+ 0% |
+ 0 / 36 |
+
+ 100% |
+ 0 / 0 |
+
+
+ | craft.rs |
+
+
+
+ |
+
+ 0%
+ |
+
+ 0 / 102
+ |
+
+ 0% |
+ 0 / 14 |
+
+ 100% |
+ 0 / 0 |
+
+
+ | io.rs |
+
+
+
+ |
+
+ 53.77%
+ |
+
+ 114 / 212
+ |
+
+ 13.4% |
+ 28 / 209 |
+
+ 100% |
+ 0 / 0 |
+
+
+ | lib.rs |
+
+
+
+ |
+
+ 0.43%
+ |
+
+ 1 / 230
+ |
+
+ 4.76% |
+ 1 / 21 |
+
+ 100% |
+ 0 / 0 |
+
+
+ | solver.rs |
+
+
+
+ |
+
+ 0%
+ |
+
+ 0 / 203
+ |
+
+ 0% |
+ 0 / 12 |
+
+ 100% |
+ 0 / 0 |
+
+
+ | specs.rs |
+
+
+
+ |
+
+ 0%
+ |
+
+ 0 / 75
+ |
+
+ 0% |
+ 0 / 48 |
+
+ 100% |
+ 0 / 0 |
+
+
+
+
+
+
diff --git a/coverage/html/src/io.rs.html b/coverage/html/src/io.rs.html
new file mode 100644
index 0000000..73e67bc
--- /dev/null
+++ b/coverage/html/src/io.rs.html
@@ -0,0 +1,5296 @@
+
+
+
+
+ Grcov report - io.rs
+
+
+
+
+
+
+
+
+
+
+
+
+
use core::fmt::Display;
+
+
+
+
+
+
+
+
// #[cfg(not(feature = "no_python"))]
+
+
+
+
+
+
+
+
use pyo3::prelude::*;
+
+
+
+
+ 12
+
+
+
#[derive(Debug, Clone, Copy)]
+
+
+
+
+
+
+
+
pub struct Parameters {
+
+
+
+
+
+
+
+
pub byregot_step: u8,
+
+
+
+
+ 32
+
+
+
#[derive(Parser, Debug, Clone)]
+
+
+
+
+
+
+
+
#[command(author, version, about, long_about = None)]
+
+
+
+
+
+
+
+
/// Name of the receipe
+
+
+
+
+ 6
+
+
+
#[arg(short, long, default_value_t = String::from("default_recipe"))]
+
+
+
+
+
+
+
+
pub recipe_name: String,
+
+
+
+
+
+
+
+
/// Name of the character
+
+
+
+
+ 6
+
+
+
#[arg(short, long, default_value_t = String::from("default_character"))]
+
+
+
+
+
+
+
+
pub character_name: String,
+
+
+
+
+ 6
+
+
+
#[arg(short, long, default_value_t = String::from("craft.toml"))]
+
+
+
+
+
+
+
+
pub file_name: String,
+
+
+
+
+
+
+
+
#[arg(short, long, action = clap::ArgAction::Count)]
+
+
+
+
+
+
+
+
/// The depth of the first pass
+
+
+
+
+ 6
+
+
+
#[arg(short, long, default_value_t = 8)]
+
+
+
+
+
+
+
+
/// Thread counts, default is 4
+
+
+
+
+ 6
+
+
+
#[arg(short, long, default_value_t = 4)]
+
+
+
+
+
+
+
+
/// Desperate mode, will try to finish the craft above all
+
+
+
+
+ 6
+
+
+
#[arg(short = 'D', long, default_value_t = false)]
+
+
+
+
+
+
+
+
/// Long mode, will try to find more solutions, at the expense of time
+
+
+
+
+ 6
+
+
+
#[arg(short = 'l', long, default_value_t = false)]
+
+
+
+
+
+
+
+
/// A final stripped down version of a craft
+
+
+
+
+
+
+
+
/// used for final print and talking with python
+
+
+
+
+
+
+
+
pub struct SolverResult {
+
+
+
+
+
+
+
+
pub progression: u32,
+
+
+
+
+
+
+
+
pub total_progression: u32,
+
+
+
+
+
+
+
+
pub total_quality: u32,
+
+
+
+
+
+
+
+
pub total_durability: u32,
+
+
+
+
+
+
+
+
pub actions: Vec<String>,
+
+
+
+
+
+
+
+
pub step1_solutions: usize,
+
+
+
+
+
+
+
+
pub step2_solutions: usize,
+
+
+
+
+
+
+
+
pub found_100_percent: bool,
+
+
+
+
+
+
+
+
/// Pretty display for SolverResult
+
+
+
+
+
+
+
+
impl Display for SolverResult {
+
+
+
+
+ 26
+
+
+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
+
+
+
+
+ 26
+
+
+
write!(f, "{:?}", self.actions)
+
+
+
+
+
+
+
+
step1_solutions: usize,
+
+
+
+
+
+
+
+
step2_solutions: usize,
+
+
+
+
+
+
+
+
found_100_percent: bool,
+
+
+
+
+
+
+
+
let mut actions = craft
+
+
+
+
+
+
+
+
.map(|action| format!("{}", action.short_name))
+
+
+
+
+
+
+
+
.collect::<Vec<String>>();
+
+
+
+
+
+
+
+
let arg = (craft.recipe.progress as f32 - craft.progression as f32)
+
+
+
+
+
+
+
+
/ craft.get_base_progression() as f32;
+
+
+
+
+
+
+
+
if 0.0 < arg && arg < 1.2 {
+
+
+
+
+
+
+
+
actions.push("basicSynth2".to_string());
+
+
+
+
+
+
+
+
if 1.2 <= arg && arg < 1.8 {
+
+
+
+
+
+
+
+
actions.push("carefulSynthesis".to_string());
+
+
+
+
+
+
+
+
if 1.8 <= arg && arg < 2.0 {
+
+
+
+
+
+
+
+
actions.push("observe".to_string());
+
+
+
+
+
+
+
+
actions.push("focusedSynthesis".to_string());
+
+
+
+
+
+
+
+
steps: craft.step_count,
+
+
+
+
+
+
+
+
progression: craft.progression,
+
+
+
+
+
+
+
+
quality: craft.quality,
+
+
+
+
+
+
+
+
durability: craft.durability,
+
+
+
+
+
+
+
+
total_progression: craft.recipe.progress,
+
+
+
+
+
+
+
+
total_quality: craft.recipe.quality,
+
+
+
+
+
+
+
+
total_durability: craft.recipe.durability,
+
+
+
+
+
+
+
+
total_cp: craft.stats.max_cp,
+
+
+
+
+ 23
+
+
+
pub fn default() -> Self {
+
+
+
+
+ 23
+
+
+
total_progression: 0,
+
+
+
+
+ 23
+
+
+
actions: vec!["Act1".to_string(), "Act2".to_string()],
+
+
+
+
+ 23
+
+
+
found_100_percent: false,
+
+
+
+
+ 8
+
+
+
pub fn pretty_print(&self) {
+
+
+
+
+ 8
+
+
+
"Quality: [{}/{}] | Durability: [{}/{}] | Cp : [{}/{}] | Steps : {}",
+
+
+
+
+ 8
+
+
+
self.total_durability,
+
+
+
+
+ 8
+
+
+
println!("{:?}", self.actions);
+
+
+
+
+
+
+
+
pub fn from_args(args: &Args) -> Self {
+
+
+
+
+
+
+
+
depth: if args.desperate { 11 } else { 8 },
+
+
+
+
+
+
+
+
threads: args.threads,
+
+
+
+
+
+
+
+
verbose: args.verbose,
+
+
+
+
+
+
+
+
desperate: args.desperate,
+
+
+
+
+
+
+
+
byregot_step: if args.long { 6 } else { 8 },
+
+
+
+
+
+
+
+
////// Python Bindings //////
+
+
+
+
+
+
+
+
/// A Python module implemented in Rust.
+
+
+
+
+
+
+
+
#[cfg(not(feature = "no_python"))]
+
+
+
+
+
+
+
+
fn xiv_csolver_lib(_py: Python, m: &PyModule) -> PyResult<()> {
+
+
+
+
+
+
+
+
m.add_function(wrap_pyfunction!(test_result, m)?)?;
+
+
+
+
+
+
+
+
m.add_function(wrap_pyfunction!(solve_from_python, m)?)?;
+
+
+
+
+
+
+
+
#[cfg(not(feature = "no_python"))]
+
+
+
+
+
+
+
+
pub fn test_result() -> SolverResult {
+
+
+
+
+
+
+
+
SolverResult::default()
+
+
+
+
+
+
+
+
/// Create a stat struct stats with the base values
+
+
+
+
+
+
+
+
#[cfg(not(feature = "no_python"))]
+
+
+
+
+
+
+
+
use crate::{solve_craft, Recipe, Stats};
+
+
+
+
+
+
+
+
#[cfg(not(feature = "no_python"))]
+
+
+
+
+
+
+
+
pub fn solve_from_python(values: &PyAny) -> PyResult<Option<Vec<SolverResult>>> {
+
+
+
+
+
+
+
+
let recipe = Recipe {
+
+
+
+
+
+
+
+
durability: values.getattr("durability")?.extract()?,
+
+
+
+
+
+
+
+
progress: values.getattr("progress")?.extract()?,
+
+
+
+
+
+
+
+
progress_divider: values.getattr("progress_divider")?.extract()?,
+
+
+
+
+
+
+
+
progress_modifier: values.getattr("progress_modifier")?.extract()?,
+
+
+
+
+
+
+
+
quality: values.getattr("quality")?.extract()?,
+
+
+
+
+
+
+
+
quality_divider: values.getattr("quality_divider")?.extract()?,
+
+
+
+
+
+
+
+
quality_modifier: values.getattr("quality_modifier")?.extract()?,
+
+
+
+
+
+
+
+
craftsmanship: values.getattr("craftsmanship")?.extract()?,
+
+
+
+
+
+
+
+
control: values.getattr("control")?.extract()?,
+
+
+
+
+
+
+
+
max_cp: values.getattr("max_cp")?.extract()?,
+
+
+
+
+
+
+
+
let param = Parameters {
+
+
+
+
+
+
+
+
depth: values.getattr("depth")?.extract()?,
+
+
+
+
+
+
+
+
byregot_step: values.getattr("byregot_step")?.extract()?,
+
+
+
+
+
+
+
+
desperate: values.getattr("desperate")?.extract()?,
+
+
+
+
+
+
+
+
threads: values.getattr("threads")?.extract()?,
+
+
+
+
+
+
+
+
verbose: values.getattr("verbose")?.extract()?,
+
+
+
+
+
+
+
+
// println!("{:?} len: {:?} ",values,values.getattr("len()"));
+
+
+
+
+
+
+
+
let res = solve_craft(recipe, stats, param);
+
+
+
+
+
+
+
+
use crate::{Parameters, SolverResult};
+
+
+
+
+
+
+
+
use pretty_assertions::{assert_eq, assert_ne};
+
+
+
+
+
+
+
+
impl PartialEq for Parameters {
+
+
+
+
+ 6
+
+
+
fn eq(&self, rhs: &Parameters) -> bool {
+
+
+
+
+ 6
+
+
+
(self.byregot_step == rhs.byregot_step)
+
+
+
+
+ 6
+
+
+
& (self.depth == rhs.depth)
+
+
+
+
+ 6
+
+
+
& (self.desperate == rhs.desperate)
+
+
+
+
+ 6
+
+
+
& (self.threads == rhs.threads)
+
+
+
+
+ 6
+
+
+
pub fn test_parameters_derived_attributes() {
+
+
+
+
+ 6
+
+
+
let def = Parameters {
+
+
+
+
+ 6
+
+
+
let def3 = def2.clone();
+
+
+
+
+ 6
+
+
+
assert_eq!(def2, def3);
+
+
+
+
+ 6
+
+
+
pub fn test_display() {
+
+
+
+
+ 6
+
+
+
let def = SolverResult::default();
+
+
+
+
+ 6
+
+
+
assert_ne!(def.to_string(), "");
+
+
+
+
+ 6
+
+
+
assert_eq!(def.to_string(), "[\"Act1\", \"Act2\"]");
+
+
+
+
+ 6
+
+
+
pub fn test_debug() {
+
+
+
+
+ 6
+
+
+
let def = SolverResult::default();
+
+
+
+
+ 6
+
+
+
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 }");
+
+
+
+
+ 3
+
+
+
pub fn test_arguments() {
+
+
+
+
+ 3
+
+
+
// Create false argument parameter
+
+
+
+
+ 3
+
+
+
character_name: "Bob GZ".to_string(),
+
+
+
+
+ 3
+
+
+
file_name: "test.toml".to_string(),
+
+
+
+
+ 3
+
+
+
recipe_name: "Belladone".to_string(),
+
+
+
+
+ 3
+
+
+
// Test Custom recipe
+
+
+
+
+ 3
+
+
+
let a3 = Args::parse_from(["ultraman","-r", "recipe","-c","dan","-f","bigfile.toml","-d","45","-t","4","-D","-l","-vvv"]);
+
+
+
+
+ 3
+
+
+
let _ = Args::parse_from(["-V"]);
+
+
+
+
+ 3
+
+
+
let _ = Args::parse_from(["-H"]);
+
+
+
+
+ 3
+
+
+
assert_eq!(a3.recipe_name,"recipe");
+
+
+
+
+ 3
+
+
+
assert_eq!(a3.character_name,"dan");
+
+
+
+
+ 3
+
+
+
assert_eq!(a3.file_name,"bigfile.toml");
+
+
+
+
+ 3
+
+
+
assert_eq!(a3.verbose,3);
+
+
+
+
+ 3
+
+
+
assert_eq!(a3.depth,45);
+
+
+
+
+ 3
+
+
+
assert_eq!(a3.threads,4);
+
+
+
+
+ 3
+
+
+
assert_eq!(a3.desperate,true);
+
+
+
+
+ 3
+
+
+
assert_eq!(a3.long,true);
+
+
+
+
+
+
+
+
// Test default parameters
+
+
+
+
+ 3
+
+
+
let a4 = Args::parse_from(["bobGZ"]);
+
+
+
+
+ 3
+
+
+
assert_eq!(a4.recipe_name,"default_recipe");
+
+
+
+
+ 3
+
+
+
assert_eq!(a4.character_name,"default_character");
+
+
+
+
+ 3
+
+
+
assert_eq!(a4.file_name,"craft.toml");
+
+
+
+
+ 3
+
+
+
assert_eq!(a4.verbose,0);
+
+
+
+
+ 3
+
+
+
assert_eq!(a4.depth,8);
+
+
+
+
+ 3
+
+
+
assert_eq!(a4.threads,4);
+
+
+
+
+ 3
+
+
+
assert_eq!(a4.desperate,false);
+
+
+
+
+ 3
+
+
+
assert_eq!(a4.long,false);
+
+
+
+
+ 3
+
+
+
pub fn test_parameters() {}
+
+
+
+
+
+
diff --git a/coverage/html/src/lib.rs.html b/coverage/html/src/lib.rs.html
new file mode 100644
index 0000000..d55f9bc
--- /dev/null
+++ b/coverage/html/src/lib.rs.html
@@ -0,0 +1,4496 @@
+
+
+
+
+ Grcov report - lib.rs
+
+
+
+
+
+
+
+
+
+ 3
+
+
+
use crate::io::SolverResult;
+
+
+
+
+
+
+
+
specs::{Recipe, Stats},
+
+
+
+
+
+
+
+
use std::sync::{Arc, Mutex};
+
+
+
+
+
+
+
+
use threadpool::ThreadPool;
+
+
+
+
+
+
+
+
/// Solve the craft with given arguments, this functions calls threads and must own it's values
+
+
+
+
+
+
+
+
pub fn solve_craft<'a>(
+
+
+
+
+
+
+
+
) -> Option<Vec<SolverResult>> {
+
+
+
+
+
+
+
+
// Load the craft with given arguments
+
+
+
+
+
+
+
+
let craft = Craft::new(recipe, stats, params);
+
+
+
+
+
+
+
+
// Start a threadpool
+
+
+
+
+
+
+
+
let pool = ThreadPool::new(params.threads);
+
+
+
+
+
+
+
+
#[cfg(feature = "verbose")]
+
+
+
+
+
+
+
+
if params.verbose > 0 {
+
+
+
+
+
+
+
+
println!("[P1] Starting phase 1...");
+
+
+
+
+
+
+
+
let phase1_routes = solver::generate_routes_phase1(craft);
+
+
+
+
+
+
+
+
let nb_p1 = phase1_routes.len();
+
+
+
+
+
+
+
+
#[cfg(feature = "verbose")]
+
+
+
+
+
+
+
+
if params.verbose > 0 {
+
+
+
+
+
+
+
+
"[P1] Found {} routes, testing them all...",
+
+
+
+
+
+
+
+
if params.verbose > 1 {
+
+
+
+
+
+
+
+
for r in &phase1_routes {
+
+
+
+
+
+
+
+
"[P1] {:?} p:{}% q:{}% c:{} d:{}",
+
+
+
+
+
+
+
+
r.quality * 100 / r.recipe.quality,
+
+
+
+
+
+
+
+
// Core algorithm, fill all found routes with the best route (doesn't branch, just replace)
+
+
+
+
+
+
+
+
let arc_phase2_routes = Arc::new(Mutex::new(Vec::<Craft>::new()));
+
+
+
+
+
+
+
+
for route in phase1_routes {
+
+
+
+
+
+
+
+
let _phase2_routes = Arc::clone(&arc_phase2_routes);
+
+
+
+
+
+
+
+
pool.execute(move || {
+
+
+
+
+
+
+
+
if let Some(mut _route) = solver::generate_routes_phase2(route) {
+
+
+
+
+
+
+
+
let mut shared = _phase2_routes.lock().unwrap();
+
+
+
+
+
+
+
+
shared.append(&mut _route);
+
+
+
+
+
+
+
+
let phase2_routes = arc_phase2_routes.lock().unwrap();
+
+
+
+
+
+
+
+
let nb_p2 = phase2_routes.len();
+
+
+
+
+
+
+
+
// Drop on empty results
+
+
+
+
+
+
+
+
if phase2_routes.len() == 0 {
+
+
+
+
+
+
+
+
// Print the results if verbose
+
+
+
+
+
+
+
+
#[cfg(feature = "verbose")]
+
+
+
+
+
+
+
+
if params.verbose > 0 {
+
+
+
+
+
+
+
+
println!("[P2] Found {} solutions, sorting", phase2_routes.len());
+
+
+
+
+
+
+
+
if params.verbose > 1 {
+
+
+
+
+
+
+
+
for r in phase2_routes.iter() {
+
+
+
+
+
+
+
+
"[P2] {:?} p:{}% q:{}% d:{}",
+
+
+
+
+
+
+
+
r.progression * 100 / r.recipe.progress,
+
+
+
+
+
+
+
+
r.quality * 100 / r.recipe.quality,
+
+
+
+
+
+
+
+
// Prune the results for analysis
+
+
+
+
+
+
+
+
// let mut valid_routes : Vec<Craft> = vec![];
+
+
+
+
+
+
+
+
let mut valid_solutions: Vec<SolverResult> = vec![];
+
+
+
+
+
+
+
+
for route in phase2_routes.iter() {
+
+
+
+
+
+
+
+
if route.quality >= route.recipe.quality {
+
+
+
+
+
+
+
+
// valid_routes.push(route.clone());
+
+
+
+
+
+
+
+
valid_solutions.push(SolverResult::from_craft(route, nb_p1, nb_p2, true));
+
+
+
+
+
+
+
+
// If no craft can make it to 100% HQ, fallback to base results
+
+
+
+
+
+
+
+
if valid_solutions.len() == 0 {
+
+
+
+
+
+
+
+
for route in phase2_routes.iter() {
+
+
+
+
+
+
+
+
valid_solutions.push(SolverResult::from_craft(route, nb_p1, nb_p2, false));
+
+
+
+
+
+
+
+
Some(valid_solutions)
+
+
+
+
+
+
+
+
/// Load the config from args and make a craft from it
+
+
+
+
+
+
+
+
pub fn load_from_config<'a>(
+
+
+
+
+
+
+
+
character_name: &str,
+
+
+
+
+
+
+
+
) -> (Recipe, Stats) {
+
+
+
+
+
+
+
+
let config: toml::Value = toml::from_str(
+
+
+
+
+
+
+
+
&std::fs::read_to_string(file_name).expect(&format!("Can't open {}", file_name)),
+
+
+
+
+
+
+
+
let recp = match config.get(recipe_name) {
+
+
+
+
+
+
+
+
None => panic!("Can't find value '{}' in '{}'", recipe_name, file_name),
+
+
+
+
+
+
+
+
// Load receipe values
+
+
+
+
+
+
+
+
let recipe = Recipe {
+
+
+
+
+
+
+
+
"Can't find 'durability' in recipe '{}' on file '{}'",
+
+
+
+
+
+
+
+
recipe_name, file_name
+
+
+
+
+
+
+
+
.expect("Can't convert durability as an integer") as u32,
+
+
+
+
+
+
+
+
"Can't find 'progress' in recipe '{}' on '{}'",
+
+
+
+
+
+
+
+
recipe_name, file_name
+
+
+
+
+
+
+
+
.expect("Can't convert progress as an integer") as u32,
+
+
+
+
+
+
+
+
"Can't find 'quality' in recipe '{}' on '{}'",
+
+
+
+
+
+
+
+
recipe_name, file_name
+
+
+
+
+
+
+
+
.expect("Can't convert quality as an integer") as u32,
+
+
+
+
+
+
+
+
progress_divider: recp
+
+
+
+
+
+
+
+
.get("progress_divider")
+
+
+
+
+
+
+
+
"Can't find 'progress_divider' in recipe '{}' on '{}'",
+
+
+
+
+
+
+
+
recipe_name, file_name
+
+
+
+
+
+
+
+
.expect("Can't convert progress_divider as an integer")
+
+
+
+
+
+
+
+
quality_divider: recp
+
+
+
+
+
+
+
+
.get("quality_divider")
+
+
+
+
+
+
+
+
"Can't find 'quality_divider' in recipe '{}' on '{}'",
+
+
+
+
+
+
+
+
recipe_name, file_name
+
+
+
+
+
+
+
+
.expect("Can't convert quality_divider as an integer") as u32,
+
+
+
+
+
+
+
+
progress_modifier: recp
+
+
+
+
+
+
+
+
.get("progress_modifier")
+
+
+
+
+
+
+
+
"Can't find 'progress_modifier' in recipe '{}' on '{}'",
+
+
+
+
+
+
+
+
recipe_name, file_name
+
+
+
+
+
+
+
+
.expect("Can't convert progress_modifier as an integer")
+
+
+
+
+
+
+
+
quality_modifier: recp
+
+
+
+
+
+
+
+
.get("quality_modifier")
+
+
+
+
+
+
+
+
"Can't find 'quality_modifier' in recipe '{}' on '{}'",
+
+
+
+
+
+
+
+
recipe_name, file_name
+
+
+
+
+
+
+
+
.expect("Can't convert quality_modifier as an integer")
+
+
+
+
+
+
+
+
let cfg = match config.get(character_name) {
+
+
+
+
+
+
+
+
None => panic!("Can't find '{}' in file '{}'", character_name, file_name),
+
+
+
+
+
+
+
+
.get("craftsmanship")
+
+
+
+
+
+
+
+
"Can't find 'craftsmanship' in character '{}' on file '{}'",
+
+
+
+
+
+
+
+
character_name, file_name
+
+
+
+
+
+
+
+
.expect("Can't convert craftsmanship as an integer") as u32,
+
+
+
+
+
+
+
+
"Can't find 'control' in character '{}' on file '{}'",
+
+
+
+
+
+
+
+
character_name, file_name
+
+
+
+
+
+
+
+
.expect("Can't convert control as an integer") as u32,
+
+
+
+
+
+
+
+
"Can't find 'max_cp' in character '{}' on file '{}'",
+
+
+
+
+
+
+
+
character_name, file_name
+
+
+
+
+
+
+
+
.expect("Can't convert max_cp as an integer") as u32,
+
+
+
+
+
+
+
+
/// Print all routes in the vect, verbose
+
+
+
+
+
+
+
+
pub fn print_routes<'a>(routes: &Option<Vec<SolverResult>>) {
+
+
+
+
+
+
+
+
println!("Showing {} routes", r.len());
+
+
+
+
+
+
+
+
"\n[{}¤][{}@][{}#] {:?} ",
+
+
+
+
+
+
+
+
c.quality, c.durability, c.steps, c.actions
+
+
+
+
+
+
+
+
None => println!("No routes to print"),
+
+
+
+
+
+
+
+
/// Find the route with the least amount of steps
+
+
+
+
+
+
+
+
pub fn find_fast_route(routes: &Option<Vec<SolverResult>>) -> Option<&SolverResult> {
+
+
+
+
+
+
+
+
if _routes.len() > 0 {
+
+
+
+
+
+
+
+
_routes.iter().min_by_key(|key| key.steps)
+
+
+
+
+
+
+
+
/// Find the route with the maximum amount of quality
+
+
+
+
+
+
+
+
pub fn find_quality_route(routes: &Option<Vec<SolverResult>>) -> Option<&SolverResult> {
+
+
+
+
+
+
+
+
Some(_routes) => _routes.iter().max_by_key(|key| key.quality),
+
+
+
+
+
+
+
+
/// Find the route with the maximum of durability left
+
+
+
+
+
+
+
+
pub fn find_safe_route(routes: &Option<Vec<SolverResult>>) -> Option<&SolverResult> {
+
+
+
+
+
+
+
+
if _routes.len() > 0 {
+
+
+
+
+
+
+
+
_routes.iter().max_by_key(|key| key.durability)
+
+
+
+
+
+
diff --git a/coverage/html/src/solver.rs.html b/coverage/html/src/solver.rs.html
new file mode 100644
index 0000000..7763686
--- /dev/null
+++ b/coverage/html/src/solver.rs.html
@@ -0,0 +1,3952 @@
+
+
+
+
+ Grcov report - solver.rs
+
+
+
+
+
+
+
+
+
+
+
+
+
use crate::action::{Action, ACTIONS};
+
+
+
+
+
+
+
+
use crate::craft::Craft;
+
+
+
+
+
+
+
+
use crate::specs::Success;
+
+
+
+
+
+
+
+
use std::collections::VecDeque;
+
+
+
+
+
+
+
+
macro_rules! action_vec {
+
+
+
+
+
+
+
+
($($tt:expr),*) => { vec![ $(Some(&$tt),)*]};
+
+
+
+
+
+
+
+
/// Find the next authorised action for this step of the craft
+
+
+
+
+
+
+
+
pub fn next_action_picker_1<'a>(craft: &Craft<'a>) -> Vec<Option<&'a Action>> {
+
+
+
+
+
+
+
+
if craft.success != Success::Pending {
+
+
+
+
+
+
+
+
let mut available_actions = Vec::<Option<&'a Action>>::new();
+
+
+
+
+
+
+
+
let mut forbidden_actions = Vec::<Option<&'a Action>>::new();
+
+
+
+
+
+
+
+
// Optimize the first three steps for massive time save
+
+
+
+
+
+
+
+
if craft.step_count == 0 {
+
+
+
+
+
+
+
+
return action_vec![ACTIONS.muscle_memory];
+
+
+
+
+
+
+
+
if craft.step_count == 1 {
+
+
+
+
+
+
+
+
return action_vec![ACTIONS.manipulation];
+
+
+
+
+
+
+
+
// Prune some actions if not requested by --long
+
+
+
+
+
+
+
+
if craft.step_count == 2 {
+
+
+
+
+
+
+
+
return action_vec![/*ACTIONS.waste_not, ACTIONS.waste_not_ii, */ ACTIONS.veneration];
+
+
+
+
+
+
+
+
if craft.step_count == 3 {
+
+
+
+
+
+
+
+
available_actions.append(&mut action_vec![
+
+
+
+
+
+
+
+
ACTIONS.waste_not_ii /*,ACTIONS.waste_not*/
+
+
+
+
+
+
+
+
// Groundwork mostly for wn / mm
+
+
+
+
+
+
+
+
if craft.buffs.waste_not > 0 || craft.buffs.muscle_memory > 0 {
+
+
+
+
+
+
+
+
available_actions.append(&mut action_vec![ACTIONS.groundwork])
+
+
+
+
+
+
+
+
// Forbidding actions depending on buffs
+
+
+
+
+
+
+
+
if craft.buffs.muscle_memory > 0 {
+
+
+
+
+
+
+
+
forbidden_actions.append(&mut action_vec![
+
+
+
+
+
+
+
+
ACTIONS.basic_synthesis,
+
+
+
+
+
+
+
+
ACTIONS.careful_synthesis,
+
+
+
+
+
+
+
+
ACTIONS.prudent_synthesis,
+
+
+
+
+
+
+
+
ACTIONS.delicate_synthesis
+
+
+
+
+
+
+
+
if craft.buffs.waste_not > 0 {
+
+
+
+
+
+
+
+
forbidden_actions.append(&mut action_vec![ACTIONS.prudent_synthesis])
+
+
+
+
+
+
+
+
available_actions.append(&mut action_vec![
+
+
+
+
+
+
+
+
ACTIONS.basic_synthesis,
+
+
+
+
+
+
+
+
ACTIONS.careful_synthesis,
+
+
+
+
+
+
+
+
ACTIONS.prudent_synthesis,
+
+
+
+
+
+
+
+
ACTIONS.delicate_synthesis
+
+
+
+
+
+
+
+
// ACTIONS.groundwork for the --pls
+
+
+
+
+
+
+
+
if craft.args.desperate {
+
+
+
+
+
+
+
+
available_actions.append(&mut action_vec![ACTIONS.groundwork]);
+
+
+
+
+
+
+
+
// For long first run
+
+
+
+
+
+
+
+
if craft.step_count > 8 {
+
+
+
+
+
+
+
+
available_actions.append(&mut action_vec![ACTIONS.waste_not_ii, ACTIONS.waste_not])
+
+
+
+
+
+
+
+
// Pruning the actions with the forbidden ones
+
+
+
+
+
+
+
+
let mut result_actions = Vec::<Option<&'a Action>>::new();
+
+
+
+
+
+
+
+
for action in available_actions {
+
+
+
+
+
+
+
+
if !forbidden_actions.contains(&action)
+
+
+
+
+
+
+
+
&& action.unwrap().can_use(&craft)
+
+
+
+
+
+
+
+
.any(|x| x.unwrap() == action.unwrap())
+
+
+
+
+
+
+
+
result_actions.push(action);
+
+
+
+
+
+
+
+
/// Find all routes that can finish in one more action
+
+
+
+
+
+
+
+
pub fn generate_routes_phase1<'a>(craft: Craft<'a>) -> Vec<Craft<'a>> {
+
+
+
+
+
+
+
+
let mut queue = Vec::new();
+
+
+
+
+
+
+
+
let mut routes = Vec::new();
+
+
+
+
+
+
+
+
while !queue.is_empty() {
+
+
+
+
+
+
+
+
let craft = queue.pop().unwrap();
+
+
+
+
+
+
+
+
for action in next_action_picker_1(&craft) {
+
+
+
+
+
+
+
+
let mut craft = craft.clone();
+
+
+
+
+
+
+
+
Some(a) => craft.run_action(a),
+
+
+
+
+
+
+
+
let remaining_prog = (craft.recipe.progress as f32 - craft.progression as f32)
+
+
+
+
+
+
+
+
/ craft.get_base_progression() as f32;
+
+
+
+
+
+
+
+
if remaining_prog <= 2.0 {
+
+
+
+
+
+
+
+
if remaining_prog <= 0.0 {
+
+
+
+
+
+
+
+
} else if 0.0 < remaining_prog && remaining_prog <= 1.2 {
+
+
+
+
+
+
+
+
// pass // Will finish with basicSynth2 (free)
+
+
+
+
+
+
+
+
} else if 1.2 < remaining_prog && remaining_prog <= 1.2 {
+
+
+
+
+
+
+
+
craft.cp -= 7; // Will finish with carefulSynthesis (7cp)
+
+
+
+
+
+
+
+
} else if 1.2 < remaining_prog && remaining_prog <= 2.0 {
+
+
+
+
+
+
+
+
craft.cp -= 12; // Will finish with observe+focusedSynthesis (12cp)
+
+
+
+
+
+
+
+
craft.durability -= 10; // Save the final step, since we always aim to end with -5dur, it doesn't matter
+
+
+
+
+
+
+
+
// Keep adding initial routes with several pass, we must be able to finish in one step
+
+
+
+
+
+
+
+
// 8 Seemed to be a good initial guess with enouth to use a good amount of WN / WNII to get close
+
+
+
+
+
+
+
+
// A higher value will yield more initial guesses with minimal benefits
+
+
+
+
+
+
+
+
// A lover value will yield less initial guesses and might spent too much CP to get to the required progression
+
+
+
+
+
+
+
+
if craft.step_count < craft.args.depth {
+
+
+
+
+
+
+
+
/// Find the list of authorised actions for this step
+
+
+
+
+
+
+
+
pub fn next_action_phase_2<'a>(craft: &Craft<'a>) -> Vec<Option<&'a Action>> {
+
+
+
+
+
+
+
+
let mut available_actions = vec![
+
+
+
+
+
+
+
+
&ACTIONS.basic_touch,
+
+
+
+
+
+
+
+
&ACTIONS.prudent_touch,
+
+
+
+
+
+
+
+
&ACTIONS.preparatory_touch,
+
+
+
+
+
+
+
+
let mut forbidden_actions = Vec::new();
+
+
+
+
+
+
+
+
if craft.success != Success::Pending {
+
+
+
+
+
+
+
+
if craft.buffs.innovation > 0 {
+
+
+
+
+
+
+
+
forbidden_actions.push(&ACTIONS.innovation);
+
+
+
+
+
+
+
+
if craft.buffs.inner_quiet >= 2 {
+
+
+
+
+
+
+
+
forbidden_actions.append(&mut vec![
+
+
+
+
+
+
+
+
&ACTIONS.basic_touch,
+
+
+
+
+
+
+
+
&ACTIONS.standard_touch,
+
+
+
+
+
+
+
+
&ACTIONS.advanced_touch,
+
+
+
+
+
+
+
+
&ACTIONS.trained_finesse,
+
+
+
+
+
+
+
+
&ACTIONS.prudent_touch,
+
+
+
+
+
+
+
+
&ACTIONS.preparatory_touch,
+
+
+
+
+
+
+
+
&ACTIONS.byregot_blessing,
+
+
+
+
+
+
+
+
available_actions.push(&ACTIONS.innovation);
+
+
+
+
+
+
+
+
if craft.buffs.manipulation == 0
+
+
+
+
+
+
+
+
&& craft.buffs.basic_touch == 0
+
+
+
+
+
+
+
+
&& craft.buffs.standard_touch == 0
+
+
+
+
+
+
+
+
&& craft.buffs.inner_quiet < 8
+
+
+
+
+
+
+
+
available_actions.push(&ACTIONS.manipulation);
+
+
+
+
+
+
+
+
if craft.buffs.waste_not > 0 {
+
+
+
+
+
+
+
+
available_actions.push(&ACTIONS.preparatory_touch);
+
+
+
+
+
+
+
+
forbidden_actions.push(&ACTIONS.prudent_touch);
+
+
+
+
+
+
+
+
available_actions.push(&ACTIONS.prudent_touch);
+
+
+
+
+
+
+
+
forbidden_actions.push(&ACTIONS.preparatory_touch);
+
+
+
+
+
+
+
+
if craft.buffs.basic_touch > 0 {
+
+
+
+
+
+
+
+
available_actions.push(&ACTIONS.standard_touch);
+
+
+
+
+
+
+
+
forbidden_actions.push(&ACTIONS.basic_touch);
+
+
+
+
+
+
+
+
if craft.buffs.standard_touch > 0 {
+
+
+
+
+
+
+
+
available_actions.push(&ACTIONS.advanced_touch);
+
+
+
+
+
+
+
+
forbidden_actions.push(&ACTIONS.basic_touch);
+
+
+
+
+
+
+
+
if craft.buffs.inner_quiet >= craft.args.byregot_step {
+
+
+
+
+
+
+
+
available_actions.push(&ACTIONS.trained_finesse);
+
+
+
+
+
+
+
+
available_actions.push(&ACTIONS.great_strides);
+
+
+
+
+
+
+
+
if craft.buffs.great_strides > 0 {
+
+
+
+
+
+
+
+
forbidden_actions.push(&ACTIONS.trained_finesse);
+
+
+
+
+
+
+
+
forbidden_actions.push(&ACTIONS.great_strides);
+
+
+
+
+
+
+
+
if craft.buffs.innovation > 0 {
+
+
+
+
+
+
+
+
available_actions.push(&ACTIONS.byregot_blessing);
+
+
+
+
+
+
+
+
let mut final_actions: Vec<Option<&Action>> = Vec::new();
+
+
+
+
+
+
+
+
for action in available_actions {
+
+
+
+
+
+
+
+
if !forbidden_actions.contains(&action)
+
+
+
+
+
+
+
+
&& !final_actions.iter().any(|a| a.unwrap() == action)
+
+
+
+
+
+
+
+
final_actions.push(Some(action));
+
+
+
+
+
+
+
+
/// Apply all actions to the current route
+
+
+
+
+
+
+
+
pub fn generate_routes_phase2<'a>(craft: Craft<'a>) -> Option<Vec<Craft<'a>>> {
+
+
+
+
+
+
+
+
let mut queue = VecDeque::new();
+
+
+
+
+
+
+
+
let mut top_route: Craft<'a> = craft.clone(); // Default route, no hq on that one
+
+
+
+
+
+
+
+
let mut top_routes: Vec<Craft<'a>> = vec![];
+
+
+
+
+
+
+
+
queue.push_back(craft);
+
+
+
+
+
+
+
+
while !queue.is_empty() {
+
+
+
+
+
+
+
+
let _craft = queue.pop_front().unwrap();
+
+
+
+
+
+
+
+
for action in next_action_phase_2(&_craft) {
+
+
+
+
+
+
+
+
if _craft.success != Success::Pending
+
+
+
+
+
+
+
+
|| !action.unwrap().can_use(&_craft)
+
+
+
+
+
+
+
+
let mut craft = _craft.clone();
+
+
+
+
+
+
+
+
craft.run_action(action.unwrap());
+
+
+
+
+
+
+
+
if action.unwrap() == &ACTIONS.byregot_blessing {
+
+
+
+
+
+
+
+
#[cfg(not(feature = "fast"))]
+
+
+
+
+
+
+
+
if top_route.quality >= craft.recipe.quality {
+
+
+
+
+
+
+
+
top_routes.push(craft.clone()); // Me memory
+
+
+
+
+
+
+
+
if top_route.quality < craft.quality {
+
+
+
+
+
+
+
+
#[cfg(feature = "fast")]
+
+
+
+
+
+
+
+
top_routes.push(craft.clone());
+
+
+
+
+
+
+
+
queue.push_back(craft);
+
+
+
+
+
+
+
+
// Let's not forget the best result
+
+
+
+
+
+
+
+
top_routes.push(top_route);
+
+
+
+
+
+
diff --git a/coverage/html/src/specs.rs.html b/coverage/html/src/specs.rs.html
new file mode 100644
index 0000000..93a3392
--- /dev/null
+++ b/coverage/html/src/specs.rs.html
@@ -0,0 +1,2224 @@
+
+
+
+
+ Grcov report - specs.rs
+
+
+
+
+
+
+
+
+
+
+
+
+
use strum_macros::EnumIter;
+
+
+
+
+
+
+
+
#[derive(Debug, Clone, Copy)]
+
+
+
+
+
+
+
+
pub progress_divider: u32,
+
+
+
+
+
+
+
+
pub quality_divider: u32,
+
+
+
+
+
+
+
+
pub progress_modifier: u32,
+
+
+
+
+
+
+
+
pub quality_modifier: u32,
+
+
+
+
+
+
+
+
#[derive(Debug, Clone, Copy)]
+
+
+
+
+
+
+
+
pub craftsmanship: u32,
+
+
+
+
+
+
+
+
#[derive(Debug, Clone, Copy, PartialEq, EnumIter)]
+
+
+
+
+
+
+
+
#[derive(Debug, Clone, Copy)]
+
+
+
+
+
+
+
+
pub struct BuffState {
+
+
+
+
+
+
+
+
pub great_strides: u8,
+
+
+
+
+
+
+
+
pub manipulation: u8,
+
+
+
+
+
+
+
+
pub muscle_memory: u8,
+
+
+
+
+
+
+
+
pub standard_touch: u8,
+
+
+
+
+
+
+
+
pub fn default() -> Self {
+
+
+
+
+
+
+
+
pub fn remove(&mut self, buff: Buff) {
+
+
+
+
+
+
+
+
Buff::InnerQuiet => self.inner_quiet = 0,
+
+
+
+
+
+
+
+
Buff::WasteNot => self.waste_not = 0,
+
+
+
+
+
+
+
+
Buff::GreatStrides => self.great_strides = 0,
+
+
+
+
+
+
+
+
Buff::Innovation => self.innovation = 0,
+
+
+
+
+
+
+
+
Buff::Veneration => self.veneration = 0,
+
+
+
+
+
+
+
+
Buff::Manipulation => self.manipulation = 0,
+
+
+
+
+
+
+
+
Buff::MuscleMemory => self.muscle_memory = 0,
+
+
+
+
+
+
+
+
Buff::BasicTouch => self.basic_touch = 0,
+
+
+
+
+
+
+
+
Buff::StandardTouch => self.standard_touch = 0,
+
+
+
+
+
+
+
+
Buff::Observe => self.observe = 0,
+
+
+
+
+
+
+
+
pub fn apply(&mut self, buff: Buff, value: u8) {
+
+
+
+
+
+
+
+
Buff::InnerQuiet => {
+
+
+
+
+
+
+
+
self.inner_quiet = 0;
+
+
+
+
+
+
+
+
self.inner_quiet += value;
+
+
+
+
+
+
+
+
Buff::WasteNot => self.waste_not = value,
+
+
+
+
+
+
+
+
Buff::GreatStrides => self.great_strides = value,
+
+
+
+
+
+
+
+
Buff::Innovation => self.innovation = value,
+
+
+
+
+
+
+
+
Buff::Veneration => self.veneration = value,
+
+
+
+
+
+
+
+
Buff::Manipulation => self.manipulation = value,
+
+
+
+
+
+
+
+
Buff::MuscleMemory => self.muscle_memory = value,
+
+
+
+
+
+
+
+
Buff::BasicTouch => self.basic_touch = value,
+
+
+
+
+
+
+
+
Buff::StandardTouch => self.standard_touch = value,
+
+
+
+
+
+
+
+
Buff::Observe => self.standard_touch = value,
+
+
+
+
+
+
+
+
pub fn tick(&mut self) {
+
+
+
+
+
+
+
+
if self.waste_not > 0 {
+
+
+
+
+
+
+
+
if self.great_strides > 0 {
+
+
+
+
+
+
+
+
self.great_strides -= 1;
+
+
+
+
+
+
+
+
if self.innovation > 0 {
+
+
+
+
+
+
+
+
self.innovation -= 1;
+
+
+
+
+
+
+
+
if self.veneration > 0 {
+
+
+
+
+
+
+
+
self.veneration -= 1;
+
+
+
+
+
+
+
+
if self.manipulation > 0 {
+
+
+
+
+
+
+
+
self.manipulation -= 1;
+
+
+
+
+
+
+
+
if self.muscle_memory > 0 {
+
+
+
+
+
+
+
+
self.muscle_memory -= 1;
+
+
+
+
+
+
+
+
if self.basic_touch > 0 {
+
+
+
+
+
+
+
+
self.basic_touch -= 1;
+
+
+
+
+
+
+
+
if self.standard_touch > 0 {
+
+
+
+
+
+
+
+
self.standard_touch -= 1;
+
+
+
+
+
+
+
+
#[derive(Debug, Clone, Copy, PartialEq)]
+
+
+
+
+
+
diff --git a/coverage/html/tests/index.html b/coverage/html/tests/index.html
new file mode 100644
index 0000000..98978b6
--- /dev/null
+++ b/coverage/html/tests/index.html
@@ -0,0 +1,105 @@
+
+
+
+
+ Grcov report - tests
+
+
+
+
+
+
+
+
+
+ | File |
+ Line Coverage |
+ Functions |
+ Branches |
+
+
+
+ | io.rs |
+
+
+
+ |
+
+ 100%
+ |
+
+ 1 / 1
+ |
+
+ 100% |
+ 1 / 1 |
+
+ 100% |
+ 0 / 0 |
+
+
+ | lib.rs |
+
+
+
+ |
+
+ 100%
+ |
+
+ 1 / 1
+ |
+
+ 100% |
+ 1 / 1 |
+
+ 100% |
+ 0 / 0 |
+
+
+
+
+
+
diff --git a/coverage/html/tests/io.rs.html b/coverage/html/tests/io.rs.html
new file mode 100644
index 0000000..5e481f6
--- /dev/null
+++ b/coverage/html/tests/io.rs.html
@@ -0,0 +1,64 @@
+
+
+
+
+ Grcov report - io.rs
+
+
+
+
+
+
+
+
+
+
+
diff --git a/coverage/html/tests/lib.rs.html b/coverage/html/tests/lib.rs.html
new file mode 100644
index 0000000..d3dcf4b
--- /dev/null
+++ b/coverage/html/tests/lib.rs.html
@@ -0,0 +1,64 @@
+
+
+
+
+ Grcov report - lib.rs
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/bin/xiv_csolver.rs b/src/bin/xiv_csolver.rs
index de9c789..dc1cb4a 100644
--- a/src/bin/xiv_csolver.rs
+++ b/src/bin/xiv_csolver.rs
@@ -1,4 +1,5 @@
// #![warn(missing_docs,unsafe_code,unstable_features,)]
+// #![feature(no_coverage)]
use clap::Parser;
use std::time::Instant;
diff --git a/src/io.rs b/src/io.rs
index 83457d4..c004308 100644
--- a/src/io.rs
+++ b/src/io.rs
@@ -85,9 +85,8 @@ pub struct SolverResult {
/// Pretty display for SolverResult
impl Display for SolverResult {
- fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
- println!("{:?}", self.actions);
- Ok(())
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
+ write!(f, "{:?}", self.actions)
}
}
@@ -238,3 +237,92 @@ pub fn solve_from_python(values: &PyAny) -> PyResult