Answer the review: say which search gave up, and let the bisection earn its offer
The panel printed "No route at this range." beside the range it was offering — which is the sentence this branch exists to stop it printing. It was gated on there being no offer, and a search that gives up usually has one: Sol to HD 120147 at 4.5 pc spends the budget, offers 4.83 pc, and says there is no route where a 71-jump route exists. The wording now follows the search at the range that was asked for, and nothing else. That needs the two give-ups kept apart, so `least` travels beside `gaveUp` to the panel: one says the asked range was not searched out, the other that the search for a range that would work was. HIP 69445 at 3 pc — asked-range search exhaustive in 44 ms, ceiling probe out of budget — used to read "Too many stars to search at this range." and now reads "No route at this range.", with nothing claimed after it. Two more from the same review. The budget flag was read off the settled count, so a search that proved a dead end with the last star it was allowed reported a give-up; it now records why the loop stopped. And the bisection's cap could fire before a single probe had narrowed anything, leaving the ceiling route's own longest hop as the answer: star 1000115173 at 3 pc was told to go to 8.00 pc, the control's maximum, for a crossing that works at 6. It now offers 6.93. Measured in the app, all three: "Too many stars to search at this range. 4.90 pc would reach.", "No route at this range." alone, and 7.00 pc in place of 8.00. The duplicated dead-end test now asks the question it was named for — exactly the budget's worth of stars reaching each other and none of them the destination — and each fix kills its own mutant. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016jxMkwA2rbicdGxHosecYi
This commit is contained in:
@@ -180,11 +180,18 @@ export function routeBetween(index: StarNeighbourhood, fromId: number, toId: num
|
||||
const frontier = new Frontier();
|
||||
frontier.push(fromId, straightLineOn(origin.x, origin.y, origin.z));
|
||||
|
||||
while (frontier.size > 0 && settled.size < MAX_VISITED) {
|
||||
let gaveUp = false;
|
||||
while (frontier.size > 0) {
|
||||
const starId = frontier.pop();
|
||||
if (settled.has(starId)) {
|
||||
continue;
|
||||
}
|
||||
// Counted against the budget only once the frontier has been drained of stale duplicates, so
|
||||
// the flag below records why the search stopped rather than how full the set happened to be.
|
||||
if (settled.size >= MAX_VISITED) {
|
||||
gaveUp = true;
|
||||
break;
|
||||
}
|
||||
settled.add(starId);
|
||||
const costHere = travelled.get(starId)!;
|
||||
|
||||
@@ -216,7 +223,7 @@ export function routeBetween(index: StarNeighbourhood, fromId: number, toId: num
|
||||
|
||||
// An empty frontier means the range reaches nothing further; a spent budget means only that the
|
||||
// search stopped looking.
|
||||
return { route: null, gaveUp: settled.size >= MAX_VISITED };
|
||||
return { route: null, gaveUp };
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -235,18 +242,24 @@ export function routeBetween(index: StarNeighbourhood, fromId: number, toId: num
|
||||
* Each step has to answer "is there a chain at this range", and a search that gives up answers
|
||||
* nothing. It is still worth carrying on from — the ranges above it are the ones left to try — but
|
||||
* the result is no longer the least range, only a range that works, and `least` says which. The
|
||||
* number of steps is bounded for the same reason: each one that gives up walks the whole budget,
|
||||
* and 11 s of them for a star at 236 pc bought two decimal places nobody reads.
|
||||
* number of steps that may give up is bounded for the same reason: each one walks the whole budget,
|
||||
* and 11 s of them for a star at 236 pc bought two decimal places nobody reads. Bounded, but not
|
||||
* before the bisection has found a range of its own: until then the only range it could offer is
|
||||
* the ceiling's, which is the control's maximum, for crossings that work well below it.
|
||||
*/
|
||||
export function minimumRangeBetween(index: StarNeighbourhood, fromId: number, toId: number, ceilingPc: number): RangeSearch {
|
||||
const widest = routeBetween(index, fromId, toId, ceilingPc);
|
||||
if (!widest.route) {
|
||||
return { rangePc: null, least: !widest.gaveUp };
|
||||
}
|
||||
const ceilingHopPc = widest.route.longestHopPc;
|
||||
let unreachable = 0;
|
||||
let reachable = widest.route.longestHopPc;
|
||||
let reachable = ceilingHopPc;
|
||||
let giveUps = 0;
|
||||
while (reachable - unreachable > RANGE_RESOLUTION_PC && giveUps < MAX_RANGE_GIVE_UPS) {
|
||||
// The cap cannot fire while `reachable` is still the ceiling route's own longest hop: that is
|
||||
// the question, not an answer the bisection earned, and offering it sends the control to its
|
||||
// maximum for a crossing that works well below — 8.00 pc for a star that routes at 6.
|
||||
while (reachable - unreachable > RANGE_RESOLUTION_PC && (giveUps < MAX_RANGE_GIVE_UPS || reachable === ceilingHopPc)) {
|
||||
const range = (unreachable + reachable) / 2;
|
||||
const { route, gaveUp } = routeBetween(index, fromId, toId, range);
|
||||
if (route) {
|
||||
|
||||
Reference in New Issue
Block a user