根据技能水平确定获胜百分比

发布于 2024-10-03 22:41:37 字数 360 浏览 2 评论 0原文

我正在制作一个程序,其中两个玩家在“战斗”中面对面,每个玩家都有一个技能水平,用 1 到 100 之间的数字表示,这个数字用于确定哪个玩家更好,例如如果玩家 A 有50,玩家 B 有 100,那么 B 赢得战斗的机会多 50%,有什么办法可以让这个数字了解双方玩家的技能水平呢?

我尝试了不同的方法,例如添加两个技能级别并在该范围内选择一个随机数,如果该数字小于玩家技能,那么他获胜,但是我不确定这是否是一个好方法,我认为概率是离开。我还尝试使用规则,例如,如果他们具有相同的技能,则为 50%(任何人都可以获胜),如果一个是另一个的一半,则较低玩家的机会为 25%,依此类推,但这很快就会变得复杂。有关如何进行此计算的任何指示?

预先感谢您的帮助

-hei

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 calculation?

Thank you in advance for your help

-hei

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

二智少女猫性小仙女 2024-10-10 22:41:37

如果玩家 A 有 50 个,玩家 B 有 100 个,那么 B 赢得战斗的机会增加 50%

如果您的意思是玩家 B 获胜的次数应该是玩家 B 的两倍,那么这是有效的:

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

获胜者 A 将赢得 50/150 或 1/3时间。获胜者 B 将赢得 2/3 的时间(两倍)。

也许你的意思是距离就是重量。例如,10 比 5 应该有 5% 的优势。

那么你可以尝试(假设B >= A):

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

所以如果A == B那么机会是偶数。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文