📊 Build status for all bb4 projects
Scala implementation of generic A* and IDA* search algorithms.
A* (AStarSearch) |
IDA* (IDAStarSearch) |
|
|---|---|---|
| Memory | Open set + visited map; can exhaust heap on huge spaces | Path-only (plus optional per-iteration transposition) |
| Speed | Usually faster when memory fits | Trades time for memory; re-expands nodes across bounds |
| Best for | Moderate spaces (e.g. small sliding puzzles) | Huge spaces (Rubik-scale) where A* runs out of memory |
Both share AbstractSearcher bookkeeping (stop(), numTries / expansions, finalRefresh).
val search = new IDAStarSearch(space) // defaults
val search = new IDAStarSearch(space, maxBoundIterations) // legacy overload
val search = new IDAStarSearch(space, IDAStarSearchConfig(
maxBoundIterations = 1_000_000,
maxNodeExpansions = Some(5_000_000L), // optional UX / timeout cap
weightPercent = 100, // 100 = optimal when h is admissible
useIterationTransposition = false, // optional seen-set per bound (memory tradeoff)
terminateWhenBoundUnchanged = false,
))- Limits /
stop(): HittingmaxNodeExpansions,maxBoundIterations, orstop()makessolvereturnNoneand still callssearchSpace.finalRefresh. Caps do not distinguish “unsolvable” from “gave up”. - Weighted IDA*:
weightPercent > 100scales the heuristic like bb4-puzzles’ sliderFastSliderSolver(f = g*100 + h*weightPercent). Faster, but may return a longer-than-optimal path. - Unsolvability: Override
SearchSpace.isKnownUnsolvable(e.g. sliding-puzzle parity) for an immediateNone. Otherwise use expansion caps for runaway spaces.
Puzzle UIs typically wrap this library via bb4-puzzles IDAStarPuzzleSolver (extends IDAStarSearch). A specialized low-memory weighted slider solver (FastSliderSolver) remains in bb4-puzzles; it may later thin out and delegate weighted IDA* here.
- Install git, scala
- git clone https://github.com/barrybecker4/bb4-A-star.git
- In bash shell run
./gradlew - Or import Gradle project into IntelliJ and run from there (preferred)