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:
@@ -27,10 +27,20 @@ export type RoutingRequest =
|
||||
|
||||
export type RoutingResponse =
|
||||
/**
|
||||
* `gaveUp` is true when the searches spent their budget rather than looking everywhere: there
|
||||
* being no route and no range to offer is then what was found, not what exists.
|
||||
* Two searches, and two things they can fail to prove, kept apart because they are printed as
|
||||
* different sentences. `gaveUp` is about the range that was asked for: true when that search
|
||||
* spent its budget rather than looking everywhere the range reaches. `least` is about the search
|
||||
* for a range that would work: true when it looked everywhere up to the ceiling, so `null` there
|
||||
* means no chain exists rather than none was found.
|
||||
*/
|
||||
| { readonly kind: 'route'; readonly requestId: number; readonly route: Route | null; readonly neededRangePc: number | null; readonly gaveUp: boolean }
|
||||
| {
|
||||
readonly kind: 'route';
|
||||
readonly requestId: number;
|
||||
readonly route: Route | null;
|
||||
readonly neededRangePc: number | null;
|
||||
readonly gaveUp: boolean;
|
||||
readonly least: boolean;
|
||||
}
|
||||
| { readonly kind: 'links'; readonly requestId: number; readonly segments: Float32Array }
|
||||
/** The question threw in the worker. Sent back so the request settles instead of waiting for good. */
|
||||
| { readonly kind: 'failed'; readonly requestId: number; readonly message: string };
|
||||
@@ -56,8 +66,9 @@ export function answerRouting(index: StarNeighbourhood, request: RoutingRequest)
|
||||
// At the ceiling the question has just been asked: the range search would repeat it, identically
|
||||
// and at the same cost, before bisecting below it.
|
||||
if (route || request.rangePc >= request.ceilingPc) {
|
||||
return { kind: 'route', requestId: request.requestId, route, neededRangePc: null, gaveUp: !route && gaveUp };
|
||||
// Asked at the ceiling, the one search answers both questions.
|
||||
return { kind: 'route', requestId: request.requestId, route, neededRangePc: null, gaveUp: !route && gaveUp, least: !gaveUp };
|
||||
}
|
||||
const needed = minimumRangeBetween(index, request.fromId, request.toId, request.ceilingPc);
|
||||
return { kind: 'route', requestId: request.requestId, route: null, neededRangePc: needed.rangePc, gaveUp: gaveUp || !needed.least };
|
||||
return { kind: 'route', requestId: request.requestId, route: null, neededRangePc: needed.rangePc, gaveUp, least: needed.least };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user