Edit: Problem solved
I'm trying to port over a popular rating algorithm which analyses some statistics from Counter-Strike matches into a PHP script. The outline of the system can be found in the link below (the bottom part of the news post): http://www.hltv.org/?pageid=242&eventid=0
Anyway, so I've get everything set up in PHP, and I'm reasonably sure that everything is correct. For the purposes of calcuation, assume that:
$rating1K = 5;
$rating2K = 8;
$rating3K = 3;
$rating4K = 0;
$rating5K = 0;
$kills = 30
$deaths = 19
$round = 30
This is my code:
$kpr = $kills / $round; // kills per round
$killRating = ($kills / $round / $kpr);
$spr = ($round - $deaths) / $round; // survivals per round
$survivalRating = ($round - $deaths) / $round / $spr;
$averageRMK = ((1*$rating1K + 4*$rating2K + 9*$rating3K + 16*$rating4K + 25*$rating5K)/$round);
$roundsWithMultipleKillsRating = ((1*$rating1K + 4*$rating2K + 9*$rating3K + 16*$rating4K + 25*$rating5K)/$round/$averageRMK);
$rating = ($killRating + 0.7 * $survivalRating + $roundsWithMultipleKillsRating) / 2.7;
echo $rating;
The problem is that $killRating, $survivalRating and $roundsWithMultipleKillsRating always seem to return 1 in the PHP script, whereas if I calculate them manually myself they are different. For example, if I calculate $killRating myself, I get 1.5789-etc, but PHP returns "1".
What can I do this fix this problem?
Thanks a lot.
You are calculating wrong...
$kpr = $kills / $round; // kills per round
$killRating = ($kills / $round / $kpr);
equals
$kpr = 30 / 30; // 1
$killRating = (30 / 30 / 1); //1
And
$spr = ($round - $deaths) / $round; // survivals per round
$survivalRating = ($round - $deaths) / $round / $spr;
equals
$spr = (30 - 19) / 30; // 0.36666
$survivalRating = (30 - 19) / 30 / 0.3666; // 1
Your own calculation is wrong. PHP does everything fine here.
Please note that kpr being $kill/$round, when you devide $kill/$round/$kpr it will always be 1. Any number divided by itself equals 1. I can't beleive everyone is talking about floats and integers without even understanding mathematics...