Commit Graph
2 Commits
Author SHA1 Message Date
adminandGitHub f56289899b Update Eagle scene setup docs (#6986) 2026-06-08 17:16:55 -07:00
64c86ebd2b Add Rust map generator, equalized province maps, and dynamic province labels (#5957)
* Add design doc for programmatic map image generation

Documents the plan to:
- Create a Python tool for regenerating map images with more equalized province sizes
- Implement dynamic province name rendering that scales with zoom
- Preserve topology and neighbor relationships while enlarging small provinces

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Add Python map generator tool for province size equalization

Implements Part 1 of the programmatic map generation plan:
- Python script using weighted dilation to grow small provinces
- Preserves jagged/natural edges using noise fields
- Allows small provinces to claim limited ocean pixels (20% max)
- Maintains neighbor relationships and realistic coastlines

Results:
- Province size ratio reduced from 110x to 22x
- Smallest province (Kojaria) grew 5x (3,262 → 16,590 pixels)
- All 43 province masks and centroids.json generated

Usage:
  cd tools/map_generator
  python -m venv venv && source venv/bin/activate
  pip install -r requirements.txt
  python generate_map.py --generate

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Add ProvinceLabelsController for dynamic map labels

Part 2 of programmatic map generation - dynamic province name rendering:
- Creates TextMeshPro labels at province centroids
- Labels scale inversely with zoom level for readability
- Only visible when zoom >= 1.5x (configurable)
- Font size scales with province area for visual hierarchy
- Includes centroids.json with province positions

To use:
1. Add ProvinceLabelsController component to a GameObject in the scene
2. Assign zoomHandler, mapContent (RectTransform), and centroidsJson TextAsset
3. Optionally configure font, colors, and zoom threshold

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Add topology documentation and tendril removal to map generator

- Document new province adjacencies caused by equalization
- Add priority_provinces parameter for boosting specific province growth
- Add remove_tendrils() post-processing to eliminate thin extensions
- Note: Will be restructured to use Bazel in next commit

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Add Bazel Python support and parallelized map generator

- Add rules_python to MODULE.bazel with Python 3.13
- Move map generator to src/main/python/net/eagle0/eagle/
- Add parallel processing using ProcessPoolExecutor
- Provinces are now grown in parallel across multiple CPU cores

Usage:
  bazel run //src/main/python/net/eagle0/eagle:map_generator -- --generate
  bazel run //src/main/python/net/eagle0/eagle:map_generator -- --workers 8

The old tools/map_generator/ script remains for reference but the Bazel
version is now the primary implementation.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Add Rust map generator and equalized province maps

- Add Rust map generator (src/main/rust/net/eagle0/eagle/map_generator/)
  - Uses parallel graph coloring for non-adjacent province processing
  - Generates equalized province sizes (smallest ~7x larger than before)
  - Outputs: rawGray.gz.bytes, map_bw.png, province masks, centroids.json
  - Run with: bazel run //src/main/rust/net/eagle0/eagle/map_generator -- --generate

- Update province_map.tsv with neighbor changes from equalization:
  - Usvol gains: Laufarvia, Hella, Grytrand
  - Chapellia loses Nikemi, gains Kojaria
  - Kojaria gains Motcia, Chapellia
  - Motcia gains Kojaria

- Update Unity assets with equalized map:
  - New rawGray.gz.bytes with equalized province boundaries
  - New map_bw.png with textured water, transparent land, dark borders
  - Updated province mask images (1-43.png)
  - Updated centroids.json with orientation data for label rotation

- Update ProvinceLabelsController.cs to support label rotation

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Fix coordinate system for rawGray and province labels

- Fix save_raw_gray to not flip Y coordinates (was causing click detection
  to be inverted)
- Fix ProvinceLabelsController to not flip Y coordinates (was causing
  labels to appear in wrong positions)
- Update rawGray.gz.bytes with correct orientation
- Update Gameplay.unity with ProvinceLabelsController setup

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Improve province label rendering

- Reduce max font size scale from 2.0 to 1.3
- Disable word wrapping, allow text overflow
- Fix orientation sign (remove negation)
- Allow near-vertical labels by expanding angle range to [-90, 90]
- Recalculate province orientations with new range

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Scale province label font size based on province dimensions

- Add principal_length and perpendicular_width to centroids.json
- Update ProvinceLabelsController to scale font based on principal_length
- Update Rust map generator to calculate province dimensions via PCA
  eigenvalues (4 * sqrt(eigenvalue) for ±2 std dev coverage)
- Disable text wrapping on labels to prevent unwanted line breaks

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Reduce province label base font size to 11

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Update neighbor positions and hex map starting positions for new borders

TSV changes (neighborPositions for new neighbors):
- Laufarvia: Usvol attacks from dir 4 (E)
- Hella: Usvol attacks from dir 2 (NE)
- Chapellia: Kojaria attacks from dir 4 (E)
- Usvol: Laufarvia=3(W), Hella=5(SW), Grytrand=4(E)
- Kojaria: Chapellia=1(N), Motcia=3(W)
- Grytrand: Usvol attacks from dir 3 (W)

Hex map changes (new attackerStartingPositions):
- Motcia.e0mj: Added direction 0 (NW) for Kojaria
- Chapellia.e0mj: Added direction 4 (SE) for Kojaria
- Kojaria.e0mj: Added directions 1 (N) and 3 (E) for Chapellia/Motcia

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Revert outline width change (made text smaller)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Add TMP underlay effect for better label visibility on dark backgrounds

The underlay expands outward (unlike outline which shrinks text inward),
providing a white glow around labels without reducing text size.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-10 14:30:58 -08:00