php正常分配奖金

时间:2012-11-05 22:39:11

标签: php

好吧,我想要分发1000分。

我有200名排名玩家,但我不想均匀分发它们。

相反,我想扭曲它,以便顶部的球员往往比顶部的球员少。因此,我需要某种能够激发正态分布一方的功能。

我该怎么做?

1 个答案:

答案 0 :(得分:0)

function grantPoints($totalavailpoints, $numusers, $rank){
  $pointstogrant=$totalavailpoints/$numusers;
  if($rank>$numusers/2)//he has a higher number rank, meaning he gets more points
    $pointstogrant++;
  else
    $pointstogrant--;
  return $pointstogrant;
}

很多方法可以根据您的需要进行调整。但这是非常基本的。它计算出给出的平均点数,如果你在下半部分则增加一个,如果你在上半部分则减去一个。

要问自己几个问题:

  • 返回的点数必须是整数吗?
  • 每个人的积分总和是否必须等于totalavailpoints?
  • 您在函数中返回的金额中您想要/需要多少多样性?
相关问题