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
- initialize all the buy/sell variables to -1
- collect a random vector of all trade item ids
- collect a second vector of references to the 2 sell and 2 buy variables.
- Perform a random_shuffle on both vectors.
- while both vectors have elements remaining, take one id and one reference and assign the id to the reference
- repeat until one vector is empty and you have assigned as much as you can and faster than the iterative random assignment below.
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