Test(Coverage) - Adds solver coverage and fixes tests/ folder being there

This commit is contained in:
Dandaedre 2023-03-08 06:14:17 +01:00
parent 539a14a4fc
commit 406bc0e515
10 changed files with 450 additions and 282 deletions

View File

@ -1,6 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" width="96" height="20" role="img" aria-label="coverage: 69%">
<title>coverage: 69%</title>
xmlns:xlink="http://www.w3.org/1999/xlink" width="96" height="20" role="img" aria-label="coverage: 77%">
<title>coverage: 77%</title>
<linearGradient id="s" x2="0" y2="100%">
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
<stop offset="1" stop-opacity=".1"/>
@ -10,14 +10,14 @@
</clipPath>
<g clip-path="url(#r)">
<rect width="61" height="20" fill="#555"/>
<rect x="61" width="35" height="20" fill="#e05d44"/>
<rect x="61" width="35" height="20" fill="#dfb317"/>
<rect width="96" height="20" fill="url(#s)"/>
</g>
<g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110">
<text aria-hidden="true" x="315" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="510">coverage</text>
<text x="315" y="140" transform="scale(.1)" fill="#fff" textLength="510">coverage</text>
<text aria-hidden="true" x="775" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="250">69%</text>
<text x="775" y="140" transform="scale(.1)" fill="#fff" textLength="250">69%</text>
<text aria-hidden="true" x="775" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="250">77%</text>
<text x="775" y="140" transform="scale(.1)" fill="#fff" textLength="250">77%</text>
</g>
<script xmlns=""/>
</svg>

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -1,13 +1,13 @@
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" width="96" height="20" role="img" aria-label="coverage: 69%">
<title>coverage: 69%</title>
xmlns:xlink="http://www.w3.org/1999/xlink" width="96" height="20" role="img" aria-label="coverage: 77%">
<title>coverage: 77%</title>
<g shape-rendering="crispEdges">
<rect width="61" height="20" fill="#555"/>
<rect x="61" width="35" height="20" fill="#e05d44"/>
<rect x="61" width="35" height="20" fill="#dfb317"/>
</g>
<g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110">
<text x="315" y="140" transform="scale(.1)" fill="#fff" textLength="510">coverage</text>
<text x="775" y="140" transform="scale(.1)" fill="#fff" textLength="250">69%</text>
<text x="775" y="140" transform="scale(.1)" fill="#fff" textLength="250">77%</text>
</g>
<script xmlns=""/>
</svg>

Before

Width:  |  Height:  |  Size: 712 B

After

Width:  |  Height:  |  Size: 712 B

View File

@ -1,13 +1,13 @@
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" width="142.5" height="28" role="img" aria-label="COVERAGE: 69%">
<title>COVERAGE: 69%</title>
xmlns:xlink="http://www.w3.org/1999/xlink" width="142.5" height="28" role="img" aria-label="COVERAGE: 77%">
<title>COVERAGE: 77%</title>
<g shape-rendering="crispEdges">
<rect width="91" height="28" fill="#555"/>
<rect x="91" width="51.5" height="28" fill="#e05d44"/>
<rect x="91" width="51.5" height="28" fill="#dfb317"/>
</g>
<g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="100">
<text fill="#fff" x="455" y="175" transform="scale(.1)" textLength="670">COVERAGE</text>
<text fill="#fff" x="1167.5" y="175" font-weight="bold" transform="scale(.1)" textLength="275">69%</text>
<text fill="#fff" x="1167.5" y="175" font-weight="bold" transform="scale(.1)" textLength="275">77%</text>
</g>
<script xmlns=""/>
</svg>

Before

Width:  |  Height:  |  Size: 739 B

After

Width:  |  Height:  |  Size: 739 B

View File

@ -1,6 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" width="96" height="18" role="img" aria-label="coverage: 69%">
<title>coverage: 69%</title>
xmlns:xlink="http://www.w3.org/1999/xlink" width="96" height="18" role="img" aria-label="coverage: 77%">
<title>coverage: 77%</title>
<linearGradient id="s" x2="0" y2="100%">
<stop offset="0" stop-color="#fff" stop-opacity=".7"/>
<stop offset=".1" stop-color="#aaa" stop-opacity=".1"/>
@ -12,14 +12,14 @@
</clipPath>
<g clip-path="url(#r)">
<rect width="61" height="18" fill="#555"/>
<rect x="61" width="35" height="18" fill="#e05d44"/>
<rect x="61" width="35" height="18" fill="#dfb317"/>
<rect width="96" height="18" fill="url(#s)"/>
</g>
<g fill="#fff" text-anchor="middle" font-family="Verdana,Geneva,DejaVu Sans,sans-serif" text-rendering="geometricPrecision" font-size="110">
<text aria-hidden="true" x="315" y="140" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="510">coverage</text>
<text x="315" y="130" transform="scale(.1)" fill="#fff" textLength="510">coverage</text>
<text aria-hidden="true" x="775" y="140" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="250">69%</text>
<text x="775" y="130" transform="scale(.1)" fill="#fff" textLength="250">69%</text>
<text aria-hidden="true" x="775" y="140" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="250">77%</text>
<text x="775" y="130" transform="scale(.1)" fill="#fff" textLength="250">77%</text>
</g>
<script xmlns=""/>
</svg>

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -1,6 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" width="99" height="20" role="img" aria-label="Coverage: 69%">
<title>Coverage: 69%</title>
xmlns:xlink="http://www.w3.org/1999/xlink" width="99" height="20" role="img" aria-label="Coverage: 77%">
<title>Coverage: 77%</title>
<style>a:hover #llink{fill:url(#b);stroke:#ccc}a:hover #rlink{fill:#4183c4}</style>
<linearGradient id="a" x2="0" y2="100%">
<stop offset="0" stop-color="#fcfcfc" stop-opacity="0"/>
@ -20,8 +20,8 @@
<rect id="llink" stroke="#d5d5d5" fill="url(#a)" x=".5" y=".5" width="61" height="19" rx="2"/>
<text aria-hidden="true" x="305" y="150" fill="#fff" transform="scale(.1)" textLength="510">Coverage</text>
<text x="305" y="140" transform="scale(.1)" textLength="510">Coverage</text>
<text aria-hidden="true" x="825" y="150" fill="#fff" transform="scale(.1)" textLength="230">69%</text>
<text id="rlink" x="825" y="140" transform="scale(.1)" textLength="230">69%</text>
<text aria-hidden="true" x="825" y="150" fill="#fff" transform="scale(.1)" textLength="230">77%</text>
<text id="rlink" x="825" y="140" transform="scale(.1)" textLength="230">77%</text>
</g>
<script xmlns=""/>
</svg>

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -211,8 +211,8 @@ impl<'a> Craft<'a> {
)
}
/// Create a "Three start" craft, testing only
pub fn three_star() -> Craft<'a> {
/// Create a "Two start" craft, testing only
pub fn two_star() -> Craft<'a> {
Self::new(
crate::specs::Recipe {
durability: 70,
@ -237,6 +237,33 @@ impl<'a> Craft<'a> {
},
)
}
/// Create a "Zero star" craft for debbuging & testing
pub fn zero_star() -> Craft<'a> {
Self::new(
crate::specs::Recipe {
durability: 70,
progress: 4000,
quality: 10920,
progress_divider: 100,
quality_divider: 100,
progress_modifier: 100,
quality_modifier: 100,
},
crate::specs::Stats {
craftsmanship: 4000,
control: 4000,
max_cp: 600,
},
crate::io::Parameters {
threads: 8,
verbose: 2,
depth: 8,
desperate: false,
byregot_step: 10,
},
)
}
}
#[cfg(test)]
@ -245,9 +272,9 @@ mod test {
// Struct Test
#[test]
pub fn struct_tests() {
let craft = crate::craft::Craft::default().clone();
assert_eq!(craft.get_base_progression(), 22);
assert_eq!(craft.get_base_quality(), 55);
let craft = crate::craft::Craft::zero_star().clone();
assert_eq!(craft.get_base_progression(), 402);
assert_eq!(craft.get_base_quality(), 435);
format!("{}", craft);
format!("{:?}", craft);

View File

@ -108,9 +108,10 @@ pub fn generate_routes_phase1<'a>(craft: Craft<'a>) -> Vec<Craft<'a>> {
continue;
} 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 {
// TODO: Test replacing this value with 1.8 that should be the correct value but hasnt be tested
// } else if 1.2 < remaining_prog && remaining_prog <= 1.4 {
// craft.cp -= 7; // Will finish with carefulSynthesis (7cp)
} else if 1.4 < 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
@ -247,253 +248,4 @@ pub fn generate_routes_phase2<'a>(craft: Craft<'a>) -> Option<Vec<Craft<'a>>> {
Some(top_routes)
}
#[cfg(test)]
mod test {
use crate::solver::{generate_routes_phase1, next_action_picker_1, ACTIONS};
#[test]
pub fn test_first_step() {
let mut craft = crate::craft::Craft::three_star();
// Try a failed craft
craft.success = crate::specs::Success::Failure;
let vact = next_action_picker_1(&craft);
assert_eq!(vact, vec![None]);
craft.success = crate::specs::Success::Pending;
// Try the first 4 steps
let vact = next_action_picker_1(&craft);
assert_eq!(vact, action_vec![ACTIONS.muscle_memory]);
craft.run_action(&ACTIONS.muscle_memory);
let vact = next_action_picker_1(&craft);
assert_eq!(vact, action_vec![ACTIONS.manipulation]);
craft.run_action(&ACTIONS.manipulation);
let vact = next_action_picker_1(&craft);
assert_eq!(vact, action_vec![ACTIONS.veneration]);
craft.run_action(&ACTIONS.veneration);
let vact = next_action_picker_1(&craft);
assert_eq!(vact, action_vec![ACTIONS.waste_not_ii, ACTIONS.groundwork]);
craft.run_action(&ACTIONS.waste_not_ii);
// Try the steps 5-8, deterministically
let vact = next_action_picker_1(&craft);
assert_eq!(vact, action_vec![ACTIONS.groundwork]);
craft.run_action(&ACTIONS.careful_synthesis);
let vact = next_action_picker_1(&craft);
assert_eq!(
vact,
action_vec![
ACTIONS.groundwork,
ACTIONS.basic_synthesis,
ACTIONS.careful_synthesis,
ACTIONS.delicate_synthesis
]
);
craft.run_action(&ACTIONS.careful_synthesis);
let vact = next_action_picker_1(&craft);
assert_eq!(
vact,
action_vec![
ACTIONS.groundwork,
ACTIONS.basic_synthesis,
ACTIONS.careful_synthesis,
ACTIONS.delicate_synthesis
]
);
craft.run_action(&ACTIONS.careful_synthesis);
let vact = next_action_picker_1(&craft);
assert_eq!(
vact,
action_vec![
ACTIONS.groundwork,
ACTIONS.basic_synthesis,
ACTIONS.careful_synthesis,
ACTIONS.delicate_synthesis
]
);
craft.run_action(&ACTIONS.careful_synthesis);
// Check odd parameters
craft.buffs.waste_not = 0;
craft.progression = 0;
let vact = next_action_picker_1(&craft);
assert_eq!(
vact,
action_vec![
ACTIONS.basic_synthesis,
ACTIONS.careful_synthesis,
ACTIONS.prudent_synthesis,
ACTIONS.delicate_synthesis
]
);
craft.run_action(&ACTIONS.delicate_synthesis);
let vact = next_action_picker_1(&craft);
assert_eq!(
vact,
action_vec![
ACTIONS.basic_synthesis,
ACTIONS.careful_synthesis,
ACTIONS.prudent_synthesis,
ACTIONS.delicate_synthesis,
ACTIONS.waste_not_ii,
ACTIONS.waste_not
]
);
craft.args.desperate = true;
let vact = next_action_picker_1(&craft);
assert_eq!(
vact,
action_vec![
ACTIONS.basic_synthesis,
ACTIONS.careful_synthesis,
ACTIONS.prudent_synthesis,
ACTIONS.delicate_synthesis,
ACTIONS.groundwork,
ACTIONS.masters_mend,
ACTIONS.waste_not_ii,
ACTIONS.waste_not
]
);
}
#[test]
pub fn test_routes_p1() {
let craft = crate::craft::Craft::three_star();
let mut routes1 = generate_routes_phase1(craft);
for route in routes1.iter() {
println!("{:?}", route.actions);
}
// Literrally any change will break it
// An eq should be implmented to just check a vector of vector versus a route
assert_eq!(routes1.len(), 9);
let route = routes1.pop().unwrap();
assert_eq!(
route.actions,
vec![
&ACTIONS.muscle_memory,
&ACTIONS.manipulation,
&ACTIONS.veneration,
&ACTIONS.waste_not_ii,
&ACTIONS.groundwork,
&ACTIONS.delicate_synthesis,
&ACTIONS.delicate_synthesis
]
);
let route = routes1.pop().unwrap();
assert_eq!(
route.actions,
vec![
&ACTIONS.muscle_memory,
&ACTIONS.manipulation,
&ACTIONS.veneration,
&ACTIONS.waste_not_ii,
&ACTIONS.groundwork,
&ACTIONS.delicate_synthesis,
&ACTIONS.basic_synthesis,
]
);
let route = routes1.pop().unwrap();
assert_eq!(
route.actions,
vec![
&ACTIONS.muscle_memory,
&ACTIONS.manipulation,
&ACTIONS.veneration,
&ACTIONS.waste_not_ii,
&ACTIONS.groundwork,
&ACTIONS.careful_synthesis
]
);
let route = routes1.pop().unwrap();
assert_eq!(
route.actions,
vec![
&ACTIONS.muscle_memory,
&ACTIONS.manipulation,
&ACTIONS.veneration,
&ACTIONS.waste_not_ii,
&ACTIONS.groundwork,
&ACTIONS.basic_synthesis
]
);
let route = routes1.pop().unwrap();
assert_eq!(
route.actions,
vec![
&ACTIONS.muscle_memory,
&ACTIONS.manipulation,
&ACTIONS.veneration,
&ACTIONS.groundwork,
&ACTIONS.delicate_synthesis,
&ACTIONS.delicate_synthesis
]
);
let route = routes1.pop().unwrap();
assert_eq!(
route.actions,
vec![
&ACTIONS.muscle_memory,
&ACTIONS.manipulation,
&ACTIONS.veneration,
&ACTIONS.groundwork,
&ACTIONS.delicate_synthesis,
&ACTIONS.basic_synthesis
]
);
let route = routes1.pop().unwrap();
assert_eq!(
route.actions,
vec![
&ACTIONS.muscle_memory,
&ACTIONS.manipulation,
&ACTIONS.veneration,
&ACTIONS.groundwork,
&ACTIONS.prudent_synthesis
]
);
let route = routes1.pop().unwrap();
assert_eq!(
route.actions,
vec![
&ACTIONS.muscle_memory,
&ACTIONS.manipulation,
&ACTIONS.veneration,
&ACTIONS.groundwork,
&ACTIONS.careful_synthesis
]
);
let route = routes1.pop().unwrap();
assert_eq!(
route.actions,
vec![
&ACTIONS.muscle_memory,
&ACTIONS.manipulation,
&ACTIONS.veneration,
&ACTIONS.groundwork,
&ACTIONS.basic_synthesis
]
);
let route = routes1.pop();
match route {
None => (),
Some(..) => panic!(),
}
}
}
mod test_solver;

