Skip to content

Conversation

@djmrFunnyMan
Copy link
Contributor

Description:

This PR increases the iteration cap for warships & transports, until a better solution can be found.

Fixes the issue where warships & transports break when pathfinding very far away.

Please complete the following:

  • I have added screenshots for all UI updates
  • I process any text displayed to the user through translateText() and I've added it to the en.json file
  • I have added relevant tests to the test directory
  • I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced
  • I have read and accepted the CLA agreement (only required once).

Please put your Discord username so you can be contacted if a bug or regression is found:

aceralex

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 26, 2025

Walkthrough

The changes increase the maximum search limits and adjust configuration parameters for pathfinding logic in three files related to ship execution and deployment. Only numeric values and flags passed to pathfinding constructors or methods have been updated, with no changes to logic, error handling, or control flow.

Changes

Files Change Summary
src/core/execution/TransportShipExecution.ts Increased the fourth argument of PathFinder.Mini from 10 to 100 in the TransportShipExecution class.
src/core/execution/WarshipExecution.ts Increased PathFinder.Mini max distance from 5000 to 10000, set third param to true, fourth to 100.
src/core/game/TransportShipUtils.ts Increased MiniAStar max iterations from 500,000 to 1,000,000 in bestShoreDeploymentSource.

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant TransportShipExecution
    participant WarshipExecution
    participant PathFinder
    participant MiniAStar

    Caller->>TransportShipExecution: initialize()
    TransportShipExecution->>PathFinder: Mini(..., ..., ..., 100)

    Caller->>WarshipExecution: initialize()
    WarshipExecution->>PathFinder: Mini(10000, ..., true, 100)

    Caller->>TransportShipUtils: bestShoreDeploymentSource()
    TransportShipUtils->>MiniAStar: new(..., 1000000)
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~6 minutes

Suggested labels

Performance Optimization

Suggested reviewers

  • evanpelle
  • tnhnblgl

Poem

🚢 Ships now search both far and wide,
With numbers raised, they will not hide.
Through waves of code, their paths expand,
With journeys mapped by careful hand.
So let the ships explore anew—
A million steps, and all for you!
⛵✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

npm error Exit handler never called!
npm error This is an error with npm itself. Please report this error at:
npm error https://github.com/npm/cli/issues
npm error A complete log of this run can be found in: /.npm/_logs/2025-07-26T16_35_03_335Z-debug-0.log

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4a38561 and 0704d31.

📒 Files selected for processing (3)
  • src/core/execution/TransportShipExecution.ts (1 hunks)
  • src/core/execution/WarshipExecution.ts (1 hunks)
  • src/core/game/TransportShipUtils.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (4)
📓 Common learnings
Learnt from: andrewNiziolek
PR: openfrontio/OpenFrontIO#1007
File: resources/lang/de.json:115-115
Timestamp: 2025-06-02T14:27:37.609Z
Learning: For OpenFrontIO project: When localization keys are renamed in language JSON files, the maintainers separate technical changes from translation content updates. They wait for community translators to update the actual translation values rather than attempting to translate in the same PR. This allows technical changes to proceed while ensuring accurate translations from native speakers.
Learnt from: jrouillard
PR: openfrontio/OpenFrontIO#848
File: src/core/execution/TradeShipExecution.ts:125-127
Timestamp: 2025-05-22T23:48:51.113Z
Learning: In TradeShipExecution, the path length is already checked in the computeNewPath() function. If the path is empty, it returns PathFindResultType.PathNotFound instead of PathFindResultType.Completed, making additional empty path checks unnecessary when handling the Completed case.
Learnt from: VariableVince
PR: openfrontio/OpenFrontIO#957
File: resources/maps/GatewayToTheAtlantic.json:175-179
Timestamp: 2025-05-30T16:16:27.118Z
Learning: In OpenFrontIO project, flag values in map JSON files (like GatewayToTheAtlantic.json) should match the actual flag file names in the resources directory (e.g., "French foreign legion" corresponds to "French foreign legion.svg"). The naming convention follows the file naming system rather than code naming conventions.
Learnt from: scottanderson
PR: openfrontio/OpenFrontIO#786
File: src/client/TerritoryPatternsModal.ts:337-338
Timestamp: 2025-06-22T05:48:19.241Z
Learning: In src/client/TerritoryPatternsModal.ts, the bit shifting operators (<<) used in coordinate calculations with decoder.getScale() are intentional and should not be changed to multiplication. The user scottanderson confirmed this is functioning as intended.
src/core/execution/TransportShipExecution.ts (2)

Learnt from: jrouillard
PR: #848
File: src/core/execution/TradeShipExecution.ts:125-127
Timestamp: 2025-05-22T23:48:51.113Z
Learning: In TradeShipExecution, the path length is already checked in the computeNewPath() function. If the path is empty, it returns PathFindResultType.PathNotFound instead of PathFindResultType.Completed, making additional empty path checks unnecessary when handling the Completed case.

