fix (pathfinding): prioritize best connected water neighbor in ShoreCoercingTransformer (#2937)

## Description:

**Describe the PR.**

This PR improves how pathfinding finds a starting water tile when
launching a transport ship from a shore.

Previously, the code simply picked the first water neighbor it found.
This caused issues where, if a boat were traveling east, it might launch
out of a northern tile from a shore.

<img width="896" height="353" alt="image"
src="https://github.com/user-attachments/assets/69d83012-3397-43b3-8ab0-9ebde6ffea97"
/>

<img width="342" height="219" alt="image"
src="https://github.com/user-attachments/assets/a191f5cf-97da-4e34-a191-55ce14c794f0"
/>

The new logic checks all water neighbors and picks the "best" one by
counting how many water tiles surround it. This ensures transport ships
launch into the main body of water instead of suboptimal positions.

If two tiles have water neighbors with the same score, they are
tie-broken through a euclidean distance check.

## Please complete the following:

- [X] I have added screenshots for all UI updates
- [X] I process any text displayed to the user through translateText()
and I've added it to the en.json file
- [X] I have added relevant tests to the test directory
- [X] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced

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

Scisyph

---------

Co-authored-by: WilliamT-byte <williamt2023@tamu.edu>
Co-authored-by: Ryan <7389646+ryanbarlow97@users.noreply.github.com>
This commit is contained in:
WillTHomeGit
2026-01-18 15:19:55 +00:00
committed by GitHub
co-authored by WilliamT-byte Ryan
parent c179249cdd
commit c123adc0ef
2 changed files with 27 additions and 16 deletions
+2 -2
View File
@@ -47,8 +47,8 @@ export class PathFinding {
return PathFinderBuilder.create(pf)
.wrap((pf) => new ComponentCheckTransformer(pf, componentCheckFn))
.wrap((pf) => new SmoothingWaterTransformer(pf, miniMap))
.wrap((pf) => new ShoreCoercingTransformer(pf, miniMap))
.wrap((pf) => new MiniMapTransformer(pf, game.map(), miniMap))
.wrap((pf) => new ShoreCoercingTransformer(pf, game.map()))
.buildWithStepper(tileStepperConfig(game));
}
@@ -57,8 +57,8 @@ export class PathFinding {
const pf = new AStarWater(miniMap);
return PathFinderBuilder.create(pf)
.wrap((pf) => new ShoreCoercingTransformer(pf, miniMap))
.wrap((pf) => new MiniMapTransformer(pf, game.map(), miniMap))
.wrap((pf) => new ShoreCoercingTransformer(pf, game.map()))
.buildWithStepper(tileStepperConfig(game));
}