sobisonator / imp19c

Imperator 19th century mod
10 stars 15 forks source link

Trade ranking optimisation #421

Closed sobisonator closed 2 months ago

sobisonator commented 7 months ago

The simplest way to improve performance would be to cache preferred tradezones for every tradegood, in every tradezone, at the start of the trade tick. ATM it ranks it for every purchase, which is great for cases where the order size isn't big enough to warrant spending more on transport for a cheaper unit cost, but I actually have no idea how often that happens Chances are, caching the values with a flat estimated order size at the beginning of the tick will be a close enough approximation, and if it can save several seconds of execution time, a huge boon.

Instead of every purchase order triggering a ranking exercise, at the beginning of the trade tick, every tradezone will perform a ranking exercise of every other tradezone, with every tradegood.

Do something like... Multiply the price of the tradegood by 50 (simulate order size of 50), or some other number that approximates the average order size. Add the transport cost between origin TZ and origin TZ Rank them and assign rank variables within the TZ scope When purchase orders are checking for which TZ to buy from, consult the cached ranks in the TZ scope, don't bother doing a new exercise.

sobisonator commented 2 months ago

Resolved since GLOBALTRADE has been implemented