GithubHelp home page GithubHelp logo

davemathews / ratings Goto Github PK

View Code? Open in Web Editor NEW

This project forked from chasecrawford/ratings

0.0 0.0 0.0 12 KB

A PHP class which implements the Elo rating system & Rating Percentage index

License: MIT License

PHP 100.00%

ratings's Introduction

Ratings

A PHP class which implements the Elo rating system & Rating Percentage index.

Install

composer require chasecrawford/ratings

Using Elo

Calculate a new elo rating for a competitor after a result

use ChaseCrawford\EloRating;

$elo = new EloRating;

$newEloRating = $elo->calculateElo(
    1000,   // (float) competitor elo rating
    1000,   // (float) opponent's elo rating
    71,     // (int) competitor score
    70,     // (int) opponent score
    0       // (int) number of matches competitor played previously (optional)
)

Find the elo ratings for all competitors from a group of results

$results = [...];

foreach($results as $result) {
  $elo->addResult(
       $result->competitorOneName,  // (string) unique name for competitor 1
       $result->competitorTwoName,  // (string) unique name for competitor 2
       $result->competitorOneScore, // (int) score for competitor 1
       $result->competitorTwoScore  // (int) score for competitor 2
  )
}

print_r($elo->getCompetitors())

Using RPI

use ChaseCrawford\RatingPercentageIndex;

$rpi = new RatingPercentageIndex;

$results = [...];

foreach($results as $result) {
  $rpi->addGame(
       $result->competitorOneName,  // (string) unique name for competitor 1
       $result->competitorTwoName,  // (string) unique name for competitor 2
       $result->outcome, // 1 for win, 0 for loss, 0.5 for draw
  )
}

print_r($rpi)

ratings's People

Contributors

ccrawfordhatfield avatar chasecrawford avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.