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

Trade items in the market is kinda horrible to assign #188

Open
jt-traub opened this issue May 7, 2024 · 3 comments
Open

Trade items in the market is kinda horrible to assign #188

jt-traub opened this issue May 7, 2024 · 3 comments

Comments

@jt-traub
Copy link
Contributor

jt-traub commented May 7, 2024

There was a bug where if you had < 4 trade items it would infinite loop. That was reported in #54
and I implemented a slightly better fix in (add PR).

An even better solution would be

  1. initialize all the buy/sell variables to -1
  2. collect a random vector of all trade item ids
  3. collect a second vector of references to the 2 sell and 2 buy variables.
  4. Perform a random_shuffle on both vectors.
  5. while both vectors have elements remaining, take one id and one reference and assign the id to the reference
  6. repeat until one vector is empty and you have assigned as much as you can and faster than the iterative random assignment below.
@valdisz
Copy link
Contributor

valdisz commented Jul 15, 2024

The current and proposed change has one big issue. Trade routes are random, too. This creates unbalanced scenarios when a lucky player gets a huge boost in the very important early stages of the game because he has several high-yield trade routes available.

A better algorithm would be to create trade routes first, taking into account city size and distance. Bigger cities would have more trade routes, and longer trade routes would yield bigger profits—all with the intent of making trade routes more homogenous.

@jt-traub
Copy link
Contributor Author

jt-traub commented Jul 15, 2024

Yeah.. this needs an entire re-think/rework.

I am not sure you want trade routes to be homogenous, which would imply that each and every city had exactly the same trade potential, but I think what you do want is 'fair distribution' of high-value routes so that they don't cluster.

I think one way to potentially solve for that would be to have trade goods be somewhat regional (ie, jewelry is much more likely to be sold in cities near mountains and wanted in cities with very few nearby mountains, etc). I think as we evolve into a more complex world-building structure, trade will be able to be (hopefully) factored into that better.

For instance, you see trade goods at production sites on the map, then you seed cities and cities are more likely to spring up around production sites, then you find a reasonable set of markets that want what is produced at those cities.

@jt-traub
Copy link
Contributor Author

With the above stated, this issue was solely about better allocation under the existing system. I would be find changing this to be the more complex one, or opening a separate issue for that.

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

No branches or pull requests

2 participants