moserware / phpskills Goto Github PK
View Code? Open in Web Editor NEWAn implementation of the TrueSkill algorithm in PHP
Home Page: http://www.moserware.com/2010/03/computing-your-skill.html
License: Other
An implementation of the TrueSkill algorithm in PHP
Home Page: http://www.moserware.com/2010/03/computing-your-skill.html
License: Other
sh-4.2$ php phpunit.phar src/Moserware/UnitTests/TrueSkill/FactorGraphTeamTrueSkillCalculatorTest.php
PHP Deprecated: Comments starting with '#' are deprecated in /etc/php5/cli/conf.d/ming.ini on line 1 in Unknown on line 0
PHPUnit 4.7.6 by Sebastian Bergmann and contributors.
PHP Fatal error: Class 'Moserware\Skills\TrueSkill\Layers\InvalidOperationException' not found in /var/www/test/PHPSkills/src/Moserware/Skills/TrueSkill/Layers/IteratedTeamDifferencesInnerLayer.php on line 55
Would love to use this, unfortunately Unit Tests fails with exception
I'm trying to implement this for a sporting event, which could have anything up to 1000 competitors.
I find with 20/30/40/50 competitors it works perfectly, and speedily - typically less than 0.2 second.
But as soon as I go to 60 competitors, it takes over 30 seconds and times out.
Do you have any idea why this would be? Any pointers appreciated, many thanks!
Thanks again for these beautiful maths!
I got into trouble with a strict PHP configuration, saying "Runtime Notice: Only variables should be assigned by reference in /home/con/www/lab/Moserware/Skills/HashMap.php line 36 "
When I disable the strict mode (or at least disable notices in php's error_reporting()) it works and I get a calculation. Unfortunately, I need the strict mode and all notices for the development to easier find bugs and the framework I'm using (Symfony2) even throws full Exceptions on notices (thanks to xdebug) so I can't even ignore a notice, even though I'd like to.
So I was trying to get rid of all ampersands as I don't fully understand the php 5.3 runtime notice for references - thought anything is a reference by now.. - seems it is not.. so unfortunately I broke the whole environment and some unit tests are totally going nuts..
Maybe you find some time to take a look over this, this is the commit where I radiacally (blindly, but not search & replace ;) removed the ampersands
bartrail@c61ca4e
and this is one of the tests that failed and I was trying to manually find out which else is failing in this TwoTeam Test case (came out this was it) - so I revered the unit test values in my fork back to the original ones, but maybe this can help you to locate which ampersand &reference is really needed...
bartrail@389665e
Cheers,
Conrad
Any chance you'd be interested in adapting this to support TrueSkill 2? Apparently it is significantly more accurate.
https://www.microsoft.com/en-us/research/uploads/prod/2018/03/trueskill2.pdf
Hi there,
Thanks for providing a PHP-based port of the TrueSkill algorithm! I've tried running the UnitTests for this project but unfortunately, I get the following error:
PHP Fatal error: Class 'Moserware\Skills\TrueSkill\Layers\InvalidOperationExcep
tion' not found in C:\wamp\www\test_project\trunk\TrueSkill\Skills\TrueSkill\L
ayers\IteratedTeamDifferencesInnerLayer.php on line 55
PHP Stack trace:
PHP 1. {main}() C:\wamp\bin\php\php5.4.12\phpunit:0
PHP 2. PHPUnit_TextUI_Command::main() C:\wamp\bin\php\php5.4.12\phpunit:49
PHP 3. PHPUnit_TextUI_Command->run() C:\wamp\bin\php\php5.4.12\pear\PHPUnit\Te
xtUI\Command.php:129
PHP 4. PHPUnit_Runner_BaseTestRunner->getTest() C:\wamp\bin\php\php5.4.12\pear
\PHPUnit\TextUI\Command.php:150
PHP 5. PHPUnit_Framework_TestSuite->addTestFiles() C:\wamp\bin\php\php5.4.12\p
ear\PHPUnit\Runner\BaseTestRunner.php:96
PHP 6. PHPUnit_Framework_TestSuite->addTestFile() C:\wamp\bin\php\php5.4.12\pe
ar\PHPUnit\Framework\TestSuite.php:430
PHP 7. PHPUnit_Util_Fileloader::checkAndLoad() C:\wamp\bin\php\php5.4.12\pear
PHPUnit\Framework\TestSuite.php:369
PHP 8. PHPUnit_Util_Fileloader::load() C:\wamp\bin\php\php5.4.12\pear\PHPUnit
Util\Fileloader.php:86
PHP 9. include_once() C:\wamp\bin\php\php5.4.12\pear\PHPUnit\Util\Fileloader.p
hp:102
PHP 10. PHPUnit_TextUI_TestRunner::run() C:\wamp\www\test_project\trunk\TrueS
kill\UnitTests\TrueSkill\FactorGraphTeamTrueSkillCalculatorTest.php:26
PHP 11. PHPUnit_TextUI_TestRunner->doRun() C:\wamp\bin\php\php5.4.12\pear\PHPUn
it\TextUI\TestRunner.php:106
PHP 12. PHPUnit_Framework_TestSuite->run() C:\wamp\bin\php\php5.4.12\pear\PHPUn
it\TextUI\TestRunner.php:305
PHP 13. PHPUnit_Framework_TestSuite->runTest() C:\wamp\bin\php\php5.4.12\pear\P
HPUnit\Framework\TestSuite.php:733
PHP 14. PHPUnit_Framework_TestCase->run() C:\wamp\bin\php\php5.4.12\pear\PHPUni
t\Framework\TestSuite.php:757
PHP 15. PHPUnit_Framework_TestResult->run() C:\wamp\bin\php\php5.4.12\pear\PHPU
nit\Framework\TestCase.php:576
PHP 16. PHPUnit_Framework_TestCase->runBare() C:\wamp\bin\php\php5.4.12\pear\PH
PUnit\Framework\TestResult.php:666
PHP 17. PHPUnit_Framework_TestCase->runTest() C:\wamp\bin\php\php5.4.12\pear\PH
PUnit\Framework\TestCase.php:628
PHP 18. ReflectionMethod->invokeArgs() C:\wamp\bin\php\php5.4.12\pear\PHPUnit\F
ramework\TestCase.php:738
PHP 19. FactorGraphTrueSkillCalculatorTest->testFactorGraphTrueSkillCalculator(
) C:\wamp\bin\php\php5.4.12\pear\PHPUnit\Framework\TestCase.php:738
PHP 20. TrueSkillCalculatorTests::testAllTwoPlayerScenarios() C:\wamp\www\test_project\trunk\TrueSkill\UnitTests\TrueSkill\FactorGraphTeamTrueSkillCalculator
Test.php:16
PHP 21. TrueSkillCalculatorTests::twoPlayerTestNotDrawn() C:\wamp\www\test_project\trunk\TrueSkill\UnitTests\TrueSkill\TrueSkillCalculatorTests.php:25
PHP 22. Moserware\Skills\TrueSkill\FactorGraphTrueSkillCalculator->calculateNew
Ratings() C:\wamp\www\test_project\trunk\TrueSkill\UnitTests\TrueSkill\TrueSki
llCalculatorTests.php:91
PHP 23. Moserware\Skills\TrueSkill\TrueSkillFactorGraph->runSchedule() C:\wamp
www\test_project\trunk\TrueSkill\Skills\TrueSkill\FactorGraphTrueSkillCalculat
or.php:54
PHP 24. Moserware\Skills\TrueSkill\TrueSkillFactorGraph->createFullSchedule() C
:\wamp\www\test_project\trunk\TrueSkill\Skills\TrueSkill\TrueSkillFactorGraph.
php:87
PHP 25. Moserware\Skills\TrueSkill\Layers\IteratedTeamDifferencesInnerLayer->cr
eatePriorSchedule() C:\wamp\www\test_project\trunk\TrueSkill\Skills\TrueSkill
TrueSkillFactorGraph.php:117
Do you know if there is something I am missing? Have you seen this problem before?
Note that I'm using PHP version 5.4.12, PEAR version 1.9.4, and PHPUnit version 3.5.15. I've also tried a newer version of PHPUnit (version 3.7.xx) with no success.
Any help would be much appreciated,
-sponge8
Wow, this is awesome! I was really happy to find an implementation of the TrueSkill algorithm in PHP. I realize that this was your first project with PHP, and I find the code to be of very good quality/structure in general, however it seems you have misunderstood how references together with objects work in PHP (which is easy to do because the manual doesnt say much about it).
It is true that PHP by default passes function arguments by value, however passing objects work pretty much like in Java - meaning it will by default pass a reference (to the object) by value.
Be aware that arrays counts as primitives so they are by default not passed as a reference.
Passing objects by reference (like you're doing mostly) will give you the ability to change the object that the passed variable points to.
I would really like to help, but I'm not sure I've got the time at the moment.
Looking at the paper's PDF
http://research.microsoft.com/pubs/67956/NIPS2006_0688.pdf (equation 7)
you swapped Sigma with Mu
This line below:
($totalPlayers_$betaSquared + $team1StdDevSquared + $team2SigmaSquared)
should be:
($totalPlayers_$betaSquared + $team1StdDevSquared + $team2StdDevSquared)
and so the "exp" part has a mirror error.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.