Compare commits

..

1 Commits
dev ... dan-fix

Author SHA1 Message Date
beffroi ca3e667fa4 Fix(status) - Fixes status always being equals to true 2023-03-12 12:43:47 +01:00
15 changed files with 33 additions and 301 deletions

View File

@ -1,9 +0,0 @@
[bumpversion]
current_version = 0.1.8
tag = True
[bumpversion:file:python/pyproject.toml]
[bumpversion:file:Cargo.toml]
[bumpversion:file:pyproject.toml]

1
.gitignore vendored
View File

@ -163,4 +163,3 @@ dmypy.json
# Cython debug symbols
cython_debug/
Cargo.lock

View File

@ -1,2 +0,0 @@
*.ico
*.png

View File

@ -1,6 +1,6 @@
[package]
name = "xiv_csolver"
version = "0.1.8"
version = "0.1.7"
edition = "2021"
authors = ["谭俊健","Dandaedre","Vkyfox"]
description = "Small XIV solver library in rust, with python and rust bindings"

232
Jenkinsfile vendored
View File

@ -1,232 +0,0 @@
// Add this webhook in Gitea:
// http://192.168.1.37:8080/gitea-webhook/post
pipeline {
agent { label 'rust_no_docker' }
environment {
CARGO_TERM_COLOR = 'always'
RUST_BACKTRACE = '1'
VENV = '.venv'
}
stages {
stage('Checkout') {
steps {
checkout scm
sh '''
set -eu
git submodule sync --recursive
git submodule update --init --recursive
'''
}
}
stage('Setup Rust') {
steps {
sh '''
set -eu
if ! command -v rustup >/dev/null 2>&1; then
echo "ERROR: rustup is not installed on this worker." >&2
exit 1
fi
echo "Ensuring stable Rust is available..."
rustup toolchain install stable \
--profile minimal \
--component rustfmt \
--component clippy
rustup default stable
echo
echo "Using:"
rustc --version
cargo --version
rustfmt --version
cargo clippy --version
'''
}
}
stage('Setup Python') {
steps {
sh '''
set -eu
if ! command -v uv >/dev/null 2>&1; then
echo "uv not found — installing it..."
if ! command -v cargo-binstall >/dev/null 2>&1; then
echo "cargo-binstall not found — installing it..."
cargo install cargo-binstall
fi
cargo binstall --no-confirm uv
else
echo "uv already installed."
fi
echo "Using:"
uv --version
rm -rf "${VENV}"
echo "Creating Python virtual environment..."
uv venv "${VENV}"
echo "Installing Maturin..."
uv pip install \
--python "${VENV}/bin/python" \
"maturin>=0.14,<0.15"
echo
echo "Python:"
"${VENV}/bin/python" --version
echo "Maturin:"
"${VENV}/bin/maturin" --version
'''
}
}
stage('Format') {
steps {
sh '''
set -eu
echo "Checking Rust formatting..."
cargo fmt --all -- --check
'''
}
}
stage('Rust Check') {
steps {
sh '''
set -eu
echo "Checking Rust targets..."
cargo check \
--all-targets \
--all-features
'''
}
}
stage('Rust Tests') {
steps {
sh '''
set -eu
echo "Running Rust tests..."
cargo test \
--all-targets \
--all-features
'''
}
}
stage('Clippy') {
steps {
sh '''
set -eu
echo "Running Clippy..."
cargo clippy \
--all-targets \
--all-features
'''
}
}
stage('Build CLI') {
steps {
sh '''
set -eu
echo "Building xiv_csolver CLI..."
cargo build \
--release \
--bin xiv_csolver_cli
echo
echo "CLI build completed."
if [ -f target/release/xiv_csolver_cli ]; then
ls -lh target/release/xiv_csolver_cli
fi
'''
}
}
stage('Build Python Bindings') {
steps {
sh '''
set -eu
echo "Building Python extension through Maturin..."
"${VENV}/bin/maturin" build \
--release
echo
echo "Python binding build completed."
'''
}
}
}
post {
success {
publishChecks(
conclusion: 'SUCCESS',
name: 'Rust/Python CI',
summary: 'xiv_csolver passed all CI checks.',
text: 'Formatting, Rust checks, tests, Clippy, CLI build, and Python binding build completed successfully.',
title: 'Build Successful'
)
echo '✅ xiv_csolver passed all CI checks.'
}
failure {
publishChecks(
conclusion: 'FAILURE',
name: 'Rust/Python CI',
summary: 'xiv_csolver failed CI.',
text: 'Formatting, Rust compilation, tests, Clippy, CLI build, or Maturin binding build failed. Check the Jenkins log.',
title: 'Build Failed'
)
echo '❌ xiv_csolver CI failed.'
}
unstable {
publishChecks(
conclusion: 'ACTION_REQUIRED',
name: 'Rust/Python CI',
summary: 'xiv_csolver CI is unstable.',
text: 'The Jenkins build completed with an unstable status.',
title: 'Build Unstable'
)
echo '⚠️ xiv_csolver CI is unstable.'
}
always {
sh '''
echo "Cleaning Python CI environment..."
rm -rf .venv
'''
}
}
}

