Skip to content

Instantly share code, notes, and snippets.

@scarvell
Created May 13, 2012 00:36
Show Gist options
  • Save scarvell/2669923 to your computer and use it in GitHub Desktop.
Save scarvell/2669923 to your computer and use it in GitHub Desktop.
PVP Ratings Algo
<?php
$teamA = 2000;
$teamB = 2280;
// If over 2000 rating, lower point cap
$maxPt = ($teamA >= 2000 && $teamB >= 2000) ? 18 : 32; // Max points
$teamApc = 1 / ( 1+pow(10,($teamB - $teamA)/400));
$teamBpc = 1 / ( 1+pow(10, ($teamA - $teamB)/400));
echo '<u>team A won:</u><br />';
echo "Team A: " . $teamA . ' to ' . ceil($teamA + $maxPt *(1 - $teamApc));
echo '<br />';
echo "Team B: " . $teamB . ' to ' . ceil($teamB + $maxPt *(0 - $teamBpc));
echo '<hr />';
echo '<u>Team B Won:</u><br />';
echo "Team A: " . $teamA . ' to ' . ceil($teamA + $maxPt *(0 - $teamApc));
echo '<br />';
echo "Team B: " . $teamB . ' to ' . ceil($teamB + $maxPt *(1 - $teamBpc));
echo '<hr />';
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment