Skip to content

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

Description

@jt-traub

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew engine feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions