# Rating calculator

This should be an example calculator for a possible bbc rating. The aim of the rating is to estimate the current strength of a player as good as possible.

### small explanation

You do not need to know the full details on how the rating will be computed, because this is very complicated. Here are some basic principles:

• you start with a number of rating points. after each game you will win or loose points, depending on how good you play.
• the place you get in a game has a big influence on how many points you make.
• If you play against players with a higher rating than yours and are successful, you get many rating points
• If you play against players with a higher rating than yours and are not successful, you loose a few rating points
• If you play against players with a lower rating than yours and are successful, you win a few rating points
• If you play against players with a lower rating than yours and are not successful, you loose many rating points
The number of games each player has played so far can also have an influence on the rating points, therefor there is an extra column.
If you want to know, how things look like if you consider many games, here is an example computation: (click here). it uses all BBC games in 2013. you can even get a graph of players of their rating over time.

## Example calculation

### Input

System parameters:
Difference between Players:
Speed at Start: Normal Speed:
first games:
Bonus for Winner:
Rating # Winner Place 2 Place 3 Place 4 Place 5 Place 6 Place 7 Place 8 Place 9 Place 10
Number of Players (2-10):

### Results

 Place Old Rating New Rating Difference played games 1 5000 5421 421 1 2 5000 5273 273 1 3 5000 5193 193 1 4 5000 5113 113 1 5 5000 5033 33 1 6 5000 4953 -47 1 7 5000 4873 -127 1 8 5000 4793 -207 1 9 5000 4713 -287 1 10 5000 4633 -367 1

## Source code

```function noobratingmain(\$ratings,\$gamec,\$probdiff=3000,\$startspeed=80,\$minspeed=40,\$mingames=30,\$winbonus=1.17)
{
/*
this is the core function of the bbc rating.
it was programmed by some supernoob :)

\$ratings and \$gamec are arrays of the same size
the size is the number of players
player with index 0 is winner, 9 is place 10
gamec is the number of games played before this game
*/
if(count(\$ratings) !=count(\$gamec) or count(\$ratings)>=11) return 0; //error
\$NN=count(\$ratings); // \$NN is the number of players in the game
\$newrating=\$ratings; // newrating will be return array
for(\$i1=0;\$i1<\$NN;\$i1++)
{
\$expect=0.0; // \$expect is the expected score for each player
for(\$i2=0;\$i2<\$NN;\$i2++)
{
if(\$i1==\$i2) continue;
\$diff = (float)(\$ratings[\$i2]-\$ratings[\$i1]); //compare rating difference with each player
if(\$i2==0 or \$i1==0) \$expect += \$winbonus/(1.0 + pow(2.0,\$diff/\$probdiff)); // add expected score for winners
if(\$i2!=0 and \$i1!=0) \$expect += 1.0/(1.0 + pow(2.0,\$diff/\$probdiff)); // add expected score for non-winners
}
if(\$gamec[\$i1]<\$mingames) \$speed2 = (float)\$startspeed + (float)(\$minspeed-\$startspeed)*(\$gamec[\$i1])/(\$mingames);
if(\$gamec[\$i1]>=\$mingames)\$speed2=\$minspeed; // determine the "speed" according to parameters
\$wonpoints=\$NN-\$i1-1; //
if(\$i1==0) \$wonpoints=\$winbonus*9.0; // winners get more points
\$newrating[\$i1] =\$ratings[\$i1] + (int) ceil(\$speed2*(\$wonpoints - \$expect) -0.5); //round the rating points to integer
}
return \$newrating;
}
```

site views (clicks, all sites): 8293641    Server Time: 2021-01-22 13:21:00