Skip to content

Conversation

@stavrosfa
Copy link
Contributor

  1. Bug fix where an ocean tile cannot be assigned if the city is at expansion level greater than 2.
  2. Added more conditions to how a tile ownership is determined, and how/if unassigned tiles are correctly assigned to a city.

// Ocean tiles may only hold claims of rank 2.
The current version has a bug, it should check if the tile is more than rank 2, not the city's current expansion level.
Case study: (Scenario) WWII In the Pacific
City: Manokwari (Above Australia)
Tiles: [37, 71] [38, 72] should belong to the city

You can also see this with Tokyo as well, it skips a row of tiles because its expansion level is more than 2, but the tiles themselves aren't.

I have tested this mostly with the Conquests scenarios that come with the game. There a few minor discrepancies, but I think they are temporary, as you play either game (openCiv3/original), they iron out.

…xpansion level greater than 2.

2. Added more conditions to how a tile ownership is determined, and how/if unassigned tiles are correctly assigned to a city.
return map.tileAt(XCoordinate + xDelta, YCoordinate + yDelta);
}

public Tile FindInRing(int rank, Func<Tile, bool> predicate, bool clockwise = true) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need this in addition to GetTilesWithinRankDistance, which returns things in spiral order?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

GetTilesWithinRankDistance returns tiles in a big fat cross style. I tried to use it, but for borders, although it's fine for the first rank, the 2nd rank doesn't include a NN, WW, EE or SS tile. This method goes around the "actual" ring around a tile. I called it ring to distinguish it from rank, which behaves differently.
I hope that makes sense.

Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense, thanks! Could you put that in a comment on the method to explain how it's different and why we need it?

@stavrosfa
Copy link
Contributor Author

Played about 2 games of 200 rounds each, skipping animations etc, only building Temples, Libraries and whatever would give me culture points, did not come across any after the latest fix.
Tom, let me know when you have a look again, I'd like your OK again before I merge it.

return null;
}

private bool IsInValidCoordinates(int dx, int dy, out Tile currentTile) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, apparently adding a comment on a commit doesn't show up in the review (the GitHub code review tool suuuuuucks)


A couple of questions from my comment on the commit:

  • Why "dx" and "dy" if these are absolute positions, not deltas?
  • Is the method name "is in valid coordinates" or "is invalid coordinates"? Would "GetTileIfValid" work, and have the return type be Tile??
  • How is this function different from map.tileAt which I believe does the tile wrapping for us

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry I missed the part where map.tileAt was wrapping, to be honest I just checked that it returns a Tile.None and not a null.
Thanks for the feedback!

@stavrosfa
Copy link
Contributor Author

stavrosfa commented Dec 7, 2025

I found that for the tiles that are opposite to each other and need to be filled in, Law II (Ocean tiles may only hold claims of rank 2.) was not being applied.
Because a picture will explain it better than I could :

OeanTiles

Top row is the original game, bottom left what we had before and on the right what we have after this fix.
The tile with the X should not be part of our city, because its rank is larger than 2.

I refactored the method that was calculating because there was too much duplication, really without any good reason.

I had to also refactor the ResolveTileOwnershipConflict method, because we somehow have to assign null to a tile that doesn't belong to a city and the bool/out City setup made more sense to me.

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.

2 participants