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

Update CityLocationTileRanker.kt #12774

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

EmperorPinguin
Copy link
Contributor

@EmperorPinguin EmperorPinguin commented Jan 8, 2025

@itanasi, what do you think of something like this, to let AI settle in better orders (and probably let the settler locations wander less)?

Note that a range of 15 should be enough for most maps, but maybe not enough in huge map marathon games. Also, the distance value 3 should probably be treated differently if we're on a different continent or on the same continent (3 tiles apart can be correct if we're trying to fit cities on a cramped Archipelago map).

@itanasi
Copy link
Contributor

itanasi commented Jan 8, 2025

So this would encourage packing all the cities within 15 tiles of the capital. I don't think the 15 hardcode will be a serious issue. Once all the space is done then there's no additional weight further out.

However, I am concerned about how it's being calculated. This effectively creates a huge hot zone as close to the Capital as possible. Distance 5 is only 1 point better than Distance 4 from the Capital (+38 vs +37)? These values are also super high for the Capital. We go from +8 at distance 6 to +31. So there's no way we will ever settle a chain of cities. Finding 20 points of value elsewhere is incredibly difficult.

The current implementation favors settling closer to neighboring cities but this pretty much makes the Capital overwhelmingly dominant.

@EmperorPinguin
Copy link
Contributor Author

However, I am concerned about how it's being calculated. This effectively creates a huge hot zone as close to the Capital as possible. Distance 5 is only 1 point better than Distance 4 from the Capital (+38 vs +37)? These values are also super high for the Capital. We go from +8 at distance 6 to +31. So there's no way we will ever settle a chain of cities. Finding 20 points of value elsewhere is incredibly difficult.

Chains of cities aren't defendable against suprise attacks. Finding 20 points of value somewhere else is possible; a river hill mountain luxury settle already grants +42 points compared to a settle who doesn't have any of these features. The "hot zone" around capital could indeed be a problem, in case the capital land is worse than expand land. The way map gen and spawn placement works, the capital land is equal to or better then the surrounding land, but there could be cases where settling 6 or 7 tiles away is necessary.

The current implementation favors settling closer to neighboring cities but this pretty much makes the Capital overwhelmingly dominant.

Note that the previous implementations also got a ×2 modifier for the capital. I use aerial distance to capital as a proxy for movement cost. It maybe be faster to settle a chain of cities on flatland first and only then go for the hill regions, but movement is less stable, as it can change based on roads being completed etc.

@EmperorPinguin EmperorPinguin marked this pull request as draft January 10, 2025 10:19
@itanasi
Copy link
Contributor

itanasi commented Jan 10, 2025

The old 2x modifier for Capital made it so there was a bias for a ring around the Capital. But this is adding a flat 38 points of value for being near the Capital!

@EmperorPinguin
Copy link
Contributor Author

The old 2x modifier for Capital made it so there was a bias for a ring around the Capital. But this is adding a flat 38 points of value for being near the Capital!

Yes, I marked it as a draft when I realized it would create undesireable results with mods. Does this look better?

@itanasi
Copy link
Contributor

itanasi commented Jan 11, 2025

Excluding the first 3 rings helps, but again I think the scaling is too large. 20-30 points of value on top of the other ring bonus is a pretty hefty bias. 2x(10-distance) might be more reasonable. That's still 16 at distance=4 and 18 at distance=5, which is similar to the 12 and 16 from the old code. And then we have a smoother gradient as we move from the Capital than the old double weighted ring.

@EmperorPinguin
Copy link
Contributor Author

Excluding the first 3 rings helps, but again I think the scaling is too large. 20-30 points of value on top of the other ring bonus is a pretty hefty bias. 2x(10-distance) might be more reasonable. That's still 16 at distance=4 and 18 at distance=5, which is similar to the 12 and 16 from the old code. And then we have a smoother gradient as we move from the Capital than the old double weighted ring.

A delta of 3 points per tile is needed to prevent settlers from wandering off too far, if I set it lower there's not really a difference compared to the old approach. I considered 15 tiles, as that 3 rings of distance 5 cities, which we won't reach on most maps. I'm not opposed to considering a max of 10 tiles (2 rings of distance 5 cities), but the formula would stop working on very big maps.

@itanasi
Copy link
Contributor

itanasi commented Jan 11, 2025

OK if we need the gradient of 3 to fix the behavior that's fine.

I don't think we need it to reach 15 tiles. At that point the overlapping circles from neighboring cities will do the job of focusing Settlers for us. Remember, the intersection of 2 cities at distance 5 will be around 16 points of value on their own.

@EmperorPinguin EmperorPinguin marked this pull request as ready for review January 11, 2025 19:48
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