province-config-generator
Skill3 starsChanged 2 months agoMITView on GitHub
Run or modify the two-stage province generation pipeline — Stage 1 scripts/utils/generate_provinces.py (geopandas/Voronoi/mapshaper geometry, Natural Earth downloads, province_name.* locale writes) and Stage 2 src/Game.Configs.Loader ProvinceProcessor, which emits Assets/Configs/provinces.json and province_map_features_1880.json. Load when regenerating province data, changing generation constants/calibration, or debugging province ids, names, population, or neighbours.
In this repository45 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .cursor/rules/issue-clarification-questions.mdcCursor rule
- .cursor/rules/reset-font-assets.mdcCursor rule
- .cursor/rules/src-dotnet-build-release.mdcCursor rule
- .cursor/rules/unity-plugins-before-work.mdcCursor rule
- codex-issueSkill
- commitSkill
- complete-prdSkill
- dependency-docsSkill
- dotnet-buildSkill
- dotnet-testSkill
- generate-imageSkill
- implementSkill
- meeting-joinSkill
- meeting-scheduleSkill
- meeting-startSkill
- plan-reviewSkill
- planSkill
- prSkill
- specifySkill
- unity-e2e-runSkill
- unity-pluginsSkill
- add-terminal-commandSkill
- dependency-docsSkill
- dotnet-benchmarkSkill
- dotnet-buildSkill
- dotnet-testSkill
- end-game-score-calibrationSkill
- flag-assetsSkill
- github-issue-automationSkill
- image-generationSkill
- localizationSkill
- meeting-joinSkill
- meeting-scheduleSkill
- meeting-startSkill
- milestone-completeSkill
- unity-e2e-runSkill
- unity-pluginsSkill
- unity-prefabsSkill
- unity-scenesSkill
- update-branchSkill
- cursor-meeting-joinSkill
- cursor-meeting-startSkill
- unity-pluginsSkill
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 23
Run from the project root:
≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Province Config Generator (Two-Stage Pipeline)
Province-level data (sitting between mapFeatureId and countryId) is generated by a
two-stage pipeline. This is a build-time data/config foundation only — no MapRenderer
changes, no runtime consumption yet. See Docs/Specs/43_province-division/ for the full
spec and plan.
Stage 1 — Python geometry stage (scripts/utils/generate_provinces.py)
Run from the project root:
.venv\Scripts\python.exe scripts\utils\generate_provinces.py [--force-download]Dependencies (installed into .venv): geopandas, shapely, scipy, pyproj, requests
(same venv as the flag-asset tooling — see the flag-assets skill).
New toolchain dependency: Node.js/npx. The final simplify step shells out to
npx mapshaper (auto-installed from the npm registry on first run if not already
present locally). No package.json is checked into the repo — npx fetches
mapshaper on demand. Confirm Node.js is installed on any machine that needs to
re-run this script.
What it does
- Reconstructs each 1880 country's unioned polygon from
Assets/Configs/countries.json(mainMapFeatureIds/secondaryMapFeatureIds, colonial-parent merges already applied) plus the raw feature geometries inAssets/Map/world_1880.json.mapFeatureIdis recomputed locally from each raw feature's name property using the same ASCII-normalize + slug algorithm asProgram.cs'sToMapFeatureId, so there's no need to round-trip throughgeojson_world.json/map_entries.jsonfor geometry. - Reprojects to
EPSG:6933(equal-area) purely for km² math; all emitted geometry stays in WGS84 lon/lat to matchworld_1880.json's convention. - Downloads and caches (skip if present) two Natural Earth datasets into the gitignored
.tmp/naturalearth/directory:ne_10m_admin_1_states_provincesandne_10m_populated_places(source:naciscdn.org/naturalearth/10m/cultural/). - Per country, applies one of three generation methods:
- Micro — area < 3,000 km²: single province = country's own polygon,
displayName= country'sdisplayName. No admin-1/Voronoi attempted. - Option A —
geopandas.overlay(admin1, country_polygon, how="intersection"). Accepted only if piece count is in[2, 300]and ≤30% of pieces (by count) are "slivers" (<0.5% of country area). Names come from the admin-1 feature'sname/woe_nameproperty. - Option C (fallback when Option A fails the fit-quality gate) — scatter
clamp(round(area_km2 / 10_000), 3, 150)seed points (both the divisor and the cap are scaled per-country byPER_COUNTRY_DENSITY_MULTIPLIER, a dict ofcountryId -> multiplierfor areas that need finer detail than the global constants give — e.g. an archipelago that collapses into one Voronoi cell) via rejection sampling with a deterministic RNG seeded from an MD5 hash ofcountryId(never unseeded — required for reproducible re-runs), build ascipy.spatial.Voronoitessellation, clip each cell to the country polygon, (population density is separately scaled per-country byCOUNTRY_POPULATION_CALIBRATION_1880, a dict ofcountryId -> multiplierthat calibrates the total generated population ofisAvailable=truecountries to a researched real-world circa-1880 figure; countries without an entry keep the uncalibrated region-band estimate — see step 7 below), and name each province from the nearestne_10m_populated_placespoint — search is uncapped by distance, so a cell is named after its closest known settlement however far away, only falling back to a compass-direction name (e.g."Northern Afghanistan", relative to the country's own bounding box) if the country has zero populated-places entries at all. If Option C itself yields zero valid cells, the country falls back further to the Micro rule so no country is ever left with zero provinces.
- Micro — area < 3,000 km²: single province = country's own polygon,
- Assigns a deterministic
provinceId={countryId}__{slug(name)}, with a numeric suffix (_2,_3, ...) on any in-country name collision. - Serializes the combined result to the gitignored intermediate file
.tmp/provinces_intermediate.geojson(properties:provinceId,countryId,displayName,generationMethod,compassKey— the latter isnullexcept for the rare compass-direction fallback case above, and only used by the locale step below —isMainTerritory(Trueif the majority of the province's area falls within the country'smainMapFeatureIdsgeometry,FalseforsecondaryMapFeatureIds/colonial holdings — seeclassify_main_territory), plus apopulationplaceholder, computed in step 7 below). - Runs
npx mapshaper -i <file> -simplify keep-shapes <pct>% -o <file>to reduce vertex count for WebGL viability (keep-shapesguarantees no polygon degenerates to zero area). The simplify percentage is a tunable constant (MAPSHAPER_SIMPLIFY_PCT) in the script, currently10. Afterward, each province's finalpopulationis computed from this simplified geometry's area (COUNTRY_REGION/REGION_DENSITY_RANGES-derived density, scaled byCOUNTRY_POPULATION_CALIBRATION_1880where the country has an entry, × simplified polygon area). The final geometry also suppliescentroidX/centroidYand an ordinalneighborProvinceIdslist. Adjacency uses a Shapely spatial index and requires a non-zero shared boundary-segment length, so point-only contacts are excluded. These properties are written back into.tmp/provinces_intermediate.geojson, so persisted population and topology match the geometry actually shipped to Stage 2. - Writes
province_name.{provinceId}locale entries intoAssets/Localization/en.asset(the generated name verbatim) andAssets/Localization/ru.asset— settlement/admin-1 proper nouns are run through a deterministic phonetic Latin→Cyrillic transliteration (transliterate_to_cyrillic, a placeholder pending real translation), while compass-direction fallback names use a proper Russian translation table (COMPASS_RU) combined with the country's already-translatedcountry_name.{countryId}entry — never transliterated, since "Northern"/"Central" etc. are real words, not proper nouns. Re-running the script replaces allprovince_name.*entries in both files but leaves every other key untouched.
At the end, the script prints a per-country generation-method summary (counts of Micro / Option A / Option C countries) and any warnings — e.g. a country that fell back from Option A to Option C (fit-quality rejection), or from Option C to Micro (degenerate/disjoint Voronoi geometry).
Cache locations:
.tmp/naturalearth/— downloaded Natural Earth zips + extracted shapefiles (gitignored).tmp/provinces_intermediate.geojson— intermediate output consumed by Stage 2 (gitignored)
Stage 2 — C# metadata/validation stage (src/Game.Configs.Loader)
ProvinceProcessor reads the intermediate GeoJSON produced by Stage 1 and the
in-memory CountryConfig already built in the same Program.cs run, cross-validates
every province's countryId against CountryConfig (per
.claude/rules/config_validation.md — a mismatch throws rather than silently
proceeding), and writes Assets/Configs/provinces.json (lightweight metadata:
provinceId, countryId, generationMethod, population, centroidX, centroidY,
isMainTerritory, and neighborProvinceIds — no displayName; province names are
localization-only, see province_name.* keys above) and Assets/Configs/province_map_features_1880.json
(passthrough geometry FeatureCollection).
Re-run order: Stage 1 (Python) must be run before Stage 2 (C# loader), since Stage 2
consumes Stage 1's intermediate file via loaderConfig.ProvinceGeoJsonSourcePath.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

