From d9a4648e39a1d6fde329a14b9c412ae5e0348c5e Mon Sep 17 00:00:00 2001 From: Tnze Date: Sun, 29 Sep 2024 22:28:21 +0800 Subject: [PATCH] Add unsound... option support for raphael --- .github/workflows/publish.yml | 1 + src-libs/src/solver/raphael.rs | 3 +- src-tauri/src/main.rs | 6 ++-- src-wasm/src/lib.rs | 2 ++ .../designer/solvers/RaphaelSolver.vue | 28 +++++++++++++------ src/libs/Solver.ts | 4 ++- src/libs/SolverWorker.ts | 10 ++++++- 7 files changed, 41 insertions(+), 13 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 2e311442..3b2cf837 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -47,6 +47,7 @@ jobs: v0.17.1 - 修复食药数据不正确的问题 + - 修复无法使用Raphael求解器的问题 releaseDraft: false prerelease: false diff --git a/src-libs/src/solver/raphael.rs b/src-libs/src/solver/raphael.rs index dbb5c10d..75f2c712 100644 --- a/src-libs/src/solver/raphael.rs +++ b/src-libs/src/solver/raphael.rs @@ -26,6 +26,7 @@ pub fn solve( use_quick_innovation: bool, backload_progress: bool, adversarial: bool, + unsound_branch_pruning: bool, ) -> Vec { let mut allowed_actions = ActionMask::from_level(status.attributes.level); if !use_heart_and_soul { @@ -55,7 +56,7 @@ pub fn solve( let mut solver = MacroSolver::new( settings, backload_progress, - false, + unsound_branch_pruning, Box::new(|_| {}), Box::new(|_| {}), ); diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index ec8c5c27..8dab2f53 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -492,19 +492,21 @@ fn reflect_solve( #[tauri::command(async)] fn raphael_solve( status: Status, - use_manipultaion: bool, + use_manipulation: bool, use_heart_and_soul: bool, use_quick_innovation: bool, backload_progress: bool, adversarial: bool, + unsound_branch_pruning: bool, ) -> Vec { raphael::solve( status.clone(), - use_manipultaion, + use_manipulation, use_heart_and_soul, use_quick_innovation, backload_progress, adversarial, + unsound_branch_pruning, ) } diff --git a/src-wasm/src/lib.rs b/src-wasm/src/lib.rs index ee4b4b83..f1679487 100644 --- a/src-wasm/src/lib.rs +++ b/src-wasm/src/lib.rs @@ -122,6 +122,7 @@ pub fn raphael_solve( use_quick_innovation: bool, backload_progress: bool, adversarial: bool, + unsound_branch_pruning: bool, ) -> Result { use app_libs::solver::raphael::solve; let status: Status = from_value(status)?; @@ -132,6 +133,7 @@ pub fn raphael_solve( use_quick_innovation, backload_progress, adversarial, + unsound_branch_pruning, ); Ok(to_value(&result)?) } diff --git a/src/components/designer/solvers/RaphaelSolver.vue b/src/components/designer/solvers/RaphaelSolver.vue index 0c80375e..8b3b7c09 100644 --- a/src/components/designer/solvers/RaphaelSolver.vue +++ b/src/components/designer/solvers/RaphaelSolver.vue @@ -44,8 +44,8 @@ const raphaelSolveIsSolving = ref(false) const useManipulation = ref(false) const useHeartAndSoul = ref(false) const useQuickInnovation = ref(false) -const backloadProgress = ref(false) -const minimizeSteps = ref(false) +const backloadProgress = ref(true) +const unsoundBranchPruning = ref(true) const adversarial = ref(false) function runRaphaelSolver() { @@ -56,7 +56,8 @@ function runRaphaelSolver() { useHeartAndSoul.value, useQuickInnovation.value, backloadProgress.value, - adversarial.value + adversarial.value, + unsoundBranchPruning.value, ), ) } @@ -91,12 +92,19 @@ function runRaphaelSolver() { + {{ $t('speed-up') }} {{ $t('quality-down') }} + {{ $t('increase-duration') }} + + + + {{ $t('speed-up') }} + {{ $t('increase-duration') }} - {{ $t('quality-down') }} + {{ $t('increase-duration') }}
@@ -120,10 +128,12 @@ error-with = 错误:{ $err } enable-action = 使用技能:{ $action } backload-progress = 后置作业技能(快速求解) -minimize-steps = 最小化步数 -adversarial = 确保 100% 可靠 +unsound-branch-pruning = 不健全剪枝 +adversarial = 确保 100% 可靠(防黑球) -quality-down = 求解质量下降 +speed-up = 求解速度提高 +quality-down = 求解品质下降 +increase-duration = 最终步数增加 need-learn-manipulation = 需要学习掌握技能 consume-crafters-delineation = 消耗能工巧匠图纸 @@ -148,10 +158,12 @@ error-with = Error: { $err } enable-action = Enable { $action } backload-progress = Backload progress (Quick solve) -minimize-steps = Minimize Steps +unsound-branch-pruning = Unsound branch pruning adversarial = Ensure 100% reliability +speed-up = speed up quality-down = quality decline +increase-duration = increase macro duration need-learn-manipulation = need manipulation consume-crafters-delineation = consume crafter's delineation diff --git a/src/libs/Solver.ts b/src/libs/Solver.ts index 24f94821..e5b28413 100644 --- a/src/libs/Solver.ts +++ b/src/libs/Solver.ts @@ -133,7 +133,8 @@ export async function raphael_solve( useHeartAndSoul: boolean, useQuickInnovation: boolean, backloadProgress: boolean, - adversarial: boolean + adversarial: boolean, + unsoundBranchPruning: boolean, ): Promise { clarityReport('runRaphaelSolver') const args = { @@ -143,6 +144,7 @@ export async function raphael_solve( useQuickInnovation, backloadProgress, adversarial, + unsoundBranchPruning, }; if (import.meta.env.VITE_BESTCRAFT_TARGET == "tauri") { let { invoke } = await pkgTauri diff --git a/src/libs/SolverWorker.ts b/src/libs/SolverWorker.ts index 8c24b984..7486e433 100644 --- a/src/libs/SolverWorker.ts +++ b/src/libs/SolverWorker.ts @@ -19,7 +19,15 @@ onmessage = async (e) => { case "rika_solve_tnzever": throw "unsupported"; case "raphael_solve": - postMessage(raphael_solve(args.status, args.useManipulation, args.useHeartAndSoul, args.useQuickInnovation, args.backloadProgress, args.adversarial)) + postMessage(raphael_solve( + args.status, + args.useManipulation, + args.useHeartAndSoul, + args.useQuickInnovation, + args.backloadProgress, + args.adversarial, + args.unsoundBranchPruning, + )) } close() };