Coder Social home page Coder Social logo

geniusye / moreeffectivetransfer Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pcfantasy/moreeffectivetransfer

0.0 1.0 0.0 4.85 MB

Cities: Skylines Mod: Optimize transfer manager in vanilla game. match the shortest transfer bettween offers

Home Page: https://steamcommunity.com/sharedfiles/filedetails/?id=2747441985

License: MIT License

C# 100.00%

moreeffectivetransfer's Introduction

Inner workings

This is a continuation of pcfantasy's More Effective Transfer Manager (https://steamcommunity.com/sharedfiles/filedetails/?id=1680840913).

He was so kind as to license his code under the MIT license for us, so if you like this mod, please take the time to go to the above posting and show your appreciation for his original work!

The core code for the match-making logic has been mostly completely rewritten, but with pcfantasy's original idea and design in mind.

This mod is compatible with the Airports DLC and the accompanying base game patch

What it does

The vanilla transfer managers handles service requests and goods transfers by matching highest priority orders (incoming and outgoing) first, regardless of distance. The observed effect is that trucks go from A to B, and from B to A; fire response is inefficient if fire fighters have to rush through heavy traffic across the map, and problems such as garbage or crime are unattended for longer than necessary.
You can learn more about the inner workings of the vanilla transfer manager by reading the excellent article here: https://jamesmonger.com/2021/02/24/cities-skylines-trading-market.html

This mod attempts to improve the situation by:

  • Optimizes the service dispatching and goods transfer for industries. All match-making between supply & demand is done by shortest distance ("as the crow flies", not actual pathfinding distance!).
  • Serves highest priority requests (=more urgent problems) first, working its way down the queue (like vanilla).
  • Different match-making modes carefully selected per service / goods: OUTGOING_FIRST (most services), INCOMING FIRST (transfers and maintenance), and BALANCED (goods).
  • Additional options to further improve service locality and warehouse effectiveness. If they work as intended heavily depends on how your city is structured, though. YMMV.

What it does not

It does not restrict any citizen activities: citizens go to any school as they like, they go shopping wherever they please, they pick a work place as they want, and they dont just go to the nearby park, instead travelling all across the city to the fancy 5* zoo.
This is intentional - the Cims value their freedom and certainly dont accept being restricted to their district...

This mod does not change the match-making to use actual pathfinding distance/routing. Using that would be very costly without optimized data structures and algorithms, and cannot be easily done.

Settings and their effect

Prefer local district services (recommended to enable)

Affects: garbage, police, health care, maintenance, mail, taxi
This setting further improves locality of services by further restricting the matchmaking:
All low priority outgoing transfer requests will only match with services from the same district. If no matching services from the same district are available, the request is unfulfilled. As the problem (garbage, crime, ...) accumulates, the request will gain urgency and increase priority. Once reaching hiher priority it will be matched to fulfill, regardless of district restrictions (but still with a bias towards local district services).
Effect:
While not quite duplicating mods such as DistrictServiceLimit or EnhancedDistrictServices, it ensures that most services stay local as much as possible, while at the same time ensuring that high priority requests will eventually be serviced, even if that means a service has to "rush across the map".

Warehouse First (recommended to enable)

Affects: warehouse goods deliveries
This setting makes all incoming and outgoing goods deliveries prefer warehouses as source/destination.
Effect:
This can help a lot in city logistics if there are some well-placed warehouses as "buffers" between industry & commercial, or industrial producers & consumers. Note that this can make things worse if you do not have strategically well-placed warehouses, and will in general increase traffic around warehouse routes.

Reserve Warehouse Trucks for local transfer (recommended to enable if Warehouse First is used)

Affects: warehouse goods exports
This setting will prevent all warehouses from using all their trucks to export goods out of the city. A contigent of trucks will be held in reserve and will only be used to fulfill requests from consumers within the city.
The setting's effect is:

  • 25% capacity reserved at all times.


Limits

There is obviously a conflict between the "higher priority first" approach and the "closed distance preferred" approach. In particular, preferring matchmaking by closest distance cannot fully prevent that buildings get serviced by service buildings from far away. That is because a more suitable, closer service offer might have already been matched to a higher priority request, so now the closer building has no choice but be matched with an offer from a service further away.

This whole situation cannot be easily prevented, and would rather require a complete redesign of the offer matchmaking system, with a "global optimization" approach (instead of the current "line-by-line, from high to low priority" approach).

TLDR: you notice in your city that garbage trucks go from A to B, and from B to A, and you think this mod is not doing its' job. This mod usually reduces these situations, but cannot fully prevent them.

For reference also see original user guide / wiki by pcfantasy:

MoreEffectiveTransfer User Guide Steam Downloads

English version

MoreEffectiveTransfer 说明书

MoreEffectiveTransfer 模组说明书

Impact and Performance

As of version 2.1.0.220303 the match-making is run on a background thread, reducing the burden for the game's main simulation thread. There is some performance improvement over vanilla due to this, although most likely this wont translate to higher frame rate.
Vanilla transfer manager on a large city: 0.6ms time per run
METM on the same city: ~0.45ms time per run

Source Code

On Github: https://github.com/TheDogKSP/MoreEffectiveTransfer
License: MIT
Be sure to always respect pcfantasy's original copyright!
This mod uses the Harmony2 library by Andreas Pardeike.

Incompatible mods:

(1) Original More Effective Transfer Manager by pcfantasy. Please completely unsubscribe original before using this one.
(2) District Service Limit (any version)
(3) Enhanced District Services
(4) Transfer Broker - MALWARE WARNING! DO NOT USE!

Recommended mods:

(1) I highly recommend to use this mod in conjunction with "Smarter Firefighters: Improved AI" by themonthlydaily (https://steamcommunity.com/sharedfiles/filedetails/?id=2346565561).
While METM ensures that your fires are serviced by the cloeset fire department, Smarter Firefighters will make each fire truck (or copter) vehicle work relentlessly until everything is extinguished before calling it a day and returning to the station. With both mods together your city fire fighting force will actually be quite effective in containing and putting out fire spread.

Contributions wanted

Contributions in the form of Github Pull Requests are welcome! Unfortunately with the rewrite of this mod the original localizations have been lost. If you want to provide a localization to any language, this is always welcome!

moreeffectivetransfer's People

Contributors

gab avatar geniusye avatar notaproton avatar pcfantasy avatar shg166 avatar tchelow avatar twotoolus-fly-lshst avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.