mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-09-04 17:08:40 +00:00
This commit is contained in:
parent
cb4c61fb5b
commit
6611f2bd52
|
|
@ -88,9 +88,15 @@ final class Elo
|
||||||
*/
|
*/
|
||||||
public function winProbability(int $elo1, int $elo2, bool $canDraw = false) : float
|
public function winProbability(int $elo1, int $elo2, bool $canDraw = false) : float
|
||||||
{
|
{
|
||||||
return $canDraw
|
$expectedWin = 1 / (1 + \pow(10, ($elo2 - $elo1) / 400));
|
||||||
? -1.0 // @todo implement
|
|
||||||
: 1 / (1 + \pow(10, ($elo2 - $elo1) / 400));
|
if (!$canDraw) {
|
||||||
|
return $expectedWin;
|
||||||
|
}
|
||||||
|
|
||||||
|
$draw = $this->drawProbability($elo1, $elo2);
|
||||||
|
|
||||||
|
return (1.0 - $draw) * $expectedWin;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -105,6 +111,12 @@ final class Elo
|
||||||
*/
|
*/
|
||||||
public function drawProbability(int $elo1, int $elo2) : float
|
public function drawProbability(int $elo1, int $elo2) : float
|
||||||
{
|
{
|
||||||
return -1.0; // @todo implement
|
$diff = \abs($elo1 - $elo2);
|
||||||
|
|
||||||
|
// Approximate draw probability: highest when ratings are equal,
|
||||||
|
// decreasing smoothly as the rating difference increases.
|
||||||
|
$maxDraw = 0.30;
|
||||||
|
|
||||||
|
return $maxDraw * \exp(-($diff ** 2) / (2 * (200 ** 2)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,7 @@ final class TesseractOcrTest extends \PHPUnit\Framework\TestCase
|
||||||
* @group framework
|
* @group framework
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
@todo somehow this suddenly takes a long time.
|
this takes a long time.
|
||||||
Might be because a php version update resulting in float 32->64bit changes?
|
Might be because a php version update resulting in float 32->64bit changes?
|
||||||
Fix it, it was working with php 8.0
|
Fix it, it was working with php 8.0
|
||||||
public function testOcrWithThresholdingRotating() : void
|
public function testOcrWithThresholdingRotating() : void
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user