开发者

Determining Win Percentage from skill level

I am making a program in which two players face each other in "combat", each player have a skill level, represented by a number between 1 and 100, this number is used to determine which player is better so for example if player A has 50 and player B has 100 then B has 50% more chances of winning the combat, What would be a good way of getting this number knowing the skill level of both players?

I tried different ways, for example adding both skill levels and throwing a selecting a random number in this range if the number is less than a player skill then he wins however i am not sure if this is a good way, I think the probability is off. I also tried to use rules, for example if they have the same skill then is 50% (anyone can win) if one is half the other then is 25% chances for the lower player and so on but this gets complicated fast. Any pointers on how to do this calculati开发者_StackOverflow社区on?

Thank you in advance for your help

-hei


if player A has 50 and player B has 100 then B has 50% more chances of winning the combat

If you mean that player B should win twice as often, then this works:

r = random(1, A+B)
if r <= A
  winner = 'A'
else
  winner = 'B'

Winner A will win 50/150 or 1/3 of the time. Winner B will win 2/3 of the time (twice as much).

Maybe you mean for the distance to be the weight. E.g., 10 vs 5 should have a 5% advantage.

Then you could try (assuming B >= A):

r = random(1, 200 + B - A)
if r <= 100 
  winner = 'A'
else
  winner = 'B'

So if A == B then chances are even.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