D
Damage
I'm trying to figure out the algorithms for a football-simulation game.
If I have a series of numbers which represent the skill levels for
various players, what function or combination of functions will return
a random player where a higher skill level means a higher probability
of being returned by the function?
E.g. player A = 5, player B = 10, player C = 50: I want to return a
random player, such that player B is twice as likely to be returned as
player A, and player C is five times more likely to be returned than
player B, etc.
I think a random number between 1 and A+B+C must be involved, but how
to correlate that random number with the different probabilities? (Some
horribly nested IF functions might work, but it could get pretty ugly
if there are a lot of players and the skill values are variable).
Any ideas, you clever people?
If I have a series of numbers which represent the skill levels for
various players, what function or combination of functions will return
a random player where a higher skill level means a higher probability
of being returned by the function?
E.g. player A = 5, player B = 10, player C = 50: I want to return a
random player, such that player B is twice as likely to be returned as
player A, and player C is five times more likely to be returned than
player B, etc.
I think a random number between 1 and A+B+C must be involved, but how
to correlate that random number with the different probabilities? (Some
horribly nested IF functions might work, but it could get pretty ugly
if there are a lot of players and the skill values are variable).
Any ideas, you clever people?