Skip to content

Refactor MapGenerator for Procedural Variety - #197

Merged
candour merged 2 commits into
mainfrom
refactor-map-generator-6495807666786743505
Jun 29, 2026
Merged

Refactor MapGenerator for Procedural Variety#197
candour merged 2 commits into
mainfrom
refactor-map-generator-6495807666786743505

Conversation

@candour

@candour candour commented Jun 29, 2026

Copy link
Copy Markdown
Owner

This refactor modernizes the map generation logic in Hawker Rush. By moving away from simple uniform random placement and straight-line path carving, the new implementation provides greater gameplay variety and a more natural aesthetic. The code is also more maintainable due to improved modularity and consistent use of axial coordinates.


PR created automatically by Jules for task 6495807666786743505 started by @candour

Summary by CodeRabbit

  • New Features

    • Improved procedural map generation to create more varied, organic layouts with winding routes, clustered obstacles, and better tile variety.
    • Added more consistent placement of special tiles like start, goal, and hazard strips.
  • Documentation

    • Updated the changelog with a new entry describing the map generation improvements.

- Standardized internal logic on axial coordinates, reducing offset-to-axial conversions.
- Implemented a winding path generator using a biased random walk to replace the previous simple A* carving on an empty grid.
- Introduced a seed-and-grow approach for clumped pillar placement, creating more organic-looking environments.
- Modularized the generation logic into specialized helper functions.
- Updated fixes.md with REF-017.

Co-authored-by: candour <4670475+candour@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@candour, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 5 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b954cf25-9604-4fa8-a1a6-dd154fbf3ef0

📥 Commits

Reviewing files that changed from the base of the PR and between b032823 and 3333cbf.

📒 Files selected for processing (1)
  • app/src/main/java/com/messark/hawker/utils/MapGenerator.kt
📝 Walkthrough

Walkthrough

MapGenerator.generateRandomVerticalMap is refactored from a single-pass guaranteed-path carve into a multi-step pipeline using three new private helpers: generateWindingPath (biased random walk with A* fallback), generateClumpedPillars (probabilistic core-and-neighbor growth), and placeDrainStrips (row-based fixed-length segments). Minor cleanups are applied to generateMap and getWeightedFloorVariant.

Changes

MapGenerator procedural generation refactor

Layer / File(s) Summary
generateRandomVerticalMap pipeline
app/src/main/java/com/messark/hawker/utils/MapGenerator.kt
Docs and initialization restructured; old single-pass logic replaced with sequential calls to the three new helpers, tile-type assignment, and drain placement before returning the map.
generateWindingPath biased walk
app/src/main/java/com/messark/hawker/utils/MapGenerator.kt
New private helper performs a neighbor-distance-plus-noise biased walk toward the end coordinate, falling back to Pathfinding.findPath if the walk fails to reach the destination.
generateClumpedPillars and placeDrainStrips
app/src/main/java/com/messark/hawker/utils/MapGenerator.kt
generateClumpedPillars seeds cores from obstruction candidates and expands clumps with probabilistic first/second-level neighbor growth. placeDrainStrips places 4-tile DRAIN segments on eligible FLOOR rows.
generateMap and getWeightedFloorVariant cleanup, changelog
app/src/main/java/com/messark/hawker/utils/MapGenerator.kt, fixes.md
floorVariant assignment in the loader path simplified; getWeightedFloorVariant collapsed to single-line return; REF-017 entry added to fixes.md.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • candour/towerpower#131: Modifies the same generateRandomVerticalMap, generateMap, and getWeightedFloorVariant code paths in MapGenerator.kt.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 71.43% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: a MapGenerator refactor aimed at procedural variety.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor-map-generator-6495807666786743505

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

Build Successful! 🚀

Download APK

Note: This link will be removed when the PR is closed.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 8729180c-153d-47f4-a608-72a732c72706

📥 Commits

Reviewing files that changed from the base of the PR and between 06a2c42 and b032823.

📒 Files selected for processing (2)
  • app/src/main/java/com/messark/hawker/utils/MapGenerator.kt
  • fixes.md

Comment thread app/src/main/java/com/messark/hawker/utils/MapGenerator.kt
@candour
candour enabled auto-merge (squash) June 29, 2026 22:22
@candour

candour commented Jun 29, 2026

Copy link
Copy Markdown
Owner Author

Reject invalid dimensions before sampling positions.

Line 34 crashes for width <= 0, and height <= 0 can return start/end coordinates outside hexes, which downstream path-distance setup expects to be valid map positions.

@google-labs-jules

Copy link
Copy Markdown
Contributor

Reject invalid dimensions before sampling positions.

Line 34 crashes for width <= 0, and height <= 0 can return start/end coordinates outside hexes, which downstream path-distance setup expects to be valid map positions.

Good catch. I've added require checks to ensure width > 0 and height > 1, which prevents the sampling crash and ensures the start and end positions are always within valid map bounds.

- Added `require` checks to ensure `width > 0` and `height > 1` in `generateRandomVerticalMap`.
- This prevents potential crashes during coordinate sampling and ensures start/end positions are valid map positions.
- Addressed PR feedback.

Co-authored-by: candour <4670475+candour@users.noreply.github.com>
@candour
candour merged commit a00aecd into main Jun 29, 2026
3 checks passed
@candour
candour deleted the refactor-map-generator-6495807666786743505 branch June 29, 2026 22:28
@github-actions

Copy link
Copy Markdown

Build Successful! 🚀

Download APK

Note: This link will be removed when the PR is closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant