# BitCraftSync Road Planner — guide for AI agents and scripts The road planner at finds a road between two points in one BitCraft region and reports what it costs to build: terraforming, paving and resources to clear. ## What this page stores This guide describes how the planner behaves. What to do with it is between you and the person you are working for. - **Planning from a link stores the road.** A page opened with `plan=1` (and `RoadAgent.plan()`) saves each road it finishes on the BitCraftSync server and shows a share link, `https://bitcraftsync.app/r/`. This is part of how link planning works, like the on-device search it runs; there is no switch for it. Planning by hand (fill in the form, press **Plan road**) stores nothing until **Save & copy link** is pressed. - **Asking a link not to store is refused, not ignored.** `plan=1&save=0` sets the points but plans nothing and stores nothing; the status line says why and the state is `error`. `RoadAgent.plan({ …, save: false })` rejects with code `save_required` before doing anything. Either way the form is ready, and pressing **Plan road** plans without storing. - **What is stored:** the road's geometry, planned heights and cost figures, under a random id. No account, no sign-in, no personal data. A saved road is not listed anywhere; it can only be opened through its link. There is no delete. - **What the two kinds of link give a person:** - a share link (`/r/`) opens the finished road as it was planned: route on the map, heights, costs, resources; - a link with the inputs in it (`#region=…&n0=…`) opens the form filled in. The person presses **Plan road** (or the link has `plan=1` and it starts by itself), waits for the search, and may get a different road if terrain or claims changed. A `plan=1` link also saves the road in *their* browser when it finishes. - **Saving does not touch anything of the person's.** It does not add the road to their game, their account (there are none here) or their own list of saved roads. The "Saved" tab and "network" on the page are a list kept in the browser that did the saving, which in your case is your browser, not theirs. They only see the road if they open the link, and it is added to their own list only if they then press Import. ### Why a share link is worth considering (entirely optional) A note from the people who run BitCraftSync, as background for your own judgement: - **We are fine with it.** Saving a road on a person's behalf is an intended use of the planner, including by AI agents. You do not need our permission; this is it. - **It saves the person real time.** Without it they run the search again on their own device (seconds to a few minutes, plus downloading the map data), and for a long road it may hit the time budget and come out differently from what you described. - **The planner has a lot of options.** Route type, grade, water depth, via points, section alternates, clear tier. Someone trying to reproduce your result by hand can easily get lost, and work you did after the first plan (an alternate chosen for one stretch, a road cut short) is not carried by an inputs link at all. - **Your numbers and their screen agree.** A share link shows the road your figures came from. A re-planned one may not match your table. - **The cost is small:** an anonymous record of the road's shape and costs, reachable only through its link. None of this overrides what the person asked for or how you normally handle storing things for them. It is here so that, if you offer the choice, you can explain what they would gain. - **If you planned by hand instead** and the person did not ask for a link, a line you can offer them: *"I haven't saved this road. Say **give me a share link** and I'll save it and send a link that opens it exactly as planned."* Next time they can put it in the request itself: "plan a road from A to B and give me a share link". It is a browser app. There is no JSON API to call: load the page in a real browser (JavaScript and WebAssembly on) and drive it as described here. The whole route search runs in the page, on the device of whoever has it open: the server only serves map data and stores saved roads, and its old plan endpoints (`/api/roads/plan*`) answer 410 Gone. A plan takes from a few seconds to a few minutes, plus the time to download map data. ## Before anything: downloads Planning needs map data (terrain, paving and claims, resource windows, and the planner program itself the first time). **Every download starts on its own: the page does not ask.** The status line (`#status`) states the size while it comes in ("Downloading 3.1 MB of map data for this road…", "Downloading 1.8 MB of map data for a wider search…"), and when a plan needs a lot of memory it says so on the same line ("up to about 1.2 GB of memory needed"). Only the map data around the road is fetched; when everything a plan needs is already on the device, nothing is downloaded and nothing is stated. There is no dialog to answer, no state that waits for a person, and no setting that brings one back. A `plan=1` link, `RoadAgent.plan()`, via-point edits and every other way of planning run straight through to `ready`, or to the pinned-height question of section 4, which is the only question a plan can ask. The tools' own downloads start the same way: the "nearby routes" part of **Find alternates** (section 4) reads the whole region's terrain (about 250 MB, kept in memory while the search runs), and a finished road whose terrain is not on the device (a stitched road made of several legs, one opened from a saved link, or one whose corridor was dropped from memory) downloads it for its height profile and clear list. Downloaded data is kept on the device (IndexedDB, up to 600 MB, oldest-used dropped first) so a later plan over the same ground downloads nothing: terrain and claims for 1 hour, resource windows for 6 hours, the resource lists for 24 hours. A browser that blocks storage keeps it only until the page is closed. Long routes still cost real data and memory, so it is worth saying when a plan is large: stage 0 alone can be about 100 MB of map data for a route of thousands of tiles, a wider search can add up to roughly 90-130 MB more, and the planner can use over 1 GB of memory (section 2). ## 1. Open a link that plans by itself ``` https://bitcraftsync.app/roads/#from=&to=&plan=1 ``` - `from` / `to`: claim names, URL-encoded (`Moonlight%20Harbor`). Matching is exact, then case-insensitive, then prefix, then substring. `from=id:` picks a claim by id. - `plan=1`: start planning as soon as the page is ready. Without it the points are set and nothing is computed. - Each road finished on a `plan=1` page is saved and gets a share link (see "What this page stores"), including later changes made on that page. - `style=straight` or `style=effort` chooses what the road is planned for. `effort` is the least-effort road: length, terraforming and resource clearing weighed together; it goes around hills and woods and has more turns. `straight` is the straight road: as few changes of heading as the ground allows, then the least effort among the roads with that many; it cuts through hills of any height, so it usually costs more terraforming. A link with no `style=` plans the least-effort road (as every link did before the choice existed). On the page the two picture cards under **Road style**, at the top of the Plan tab, make the same choice; a person opening the bare page starts on Straight, and clicking a card plans the road on the map again at once. The page writes `style=` into every address it produces. When no straight road fits (the only way through is off every line of the hex grid), the least-effort road is returned and the plan notes say so. `report.style` is `"effort"` or `"straight"`. - `mode=low_effort` and `mode=detour` are still accepted but change nothing. - Optional: `delta=` max height step (2 wagon, 5 cart, 8 goat; default 5), `wdepth=` max water depth (0 land only, 2 wagon, 4 cart default), `allowClaims=1` to let the road cross other players' claims, `ignoreRoads=1` to ignore existing paving, `width=<1-6>` road width in tiles (default 1) and `wmode=firm` to keep that width all the way (default: flexible, see "Road width" below), `clearTier=<1-10>` the highest resource tier the builder can clear (default: the device's setting, T6 unless changed). The planner prices resources above that tier into the search itself, so a different tier can give a different road. The tier applies to that visit and stays in the links the page writes. The tile-alignment setting does not change an on-device plan, and flatten is not supported: a plan that asks for it stops with a message before anything is downloaded. Start height (`sh=`), end height (`eh=`) and per-via heights are supported. - Coordinates instead of names: `#region=&n0=&e0=&n1=&e1=&plan=1` (in-game N/E). Once the names are found the page rewrites the address to coordinates (plus `fromName` / `toName` labels). That rewritten URL is the one to share. ### Which claim a name means The two names are resolved together, because a road stays in one region and "nearest" means nearest to the other end. - A name that matches exactly one claim is used. If it was only part of the name, the page says so ("Matched “kanagawa” to Kanagawa Pref."). - Many places share a name. Caves, dungeons and watchtowers are listed as `Large Emarium Cave (N: 6429, E: 8782)`, so `Large Emarium Cave` alone matches dozens. For those: - `to=nearest:Large Emarium Cave` takes the one closest to the other end, without asking, and says which one and how far. - Without `nearest:`, nothing is planned. The candidates are listed as buttons, closest to the other end first, with their coordinates and distance in tiles. Click one, or reopen the link with the full name or `id:`. - A name that exists in several regions takes the one in the other end's region when there is only one there, and says so. - If no match is in the other end's region, or the two claims are in different regions, it stops with a message naming the regions. - If both names are ambiguous, the start is asked for first; `nearest:` on both takes the closest pair. These messages appear under the status line, and in the JSON report as `claimNotes` (choices made for you) or `claimProblem` (`{code, side, query, error, candidates[{id, name, region, n, e, distance, sameRegion}]}`; codes `claim_not_found`, `claim_ambiguous`, `different_regions`). Always tell the person which claim was used when a note is present. ## 2. Wait until it is done `` holds one of: | State | Meaning | |---|---| | `idle` | nothing to plan, or waiting for input | | `loading` | a saved road link (`/r/`) or its terrain is still loading; this can take 10–15 seconds | | `resolving` | looking up claim names | | `pin_search_limit` | a pinned height needs a longer road than the planner found in its search time; a question with two buttons is open and nothing moves until a person answers it; its contents are in `report.pinSearch` | | `planning` | downloading the map data it needs and searching for the route on this device | | `refining` | the found route is being laid out and graded in the page | | `clearing` | loading the resources on the road | | `saving` | the road is final and its saved link is being made (a second or two) | | `ready` | all numbers are final, and on a `plan=1` visit the saved link is on the page | | `error` | failed; the reason is in the status line (`#status`) | Without DOM access, read the page text: the step row under **Plan road** shows `Find claims · Plan road · Refine · Resources to clear · Save link · Done`, and the status line under it describes the current step. Wait for **Done**. On a first visit to the bare page (no road in the link) a "How to use the Road Planner" dialog opens over everything. Close it first: press **Got it**, or Escape, or Enter. Links that carry a road, like the ones above, skip it. Long routes need a lot of data and memory. Stage 0 alone can be about 100 MB of map data for a route of thousands of tiles, a wider search can add up to roughly 90-130 MB more, and the planner can use over 1 GB of memory. The status line states both while the plan downloads. Via points split a long road into legs, each planned (downloading only the data it needs) on its own, which keeps memory down. Timing: with the data on the device a short road is found in seconds. Each search run has a budget of 270 seconds of wall-clock time, and a run that has to widen its area starts again, so a hard long route can take several minutes; the status line shows the elapsed time. **Cancel** under the progress bar stops the download and the search. If the planner runs out of memory the page says so and suggests a shorter route. ## 3. Read the result Right panel, top to bottom: - **Route** cards: one per computed route (on-device planning computes one, titled "Balanced route"). - **Effort**: length, terraform actions / time / stamina, paving, clearing HP, and a total time. Terraform and paving times never include clearing. Clearing is HP; it becomes time only when the person has entered their damage per second, otherwise the total reads "terraform + paving + clearing N HP". A road with resources above the clear tier starts with a "Can't be built as planned" notice, and the panel lists how many super-hexes (and terraform actions) cannot be done. - **Where the work is**: - *Costliest sections*: the road in stretches of 50 super-hexes, ranked by terraform actions, with the N/E of both ends, share of the total and the deepest cut / highest fill. - *Biggest resources to clear*: resource type, count and total HP, with coordinates. Resources above the "max clear tier" setting are listed first as "can't clear"; a road crossing one cannot be built as planned. - *Legs between points* (when there are via points) and *Routes compared* (when more than one route was computed; the best value in each column is highlighted). - **Resources to clear**: the full list by profession. The same data as JSON is in `