391
src/solver/test_solver.rs Normal file
View File

@ -0,0 +1,391 @@
#[allow(unused_imports)]
use super::*;
#[test]
pub fn test_first_step() {
let mut craft = crate::craft::Craft::two_star();
// Try a failed craft
craft.success = crate::specs::Success::Failure;
let vact = next_action_picker_1(&craft);
assert_eq!(vact, vec![None]);
craft.success = crate::specs::Success::Pending;
// Try the first 4 steps
let vact = next_action_picker_1(&craft);
assert_eq!(vact, action_vec![ACTIONS.muscle_memory]);
craft.run_action(&ACTIONS.muscle_memory);
let vact = next_action_picker_1(&craft);
assert_eq!(vact, action_vec![ACTIONS.manipulation]);
craft.run_action(&ACTIONS.manipulation);
let vact = next_action_picker_1(&craft);
assert_eq!(vact, action_vec![ACTIONS.veneration]);
craft.run_action(&ACTIONS.veneration);
let vact = next_action_picker_1(&craft);
assert_eq!(vact, action_vec![ACTIONS.waste_not_ii, ACTIONS.groundwork]);
craft.run_action(&ACTIONS.waste_not_ii);
// Try the steps 5-8, deterministically
let vact = next_action_picker_1(&craft);
assert_eq!(vact, action_vec![ACTIONS.groundwork]);
craft.run_action(&ACTIONS.careful_synthesis);
let vact = next_action_picker_1(&craft);
assert_eq!(
vact,
action_vec![
ACTIONS.groundwork,
ACTIONS.basic_synthesis,
ACTIONS.careful_synthesis,
ACTIONS.delicate_synthesis
]
);
craft.run_action(&ACTIONS.careful_synthesis);
let vact = next_action_picker_1(&craft);
assert_eq!(
vact,
action_vec![
ACTIONS.groundwork,
ACTIONS.basic_synthesis,
ACTIONS.careful_synthesis,
ACTIONS.delicate_synthesis
]
);
craft.run_action(&ACTIONS.careful_synthesis);
let vact = next_action_picker_1(&craft);
assert_eq!(
vact,
action_vec![
ACTIONS.groundwork,
ACTIONS.basic_synthesis,
ACTIONS.careful_synthesis,
ACTIONS.delicate_synthesis
]
);
craft.run_action(&ACTIONS.careful_synthesis);
// Check odd parameters
craft.buffs.waste_not = 0;
craft.progression = 0;
let vact = next_action_picker_1(&craft);
assert_eq!(
vact,
action_vec![
ACTIONS.basic_synthesis,
ACTIONS.careful_synthesis,
ACTIONS.prudent_synthesis,
ACTIONS.delicate_synthesis
]
);
craft.run_action(&ACTIONS.delicate_synthesis);
let vact = next_action_picker_1(&craft);
assert_eq!(
vact,
action_vec![
ACTIONS.basic_synthesis,
ACTIONS.careful_synthesis,
ACTIONS.prudent_synthesis,
ACTIONS.delicate_synthesis,
ACTIONS.waste_not_ii,
ACTIONS.waste_not
]
);
craft.args.desperate = true;
let vact = next_action_picker_1(&craft);
assert_eq!(
vact,
action_vec![
ACTIONS.basic_synthesis,
ACTIONS.careful_synthesis,
ACTIONS.prudent_synthesis,
ACTIONS.delicate_synthesis,
ACTIONS.groundwork,
ACTIONS.masters_mend,
ACTIONS.waste_not_ii,
ACTIONS.waste_not
]
);
assert_eq!(craft.progression, 250);
assert_eq!(craft.quality, 266);
assert_eq!(craft.cp, 317);
}
#[test]
pub fn test_routes_p1() {
let craft = crate::craft::Craft::two_star();
let mut routes1 = generate_routes_phase1(craft);
for route in routes1.iter() {
println!("{:?}", route.actions);
}
// Literrally any change will break it
// An eq should be implmented to just check a vector of vector versus a route
assert_eq!(routes1.len(), 9);
let route = routes1.pop().unwrap();
assert_eq!(
route.actions,
vec![
&ACTIONS.muscle_memory,
&ACTIONS.manipulation,
&ACTIONS.veneration,
&ACTIONS.waste_not_ii,
&ACTIONS.groundwork,
&ACTIONS.delicate_synthesis,
&ACTIONS.delicate_synthesis
]
);
let route = routes1.pop().unwrap();
assert_eq!(
route.actions,
vec![
&ACTIONS.muscle_memory,
&ACTIONS.manipulation,
&ACTIONS.veneration,
&ACTIONS.waste_not_ii,
&ACTIONS.groundwork,
&ACTIONS.delicate_synthesis,
&ACTIONS.basic_synthesis,
]
);
let route = routes1.pop().unwrap();
assert_eq!(
route.actions,
vec![
&ACTIONS.muscle_memory,
&ACTIONS.manipulation,
&ACTIONS.veneration,
&ACTIONS.waste_not_ii,
&ACTIONS.groundwork,
&ACTIONS.careful_synthesis
]
);
let route = routes1.pop().unwrap();
assert_eq!(
route.actions,
vec![
&ACTIONS.muscle_memory,
&ACTIONS.manipulation,
&ACTIONS.veneration,
&ACTIONS.waste_not_ii,
&ACTIONS.groundwork,
&ACTIONS.basic_synthesis
]
);
let route = routes1.pop().unwrap();
assert_eq!(
route.actions,
vec![
&ACTIONS.muscle_memory,
&ACTIONS.manipulation,
&ACTIONS.veneration,
&ACTIONS.groundwork,
&ACTIONS.delicate_synthesis,
&ACTIONS.delicate_synthesis
]
);
let route = routes1.pop().unwrap();
assert_eq!(
route.actions,
vec![
&ACTIONS.muscle_memory,
&ACTIONS.manipulation,
&ACTIONS.veneration,
&ACTIONS.groundwork,
&ACTIONS.delicate_synthesis,
&ACTIONS.basic_synthesis
]
);
let route = routes1.pop().unwrap();
assert_eq!(
route.actions,
vec![
&ACTIONS.muscle_memory,
&ACTIONS.manipulation,
&ACTIONS.veneration,
&ACTIONS.groundwork,
&ACTIONS.prudent_synthesis
]
);
let route = routes1.pop().unwrap();
assert_eq!(
route.actions,
vec![
&ACTIONS.muscle_memory,
&ACTIONS.manipulation,
&ACTIONS.veneration,
&ACTIONS.groundwork,
&ACTIONS.careful_synthesis
]
);
let route = routes1.pop().unwrap();
assert_eq!(
route.actions,
vec![
&ACTIONS.muscle_memory,
&ACTIONS.manipulation,
&ACTIONS.veneration,
&ACTIONS.groundwork,
&ACTIONS.basic_synthesis
]
);
let route = routes1.pop();
assert!(route.is_none());
}
// Test Custom routes (None and basic synthesis)
#[test]
pub fn test_custom_p1_routes() {
// None route, no more actions
let mut craft = crate::craft::Craft::zero_star();
craft.success = crate::specs::Success::Failure;
let routes1 = generate_routes_phase1(craft.clone());
assert!(routes1.is_empty());
}
// Test step 2 route-finding
#[test]
pub fn test_second_step() {
let mut craft = crate::craft::Craft::two_star();
craft.cp = 10000;
let mut routes1 = generate_routes_phase1(craft);
let mut craft2 = routes1.pop().unwrap();
let vact = next_action_phase_2(&craft2);
assert_eq!(vact, action_vec![ACTIONS.innovation]);
craft2.run_action(&ACTIONS.innovation);
let vact = next_action_phase_2(&craft2);
assert_eq!(
vact,
action_vec![ACTIONS.basic_touch, ACTIONS.preparatory_touch]
);
craft2.run_action(&ACTIONS.basic_touch);
let vact = next_action_phase_2(&craft2);
assert_eq!(
vact,
action_vec![ACTIONS.preparatory_touch, ACTIONS.standard_touch]
);
craft2.run_action(&ACTIONS.standard_touch);
let vact = next_action_phase_2(&craft2);
assert_eq!(
vact,
action_vec![ACTIONS.preparatory_touch, ACTIONS.advanced_touch]
);
craft2.run_action(&ACTIONS.advanced_touch);
let vact = next_action_phase_2(&craft2);
assert_eq!(
vact,
action_vec![
ACTIONS.basic_touch,
ACTIONS.preparatory_touch,
ACTIONS.manipulation
]
);
craft2.run_action(&ACTIONS.manipulation);
let vact = next_action_phase_2(&craft2);
assert_eq!(vact, action_vec![ACTIONS.innovation]);
craft2.run_action(&ACTIONS.innovation);
let vact = next_action_phase_2(&craft2);
assert_eq!(
vact,
action_vec![ACTIONS.basic_touch, ACTIONS.prudent_touch]
);
craft2.run_action(&ACTIONS.basic_touch);
let vact = next_action_phase_2(&craft2);
assert_eq!(
vact,
action_vec![ACTIONS.prudent_touch, ACTIONS.standard_touch]
);
craft2.run_action(&ACTIONS.prudent_touch);
let vact = next_action_phase_2(&craft2);
assert_eq!(
vact,
action_vec![ACTIONS.basic_touch, ACTIONS.prudent_touch]
);
craft2.run_action(&ACTIONS.prudent_touch);
let vact = next_action_phase_2(&craft2);
assert_eq!(
vact,
action_vec![ACTIONS.basic_touch, ACTIONS.prudent_touch]
);
craft2.run_action(&ACTIONS.prudent_touch);
let vact = next_action_phase_2(&craft2);
assert_eq!(vact, action_vec![ACTIONS.innovation]);
craft2.run_action(&ACTIONS.innovation);
let vact = next_action_phase_2(&craft2);
assert_eq!(
vact,
action_vec![ACTIONS.basic_touch, ACTIONS.prudent_touch]
);
craft2.run_action(&ACTIONS.prudent_touch);
let vact = next_action_phase_2(&craft2);
assert_eq!(
vact,
action_vec![
ACTIONS.basic_touch,
ACTIONS.prudent_touch,
ACTIONS.trained_finesse,
ACTIONS.great_strides
]
);
craft2.run_action(&ACTIONS.great_strides);
let vact = next_action_phase_2(&craft2);
assert_eq!(
vact,
action_vec![
ACTIONS.basic_touch,
ACTIONS.prudent_touch,
ACTIONS.byregot_blessing
]
);
craft2.run_action(&ACTIONS.byregot_blessing);
craft2.success = crate::specs::Success::Success;
assert_eq!(next_action_phase_2(&craft2), vec![None]);
assert_eq!(craft2.progression, 3750);
assert_eq!(craft2.quality, 9899);
assert_eq!(craft2.cp, 9322);
}
#[test]
pub fn test_generate_routes_p2() {
let craft = crate::craft::Craft::two_star();
let mut routes1 = generate_routes_phase1(craft);
let craft1 = routes1.pop().unwrap();
let routes2 = generate_routes_phase2(craft1);
assert_eq!(routes2.unwrap().len(), 241);
// Any modification on the solving will break this test, same as before,
// maybe having a range of expected solution instead is the way to go.
// Nonetheless the solver test will add qualitative testing so some
// results will be thoughrouly checked
// Maybe sampling a handful results and expect them to always exits could also work
}

View File

@ -1 +0,0 @@

View File

@ -1 +0,0 @@