Skip to content

Instantly share code, notes, and snippets.

@nlhepler
Last active February 8, 2023 03:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nlhepler/dde24a5d78b114557479da7c4cab8931 to your computer and use it in GitHub Desktop.
Save nlhepler/dde24a5d78b114557479da7c4cab8931 to your computer and use it in GitHub Desktop.
quick-n-dirty brute-force optimizer for mythic leads in FN:STW
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)]
enum Personality {
Adventurous,
Analytical,
Competitive,
Cooperative,
Curious,
Dependable,
Dreamer,
Pragmatic,
}
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)]
enum Job {
Doctor,
Marksman,
Engineer,
Explorer,
Gadgeteer,
PersonalTrainer,
MartialArtist,
Inventor,
}
fn main() {
use std::collections::HashSet;
use Job::*;
use Personality::*;
let jobs = &[
Doctor,
Marksman,
Engineer,
Explorer,
Gadgeteer,
PersonalTrainer,
MartialArtist,
Inventor,
];
// put your current mythic lead configuration here--
// you can see my Explorer is Adventurous, my Gadgeteer Curious,
// and my Inventor Pragmatic.
let options: &[&[Personality]] = &[
&[Competitive, Analytical, Pragmatic], // Doctor
&[Dependable, Cooperative, Adventurous], // Marksman
&[Pragmatic, Dreamer, Analytical], // Engineer
&[Adventurous], // Explorer
&[Curious], // Gadgeteer
&[Curious, Competitive, Cooperative], // Personal Trainer
&[Adventurous, Dependable, Competitive], // Martial Artist
&[Pragmatic], // Inventor
];
fn recurse(
i: usize,
options: &[&[Personality]],
mut acc: Vec<Personality>,
) -> Vec<Personality> {
match options.first() {
Some(opts) => {
let chosen = i % opts.len();
let nexti = i / opts.len();
acc.push(opts[chosen]);
recurse(nexti, &options[1..], acc)
}
None => acc,
}
}
fn is_valid(config: &[Personality]) -> bool {
let mut s = HashSet::new();
for p in config {
if s.replace(p).is_some() {
return false;
}
}
true
}
let total = options
.iter()
.map(|opts| opts.len())
.fold(1usize, |a, b| a * b);
let mut results = vec![];
for i in 0..total {
let result = recurse(i, options, vec![]);
if is_valid(&result) {
results.push(result);
}
}
if results.is_empty() {
println!("you will necessarily have duplicate personalities :(");
} else {
println!("{} possible configurations:", results.len());
for (i, result) in results.iter().enumerate() {
println!(
" {}: {:?}",
i + 1,
result
.iter()
.copied()
.enumerate()
.map(|(i, p)| (jobs[i], p))
.collect::<Vec<_>>()
);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment