Skip to content
Extraits de code Groupes Projets
Valider 83983361 rédigé par Eliah Rebstock's avatar Eliah Rebstock
Parcourir les fichiers

Fonction ELO qui marche + Test

parent 8e07578d
Aucune branche associée trouvée
Aucune étiquette associée trouvée
2 requêtes de fusion!21Merge de Dev dans Master,!2Dev phoenix
...@@ -16,19 +16,18 @@ ...@@ -16,19 +16,18 @@
function avg_skip($tab, $j) function avg_skip($tab, $j)
{ {
$i = 0; $i = 0;
$s = 0; $s = 0;
while ($i < count($tab)) $n = count($tab);
for($i=0;$i < $n;$i++)
{ {
if ($i != $j) if ($i != $j)
{ {
$s = $s + $tab[$i]; $s = $s + $tab[$i];
} }
$i++;
} }
return $s/(count($tab)-1); return $s/($n-1);
} }
...@@ -51,16 +50,44 @@ function ELO($scores_actuel, $scores_obtenus, $K, $D) ...@@ -51,16 +50,44 @@ function ELO($scores_actuel, $scores_obtenus, $K, $D)
$newS = array(); $newS = array();
$c = max($scores_obtenus)-min($scores_obtenus); $c = max($scores_obtenus)-min($scores_obtenus);
$d = min($scores_obtenus); $d = min($scores_obtenus);
$j = 0;
foreach ($scores_actuel as $A) for ($j=0;$j<count($scores_obtenus);$j++)
{ {
$m = avg_skip($scores_actuel, $j); $m = avg_skip($scores_actuel, $j);
$EA = 1/(1+10^(($m-$A)/$D)); $EA = 1/(1+10**(($m-$scores_actuel[$j])/$D));
$EA = $c * $EA - $d;
$newS[$j] = floor($K * ($scores_actuel[$j]-$EA)); $EA = $c * $EA + $d;
$j++;
}
$newS[$j] = floor($K * ($scores_obtenus[$j]-$EA));
}
return $newS; return $newS;
} }
/* Test */
print("<html><body><table><th>Itération</th><th>Joueur 1</th><th>Joueur 2</th><th>Joueur 3</th><th>Joueur 4</th><th>Joueur 5</th></tr>");
$sa = array(-2,-1,0,1,2);
$DS = array(1000,1000,1000,1000,1000);
print("<tr><td>0</td>");
foreach ($DS as $value) {
print("<td>$value</td>");
}
print("</tr>");
for($j=1;$j<=10;$j++)
{
$res = ELO($DS, $sa, 32, 400);
print("<tr><td>$j</td>");
for ($i=0;$i<count($DS);$i++) {
$DS[$i] = $DS[$i] + $res[$i];
$k1 = $DS[$i];
$k2 = $res[$i];
print("<td>$k1 ($k2)</td>");
}
print("</tr>");
}
print("</table></body></html>");
?>
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment