Configure Fair Hints & Cancellation
How to get responsive, non-cheating hints in interactive games and cancel long searches cleanly.
Passing Unknown Face-Down Cards
When calling hint, Dealbreaker automatically hides face-down cards (written with ~, like "~5H"). If your client doesn't even know what the face-down cards are—for example, in a server-authoritative game—write them as "?" (or "~?"):
json
{
"piles": {
"tableau": [["~?", "~?", "KS"], ["QD"]],
"foundation": [[], [], [], []]
}
}Dealbreaker infers the unseen cards by subtracting all visible cards from the game's pack and randomly samples valid arrangements.
Tuning Hint Quality vs. Latency
Hint runtime scales roughly with samples × max_states:
- Snappy mobile/web UI (~50–200 ms):
samples: 8–16,max_states: 50_000–100_000. - Stronger advice:
samples: 32,max_states: 250_000. - Deterministic hints for tests: pass a fixed
seedinHintOptions.
ts
const hint = await solver.hint(state, {
samples: 16,
seed: 1,
solve: { max_states: 100_000 },
});python
hint = solver.hint(state, samples=16, seed=1, max_states=100_000, timeout_ms=500)rust
use dealbreaker::{hint, HintOptions, SolveOptions};
let opts = HintOptions::default()
.samples(16)
.seed(1)
.solve(SolveOptions::default().max_states(100_000).timeout_ms(500));
let suggestion = hint(&game, &state, &opts);Timeouts & Cooperative Cancellation
- Wall-clock timeout (native Rust, Python, CLI, C ABI): set
timeout_msinSolveOptions(or--timeout-mson the CLI). - Rust cancellation: pass an
AtomicBooltosolve_with_cancel,hint_with_cancel, ormaximize_with_cancel. - C ABI cancellation: create a
DealbreakerCancel *withdealbreaker_cancel_new()and calldealbreaker_cancel_trigger()from another thread. - Browser cancellation: use
WorkerSolver(dealbreaker/worker) and callsolver.terminate().
See Hidden Cards & Fair Hints for how sampling works under the hood.