All done in C++. Let's say that I have two arrays:
int arrElem[]={1,2,3,4};
int arrPref[]={0,2,3,0};
arrElem is an array to elements from witch I must choose and an array of preference. The array of prefrence indicates, let's say, the percentage/10 of preference for it's corresponding element in elements array - with that I want to say:
- element arrElem[0]=1 has no preference
- element arrElem[1]=2 has 20% of preference
- element arrElem[2]=3 has 30% of preference
- element arrElem[3]=4 has no preference
the preference has no higher bound limit but if it's 10 or more, than it's corresponding element is automatically chosen. I can't seem to find a way to write a randomizer that would pick the element this way.
EDIT: to clarify how the chances are calculated for an object:
(100% - (sum of all preferences*10 in set )/ (number of elements in set))+(element preference*10) dont know really what to do with the situation when (sum of all preferences*10 in set ) is more then 100