Skip to content

Commit

Permalink
Add unsound... option support for raphael
Browse files Browse the repository at this point in the history
  • Loading branch information
Tnze committed Sep 29, 2024
1 parent fc659e0 commit d9a4648
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 13 deletions.
1 change: 1 addition & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ jobs:
v0.17.1
- 修复食药数据不正确的问题
- 修复无法使用Raphael求解器的问题
releaseDraft: false
prerelease: false
3 changes: 2 additions & 1 deletion src-libs/src/solver/raphael.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ pub fn solve(
use_quick_innovation: bool,
backload_progress: bool,
adversarial: bool,
unsound_branch_pruning: bool,
) -> Vec<Actions> {
let mut allowed_actions = ActionMask::from_level(status.attributes.level);
if !use_heart_and_soul {
Expand Down Expand Up @@ -55,7 +56,7 @@ pub fn solve(
let mut solver = MacroSolver::new(
settings,
backload_progress,
false,
unsound_branch_pruning,
Box::new(|_| {}),
Box::new(|_| {}),
);
Expand Down
6 changes: 4 additions & 2 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Actions> {
raphael::solve(
status.clone(),
use_manipultaion,
use_manipulation,
use_heart_and_soul,
use_quick_innovation,
backload_progress,
adversarial,
unsound_branch_pruning,
)
}

Expand Down
2 changes: 2 additions & 0 deletions src-wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ pub fn raphael_solve(
use_quick_innovation: bool,
backload_progress: bool,
adversarial: bool,
unsound_branch_pruning: bool,
) -> Result<JsValue, JsValue> {
use app_libs::solver::raphael::solve;
let status: Status = from_value(status)?;
Expand All @@ -132,6 +133,7 @@ pub fn raphael_solve(
use_quick_innovation,
backload_progress,
adversarial,
unsound_branch_pruning,
);
Ok(to_value(&result)?)
}
Expand Down
28 changes: 20 additions & 8 deletions src/components/designer/solvers/RaphaelSolver.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -56,7 +56,8 @@ function runRaphaelSolver() {
useHeartAndSoul.value,
useQuickInnovation.value,
backloadProgress.value,
adversarial.value
adversarial.value,
unsoundBranchPruning.value,
),
)
}
Expand Down Expand Up @@ -91,12 +92,19 @@ function runRaphaelSolver() {
</el-space>
<el-space>
<el-checkbox v-model="backloadProgress" :label="$t('backload-progress')" />
<el-tag v-if="backloadProgress" type="success">{{ $t('speed-up') }}</el-tag>
<el-tag v-if="backloadProgress" type="danger">{{ $t('quality-down') }}</el-tag>
<el-tag v-if="backloadProgress" type="danger">{{ $t('increase-duration') }}</el-tag>
</el-space>
<el-space>
<el-checkbox v-model="unsoundBranchPruning" :label="$t('unsound-branch-pruning')" />
<el-tag v-if="unsoundBranchPruning" type="success">{{ $t('speed-up') }}</el-tag>
<el-tag v-if="unsoundBranchPruning" type="danger">{{ $t('increase-duration') }}</el-tag>
</el-space>
<el-checkbox v-model="minimizeSteps" :label="$t('minimize-steps')" disabled />
<el-space>
<el-checkbox v-model="adversarial" :label="$t('adversarial')" />
<el-tag v-if="adversarial" type="danger">{{ $t('quality-down') }}</el-tag>
<el-tag v-if="adversarial" type="danger">{{ $t('increase-duration') }}</el-tag>
</el-space>
</el-space>
<div style="margin-top: 10px;">
Expand All @@ -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 = 消耗能工巧匠图纸

Expand All @@ -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

Expand Down
4 changes: 3 additions & 1 deletion src/libs/Solver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ export async function raphael_solve(
useHeartAndSoul: boolean,
useQuickInnovation: boolean,
backloadProgress: boolean,
adversarial: boolean
adversarial: boolean,
unsoundBranchPruning: boolean,
): Promise<Actions[]> {
clarityReport('runRaphaelSolver')
const args = {
Expand All @@ -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
Expand Down
10 changes: 9 additions & 1 deletion src/libs/SolverWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
};

0 comments on commit d9a4648

Please sign in to comment.