Learnt from: scottanderson
PR: #784
File: src/core/game/StatsImpl.ts:125-134
Timestamp: 2025-05-19T06:00:38.007Z
Learning: In StatsImpl.ts, unused parameters in boat/stats-related methods are intentionally kept for future use and shouldn't be removed.

src/core/game/TransportShipUtils.ts (4)

Learnt from: scottanderson
PR: #786
File: src/client/TerritoryPatternsModal.ts:337-338
Timestamp: 2025-06-22T05:48:19.241Z
Learning: In src/client/TerritoryPatternsModal.ts, the bit shifting operators (<<) used in coordinate calculations with decoder.getScale() are intentional and should not be changed to multiplication. The user scottanderson confirmed this is functioning as intended.

Learnt from: scottanderson
PR: #784
File: src/core/game/StatsImpl.ts:125-134
Timestamp: 2025-05-19T06:00:38.007Z
Learning: In StatsImpl.ts, unused parameters in boat/stats-related methods are intentionally kept for future use and shouldn't be removed.

Learnt from: jrouillard
PR: #848
File: src/core/execution/TradeShipExecution.ts:125-127
Timestamp: 2025-05-22T23:48:51.113Z
Learning: In TradeShipExecution, the path length is already checked in the computeNewPath() function. If the path is empty, it returns PathFindResultType.PathNotFound instead of PathFindResultType.Completed, making additional empty path checks unnecessary when handling the Completed case.

Learnt from: jrouillard
PR: #848
File: src/core/execution/TradeShipExecution.ts:110-134
Timestamp: 2025-05-22T23:43:54.789Z
Learning: In the OpenFrontIO project, MiniAStar.compute() only returns PathFindResultType.Pending, PathFindResultType.Completed, or PathFindResultType.PathNotFound - it doesn't return PathFindResultType.NextTile. When PathFindResultType.Completed is returned, the full path can be retrieved via reconstructPath().

src/core/execution/WarshipExecution.ts (2)

Learnt from: jrouillard
PR: #848
File: src/core/execution/TradeShipExecution.ts:125-127
Timestamp: 2025-05-22T23:48:51.113Z
Learning: In TradeShipExecution, the path length is already checked in the computeNewPath() function. If the path is empty, it returns PathFindResultType.PathNotFound instead of PathFindResultType.Completed, making additional empty path checks unnecessary when handling the Completed case.

Learnt from: scottanderson
PR: #784
File: src/core/game/StatsImpl.ts:125-134
Timestamp: 2025-05-19T06:00:38.007Z
Learning: In StatsImpl.ts, unused parameters in boat/stats-related methods are intentionally kept for future use and shouldn't be removed.

🧬 Code Graph Analysis (3)
src/core/execution/TransportShipExecution.ts (1)
src/core/pathfinding/PathFinding.ts (1)
  • PathFinder (88-189)
src/core/game/TransportShipUtils.ts (1)
src/core/pathfinding/MiniAStar.ts (1)
  • MiniAStar (29-89)
src/core/execution/WarshipExecution.ts (1)
src/core/pathfinding/PathFinding.ts (1)
  • PathFinder (88-189)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: 🏗️ Build
🔇 Additional comments (3)
src/core/game/TransportShipUtils.ts (1)

151-151: Good increase in pathfinding iterations for long-distance routes.

The doubled iteration limit from 500,000 to 1,000,000 should help resolve pathfinding failures over very long distances as described in the PR objectives. The parameter placement and value are correct for the MiniAStar constructor.

src/core/execution/TransportShipExecution.ts (1)

67-67: Correct increase in pathfinding max tries parameter.

Increasing maxTries from 10 to 100 gives the pathfinder more attempts to find valid routes, which should help with long-distance transport ship navigation. The parameter order and value are correct for PathFinder.Mini.

src/core/execution/WarshipExecution.ts (1)

30-30: Well-coordinated pathfinding parameter updates.

The changes properly increase iterations from 5,000 to 10,000, explicitly enable water pathing, and set maxTries to 100. This aligns with similar updates in TransportShipExecution and provides warships with enhanced pathfinding capabilities for long-distance navigation.


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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@evanpelle evanpelle added this to the v24 milestone Jul 26, 2025
@github-project-automation github-project-automation bot moved this from Triage to Final Review in OpenFront Release Management Jul 26, 2025
@evanpelle evanpelle merged commit 67dea7c into openfrontio:main Jul 26, 2025
9 of 10 checks passed
@github-project-automation github-project-automation bot moved this from Final Review to Complete in OpenFront Release Management Jul 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Complete

Development

Successfully merging this pull request may close these issues.

2 participants