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

Economic Districts #6345

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

Conversation

bunnybot
Copy link

@bunnybot bunnybot commented Feb 6, 2024

NordfrieseMirrored from Codeberg
Created on Tue Feb 06 19:59:44 CET 2024 by Benedikt Straub (Nordfriese)


Type of change
New feature for v1.3

Issue(s) closed
This addresses several points that arise frequently in the context of very large games – namely the problem of wares (and also workers) being transported across long distances instead of preferring local supplies.

How it works
These points all happen in the background. The UI is unchanged.

Each economy automatically divides itself into districts. A district is centered around a warehouse (multiple warehouses in close proximity are clustered for this purpose), and each flag belongs to the closest warehouse. Thus, a district is a circle around a warehouse or cluster of warehouses.

Districts try to be self-sufficient and minimize imports.
Supply/request matching always prefers to use supplies from the same district. Imports are only accepted if no local supply is available.

New: All active long-distance imports are frequently monitored, and if a ware becomes available in the local district, the import is cancelled and replaced with the local ware. This type of supply exchanging was previously always rejected as too CPU-intensive, but this approach is performant and catches all the cases where it matters most.

Additionally, economy targets are distributed across districts. Global targets (global here meaning within one economy) continue to work as before. In addition, if a district is short of a specific ware, then the productionsites within this district keep producing even if the global stock is above target. Each district's local target is simply the global target divided by number of districts, rounding up.

Possible regressions
Economic request/supply matching, economy targets.

Screenshots
grafik grafik

Additional context
Nothing here needs to be saveloaded. This is all recalculated lazily every few seconds.
Benchmark for a nearly completely conquered Accurate Europe 1.0 map, Release build:

[00:02:38.430 real] INFO: NOCOM Recalcing districts for 5376 flags and 34 warehouses took 7 ms
[00:02:38.434 real] INFO: NOCOM Checking imports for 5376 flags and 34 warehouses took 3 ms

Flags at the border between two districts tend to jitter between the two possible districts due to pseudo-randomness in the routing algorithm. I would not consider this a problem.

Could do with more testing, both with big economies and with small ones. I'd therefore like to have this early in the release cycle for v1.3.

@bunnybot bunnybot added this to the v1.3 milestone Feb 6, 2024
@bunnybot bunnybot changed the title WIP: Economic Districts Economic Districts Feb 6, 2024
@bunnybot bunnybot self-assigned this Feb 6, 2024
@bunnybot
Copy link
Author

bunnybot commented Feb 6, 2024

Assigned to Nordfriese

@bunnybot bunnybot added enhancement New feature or request balancing & gameplay Tribes' statistics & mechanics economy Ware priority & transport, worker creation & assignment, requests & supplies, trading pathfinding Fugitives, ships, routing, … under discussion There is no consensus about a critical point yet labels Feb 6, 2024
@bunnybot bunnybot changed the title Economic Districts WIP: Economic Districts Feb 11, 2024
@bunnybot
Copy link
Author

frankystoneMirrored from Codeberg
On Tue Feb 20 15:14:18 CET 2024, ** (frankystone)* wrote:*


Does this change anything related to economy worker settings?

In the attached save game the barracks produce soldiers endlessly, 'stealing' the wares needed to create heroes. Starting this save game in master the soldier production stops, because economy setting says 10 soldiers and there are already more than 40 sitting around.

In debug builds the game stutters for me every time the district calculation is made. Probably because of the debug things.

@bunnybot
Copy link
Author

bunnybot commented Feb 20, 2024

NordfrieseMirrored from Codeberg
On Tue Feb 20 15:48:29 CET 2024, Benedikt Straub (Nordfriese) wrote:


Ah yes…
if you have 4 warehouses and a soldier target setting of 10, then each warehouse's district target is ceil(10/4) = 3 soldiers. However the barracks is in the HQ district and the HQ's stock policy for soldiers is kRemove, so the barracks district can never reach its local target.

So for districts where a ware/worker is not meant to be stored in warehouses this check won't work. And if some other (foreign) warehouse has a Prefer policy for that ware/worker but we don't Prefer it locally then too it won't work.

I'll create a commit to take these stock policies into account and skip the local target check if the warehouse policies interfere with district target distribution.


In debug builds the game stutters for me every time the district calculation is made. Probably because of the debug things.

For me debug builds with such large maps stutter on every economy update anyway ;) What times does the log print out for district recalculation and imports checking? For me this is always 1ms each with your savegame in a debug build (i.e. negligibly fast).

@bunnybot bunnybot added the ci:success CI checks succeeded label Apr 11, 2024
@bunnybot bunnybot added ci:success CI checks succeeded and removed ci:success CI checks succeeded labels Apr 20, 2024
@bunnybot bunnybot added ci:success CI checks succeeded and removed ci:success CI checks succeeded labels Apr 25, 2024
@bunnybot bunnybot added ci:fail CI checks failed and removed ci:success CI checks succeeded labels May 6, 2024
@bunnybot bunnybot added ci:fail CI checks failed and removed ci:fail CI checks failed labels May 17, 2024
@bunnybot bunnybot added ci:success CI checks succeeded and removed ci:fail CI checks failed labels May 20, 2024
@bunnybot bunnybot added ci:success CI checks succeeded and removed ci:success CI checks succeeded labels May 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
balancing & gameplay Tribes' statistics & mechanics ci:success CI checks succeeded economy Ware priority & transport, worker creation & assignment, requests & supplies, trading enhancement New feature or request pathfinding Fugitives, ships, routing, …
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants