The context of this is that I am creating a turn-based RPG engine, and each of a set of players has a "speed", which determines the probability of moving earlier in a turn depending on how high it is. The higher the speed, the earlier in the turn the player is expected to move.
I would like to devise an algorithm to determine a random probabilistic turn order based off of these speed values.
The algorithm should have the following properties:
- It is commutative. That is, no matter which player is used as the base for calculations, the algorithm will return the same probability of each turn order occurring.
- It is consistent. The probabilities always add up to 1.
- It handles equality well. When all the players have the same speed, they should have an equal probability of moving first, second, etc. When two players have equal speed, but dominate over the rest, they will have an equal probability between themselves and everybody else will have a lesser amount.
- It is scalable. The same formula should work no matter how many players (even the degenerate case of one) there are.
- It is smooth. That is, it does not suddenly snap from one case to another. If we make the fastest player always move first, the probability of a player moving first snaps from 0 to 1 on the basis of a single point difference, which is bad.
- It preserves priority. That is, if the faster player does not move first, it should have a high probability of moving second, and if it doesn't, then it should have an even higher probability of moving third, etc.
And a few properties that are less important:
- It is adjustable. Depending on how steep the user wants the increase in probability to be, there should be a parameter in the algorithm to account for it, without requiring a complete redesign of the algorithm.
- It handles edge cases well. If we let $s$ be a variable representing the speed of one of the players and $p(s)$ represent the probability that that player moves first, then $\displaystyle \lim_{s \rightarrow \infty} p(s) = 1$.