Improve Stall Targeting Mode 'FIRST' - #196
Conversation
This change replaces the 'currentPathIndex' based targeting for the 'FIRST' mode with a more accurate 'distance-to-goal' calculation along the available path. Key improvements: - Added 'pathDistances' to GameState to store pre-calculated BFS distances from every tile to the goal. - Updated MainViewModel to recalculate 'pathDistances' whenever the board layout changes (placement, sale, level graduation, etc.). - Refined 'DefaultStallBehavior.selectTarget' to use these distances, combining waypoint progress with remaining path length for high-precision targeting. - Added 'TargetingTest.kt' to verify that enemies on longer paths are correctly deprioritized even if they have higher waypoint indices. - Ensured 'pathDistances' are restored when resuming a saved game. Co-authored-by: candour <4670475+candour@users.noreply.github.com>
|
👋 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 New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
Warning Review limit reached
More reviews will be available in 24 minutes and 40 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the 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 credits. 🚦 How do rate 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 see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe PR adds ChangesPath distances and targeting
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Build Successful! 🚀Note: This link will be removed when the PR is closed. |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 0533f2bc-7c75-4ae7-94e4-644fed737ff7
📒 Files selected for processing (5)
app/src/main/java/com/messark/hawker/MainViewModel.ktapp/src/main/java/com/messark/hawker/model/GameModels.ktapp/src/main/java/com/messark/hawker/registry/Registry.ktapp/src/main/java/com/messark/hawker/utils/Pathfinding.ktapp/src/test/java/com/messark/hawker/TargetingTest.kt
…dd crash safety. This change replaces the 'currentPathIndex' based targeting for the 'FIRST' mode with a more accurate 'distance-to-goal' calculation along the available path. It also adds a safety guard to prevent crashes on empty enemy paths. Key improvements: - Added 'pathDistances' to GameState to store pre-calculated BFS distances from every tile to the goal. - Updated MainViewModel to recalculate 'pathDistances' whenever the board layout changes (placement, sale, level graduation, resume, etc.). - Refined 'DefaultStallBehavior.selectTarget' to use these distances, combining waypoint progress with remaining path length for high-precision targeting. - Added a safety guard in targeting logic that returns a fallback distance (9999f) if an enemy's path is empty, preventing potential 'NoSuchElementException'. - Added 'TargetingTest.kt' with test cases for correct distance-based targeting and crash safety with empty paths. Co-authored-by: candour <4670475+candour@users.noreply.github.com>
Build Successful! 🚀Note: This link will be removed when the PR is closed. |
The 'FIRST' targeting mode for stalls now uses the actual travel distance an enemy needs to cover to reach the goal, rather than just their progress through their current list of waypoints. This ensures consistent behavior even when enemies have paths of different lengths or when the path is redirected.
The implementation uses a BFS-calculated distance map ('pathDistances') that is updated only when the board geometry changes, maintaining high performance during the main game loop. Targeting now calculates the total remaining distance by summing the pre-calculated distance from the enemy's next waypoint to the goal and the axial distance from the enemy's current position to that waypoint.
PR created automatically by Jules for task 3429988393333102126 started by @candour
Summary by CodeRabbit
New Features
Bug Fixes