10
Todo.md
View File

@ -16,15 +16,7 @@
### Features
🟩 (GUI) Refactor code
🟩 (GUI) Restore GUI state
🟩 (GUI) Bugfix the gui and clean it up
🟩 (LIB) Restructure code, cleanup the mess
🟩 (LIB) Have an autoretry
🟩 (LIB) Have the autoretry be smart and/or threaded with interrupts
🟩 (LIB) Cleanup the Toml to have one unique Food/Receipe/Craftsman with the gui
🟩 (LIB) Be more aggressive with the mem optimisations
🟩 (LIB) Have a thread interrupt mode for fast mode
🟩 (LIB) Cleanup features (verbose doesn't really make sense)
# Roadmap
## v1.0.0

View File

@ -5,7 +5,7 @@ build-backend = "maturin"
[project] # The rust bindings
name = "xiv_csolver_lib"
requires-python = ">=3.7"
version = "0.1.8"
version = "0.1.7"
classifiers = [
"Programming Language :: Rust",
"Programming Language :: Python :: Implementation :: CPython",

View File

@ -9,7 +9,7 @@ authors = [
{name="Dandaedre"},
]
requires-python = ">=3.7"
version = "0.1.8"
version = "0.1.7"
license = {text="Mozilla Public License Version 2.0"}
classifiers = [
"Programming Language :: Rust",

View File

@ -4,9 +4,5 @@
# If this seems super convoluted, and you'd rather it was just the three in-game values, know that me too.
# Unfortunately that is how the craft system works in FFXIV.
Lvl88: [1650, 7000, 40, 128, 112, 100, 100]
Patch6.3_precrafts: [3696, 8200, 35, 130, 115, 80, 70]
Patch6.3_gear: [5060, 12628, 70, 130, 115, 80, 70]
Patch6.3_gatherer: [5720, 12900, 70, 130, 115, 80, 70]
Patch6.4_precrafts: [4488, 9090, 35, 130, 115, 80, 70]
Patch6.4_gear: [6600, 14040, 70, 130, 115, 80, 70]
Grade 7 Tincture of Strength: [5060, 12628, 70, 130, 115, 80, 70]
Grade 5 Strength Alkahest: [1300, 6200, 40, 123, 107, 100, 100]

View File

@ -4,5 +4,6 @@
# The top line will always be selected by default
Vicky Crosia: [4021, 3987, 601]
Ladisla Kociann: [4021, 3951, 580]
Vicky Crosia: [4021, 3933, 587]
Dandaedre Zadiel: [0, 0, 0]
Sekundes Dullahan: [2566, 2443, 522]

View File

@ -33,18 +33,18 @@ class Printer:
}
def save_users(self, user_name: str = None, user_stats: list = None) -> dict:
output = self.help_text_dict['users'] + '\r\n\r\n'
output = self.help_text_dict['users'] + '\n\n'
if user_name.title() == '':
for user, stats in self.full_config.get_users_dict().items():
if user != ' ':
output += f'{user}: [{stats[0]}, {stats[1]}, {stats[2]}]\r\n'
output += f'{user}: [{stats[0]}, {stats[1]}, {stats[2]}]\n'
else:
self.full_config.get_users_dict()[user_name] = user_stats
for user, stats in self.full_config.get_users_dict().items():
if user != ' ':
output += f'{user}: [{stats[0]}, {stats[1]}, {stats[2]}]\r\n'
output += f'{user}: [{stats[0]}, {stats[1]}, {stats[2]}]\n'
self.print_users(output)
return self.full_config.get_users_dict()
@ -55,18 +55,18 @@ class Printer:
return True
def save_recipe(self, recipe_name: str = None, recipe_basic_stats: list = None, recipe_advanced_stats: list = None) -> dict:
output = self.help_text_dict['recipe'] + '\r\n\r\n'
output = self.help_text_dict['recipe'] + '\n\n'
if recipe_name.title() == '':
for recipe, stats in self.full_config.get_recipes_dict().items():
if recipe != ' ':
output += f'{recipe}: [{stats[0]}, {stats[1]}, {stats[2]}, {stats[3]}, {stats[4]}, {stats[5]}, {stats[6]}]\r\n'
output += f'{recipe}: [{stats[0]}, {stats[1]}, {stats[2]}, {stats[3]}, {stats[4]}, {stats[5]}, {stats[6]}]\n'
else:
self.full_config.get_recipes_dict()[recipe_name] = recipe_basic_stats[:-1] + recipe_advanced_stats
for recipe, stats in self.full_config.get_recipes_dict().items():
if recipe != ' ':
output += f'{recipe}: [{stats[0]}, {stats[1]}, {stats[2]}, {stats[3]}, {stats[4]}, {stats[5]}, {stats[6]}]\r\n'
output += f'{recipe}: [{stats[0]}, {stats[1]}, {stats[2]}, {stats[3]}, {stats[4]}, {stats[5]}, {stats[6]}]\n'
self.print_recipe(output)
return self.full_config.get_recipes_dict()

View File

@ -50,7 +50,7 @@ Remaining CP: {self.remaining_cp}"""
saved_lines.append(line)
for line in saved_lines:
justified_text += line + '\r\n'
justified_text += line + '\n'
return justified_text[:-1]
@ -67,9 +67,8 @@ Remaining CP: {self.remaining_cp}"""
if self.steps != 15 and self.steps != 29 and self.steps != 44:
saved_lines.append('/echo Craft complete ! <se.3>')
# else:
# TODO: Add a callback to the parent object for logging
# self.loggers.add_log(f'No completion message in macro because rotation is exactly {self.steps} steps.')
else:
self.loggers.log(f'No completion message in macro because rotation is exactly {self.steps} steps.')
if self.steps > 15:
saved_lines.insert(14, '/echo Macro 1 complete <se.2>')
@ -82,11 +81,11 @@ Remaining CP: {self.remaining_cp}"""
for line in saved_lines:
count += 1
if count < 16:
self.macro1 += line + '\r\n'
self.macro1 += line + '\n'
elif 15 < count < 31:
self.macro2 += line + '\r\n'
self.macro2 += line + '\n'
elif 30 < count < 46:
self.macro3 += line + '\r\n'
self.macro3 += line + '\n'
self.macro1 = self.macro1[:-1]
self.macro2 = self.macro2[:-1]
@ -155,7 +154,7 @@ class Solver:
break
if not done:
self.loggers.add_log('Could not find a rotation for a 50% Safe Margin.\r\n'
self.loggers.add_log('Could not find a rotation for a 50% Safe Margin.\n'
' Defaulting to Best Quality.')
self.safe_50 = self.best_quality
@ -171,3 +170,5 @@ class Solver:
self.least_steps = Result(output, 'Least steps')
return self.least_steps

View File

@ -48,7 +48,7 @@ def translate_list(actions: list, lang: str):
output.append(dictionary[action])
except KeyError:
output.append(supported_languages["en"][action])
loggers.log('Translation not found. Defaulting to English.\r\n'
loggers.log('Translation not found. Defaulting to English.\n'
' Macros will probably be broken because of this.')
else:

View File

@ -168,25 +168,9 @@ pub fn solve_craft<'a>(
let phase2_routes = arc_phase2_routes.lock().unwrap();
let nb_p2 = phase2_routes.len();
// Drop on empty results. // TODO: Retry automatically with better parameters
// Drop on empty results
if phase2_routes.len() == 0 {
// No solutions were found
if params.desperate {
// But everything was tested
return Some((Vec::<SolverResult>::new(), Info::new(0, 0, false)));
} else {
// And not everything was tested
return solve_craft(
recipe,
stats,
Parameters {
depth: 11,
byregot_step: 6,
desperate: true,
..params
},
);
}
return None;
}
// Print the results if verbose
@ -209,10 +193,12 @@ pub fn solve_craft<'a>(
// Prune the results for analysis
// let mut valid_routes : Vec<Craft> = vec![];
let mut valid_solutions: Vec<SolverResult> = vec![];
let mut success = false;
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
valid_solutions.push(SolverResult::from_craft(route));
success = true;
}
}
// If no craft can make it to 100% HQ, fallback to base results
@ -222,7 +208,7 @@ pub fn solve_craft<'a>(
}
}
Some((valid_solutions, Info::new(nb_p1, nb_p2, true)))
Some((valid_solutions, Info::new(nb_p1, nb_p2, succes)))
}
/// Load the config from args and make a craft from it
@ -394,7 +380,7 @@ mod test {
craft.recipe.progress = 0;
let res = solve_craft(craft.recipe, craft.stats, craft.args);
println!("{:?}", res);
assert!(res.unwrap().0.len() == 0);
assert!(res.is_none());
craft.recipe.progress = 100;
craft.stats.max_cp = 0;

View File

@ -130,7 +130,7 @@ impl SolverResult {
progression: craft.progression,
quality: craft.quality,
durability: craft.durability,
actions,
actions: actions,
total_progression: craft.recipe.progress,
total_quality: craft.recipe.quality,
total_durability: craft.recipe.durability,