Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly calculate city borders based on culture #556

Open
wants to merge 4 commits into
base: Development
Choose a base branch
from

Conversation

TomWerner
Copy link
Contributor

@TomWerner TomWerner commented Feb 15, 2025

We now have nearly tile-for-tile accuracy with the real game for loaded save files! There is 1 tile that is different from the real game to C7 in the screenshot below, which I've circled.

The difference I suspect is due to rules 7/8 from https://forums.civfanatics.com/threads/the-eight-laws-of-border-dynamics.106882/:

  • VII. If an unassigned tile finds a tile of a single civ directly adjacent to both the NW and SE, it is assigned to that civ.

  • VII. If an unassigned tile finds a tile of a single civ directly adjacent to both the NW and SE, it is assigned to that civ.

I'm not sure the best way to implement this without doing a second pass over all the tiles, but that may be what we need to do.

image

image


This change required changing how we track tile owners, from a player owner to a city owner, so that we can correctly check rank and culture comparisons.

#288

@TomWerner TomWerner force-pushed the twrner/handle-culture-bounds branch 16 times, most recently from 0be3a62 to 23ec25a Compare February 16, 2025 22:59
This doesn't yet implement the benefits of specialists, but it does allow us to force certain tiles to not be worked. This is important when passing tiles between cities, for example.

#541
Unlike with `.SAV` files, scenarios don't specify the tile assignments for each of the citizens in cities. To handle this we backfill them using the tile assignment AI. This is slightly complicated by fact that the `C7Engine` code can't depend directly on the AI logic, so we have to do some dependency injection via an `Action`.

#541
This doesn't yet handle per-turn culture (we'll need building for that) but it should allow us to determine the proper border expansion levels in a following PR, as well as improve the tile assignment logic to restrict things to the BFC.

#541
@TomWerner TomWerner force-pushed the twrner/handle-culture-bounds branch from 23ec25a to af0e501 Compare February 17, 2025 20:18
@KulkoBSW
Copy link
Contributor

IF you use an exponent of 1,8 it is working for all Culture size up to 20K (Which is a victory condition) but it breaks again slightly at 101K, no idea what formula they are using there.
So the better formula should be Power( (Power(abs(X1-x2),1,8) + Power(abs(y1-y2),1,8)), 1/1,8)

@TomWerner TomWerner force-pushed the twrner/handle-culture-bounds branch from af0e501 to 6a473ea Compare February 18, 2025 13:35
@TomWerner
Copy link
Contributor Author

@KulkoBSW nice! I've updated the code and PR description. How'd you figure that out?

We now have nearly tile-for-tile accuracy with the real game for loaded save files! 

I've based this mainly off of https://forums.civfanatics.com/threads/the-eight-laws-of-border-dynamics.106882/, but haven't yet implemented rules 7 or 8
@KulkoBSW
Copy link
Contributor

@TomWerner Have you tested it out with your code. I realize you still have that additional Sqrt in DeltaX/DeltaY and I am not totally sure how that will interfere with my test data. So the exponnent might still be slightly off.

As for How I got this? Studying math in University. changing the exponent changes the roundness of the circle and there is basically no other valid Metric on the plane. So I just wrote an excel to try out different exponents until I found one that fit.

@TomWerner TomWerner force-pushed the twrner/handle-culture-bounds branch from 6a473ea to 9d605d0 Compare February 18, 2025 17:05
@TomWerner
Copy link
Contributor Author

Yeah, I tested it with a quick hack to exponentially increase culture, and it looked good, and I also loaded the save game I was using for testing and updated the screenshot.

The Sqrt(2) factor is needed because this grid is rotated, that factor cancels out the rotation.

@KulkoBSW
Copy link
Contributor

I also checked it out on 5 editor saves and with that addition it works even for Culture 100K, so its probably the correct formula.

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