View Full Version : Need an algeorhythm
Dean C
06-06-2003, 10:56 AM
.....Or however you spell it... :p
Imagine you have a wins and losses field in the user column. Now instead of adding a rating field and say adding 10 to the rating field for a win and minusing 5 for a loss i thought i'd make myself a little system to work it out.
Basically i don't want people to have a minus rating but remember people who have a loss have participated in some kind of battle so they must have some kind of rating. Basically i need a cool system that will keep my uses happy...
Any ideas?
- miSt
Xenon
06-06-2003, 11:16 AM
hmm if you don't want an negativ rating, you can for example use an exponential rating.
so whenever the losses are higher than the wins, the rating will go towards 0, but never be negativ :)
Dean C
06-06-2003, 11:31 AM
What i mean was can i have some sample code? :p
Dean C
06-06-2003, 11:54 AM
How do this look:
if($post['wins']>$post['losses'])
{
$rating = $post['wins']*100;
} else if($post['losses']>$post['wins']) {
$rating = ($post['wins']*100)-($post['losses']*10);
} else if($post['losses']==$post['wins']) {
$rating = ($post['wins']*100)-($post['losses']*10);
}
Xenon
06-06-2003, 12:02 PM
it will give you negative ratings if someone has x losses and 0 wins...
use this:
$rating = exp($post['wins'] - $post['losses']);
rating range then would be from 0 up to infinity, but never negative :)
Dean C
06-06-2003, 03:46 PM
So i'd use this:
$rating = exp(($post['wins']*100)-($post['losses']*10));
Instead of this:
$rating = ($post['wins']*100)-($post['losses']*10);
:)?
- miSt
Xenon
06-06-2003, 04:48 PM
no, use exactly the code i posted :)
the more wins someone has the greater the value will be, there is no need to do the *100
Dean C
06-06-2003, 05:31 PM
Ahhh works pretty cool but can you explain to me how it works as the description on php.net was a bit confusing to me. Its basically so i can tell the users how we work out their rating :)?
Thanks
- miSt
Xenon
06-06-2003, 09:44 PM
exp(x) is the normal exponentialfunction you should have learned in maths:
e^x
maybe you have toad a faktor smaller than 1 before, if you are awaiting high ammounts of wins ;)
exp(100) would be more than 10^43 :)
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.