承接 keliodev/glicko2 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

keliodev/glicko2

最新稳定版本:1.0.2

Composer 安装命令:

composer require keliodev/glicko2

包简介

A PHP implementation of glicko2 rating system

README 文档

README

--------------------------------------------------------------------------------------------------------------

It's a fork to rename the class Match into MatchGame because the work "match" is a reserved keyword in PHP 8.0

--------------------------------------------------------------------------------------------------------------

License Latest Stable Version Total Downloads

A PHP implementation of Glicko2 rating system

Installation

Composer

The preferred way to install this extension is through Composer.

Either run

php composer.phar require KelioDev/glicko2 "~1.0.0"

or add

"KelioDev/glicko2": "~1.0.0"

to the require section of your composer.json

Usage

For ease of understanding take ActiveRecord pattern.

Somewhere create object. Attribute names can be any

use keliodev\glicko2\Player;
// ...
public function createUserRating(int $userId)
{
    $userRating = new UserRating();
    $userRating->user_id = $userId;
    $player = new Player();
    $userRating->rating = $player->getRating();
    $userRating->rating_deviation = $player->getRatingDeviation();
    $userRating->rating_volatility = $player->getRatingVolatility();

    $userRating->insert();
    
    return $userRating;
}

Ok, let's play

use keliodev\glicko2\MatchGame;
use keliodev\glicko2\MatchCollection;
use keliodev\glicko2\Player;

$player1 = new Player($userRating1->rating, $userRating1->rating_deviation, $userRating1->rating_volatility);
$player2 = new Player($userRating2->rating, $userRating2->rating_deviation, $userRating2->rating_volatility);

// match chain
$match1 = new MatchGame($player1, $player2, 1, 0);
$match1->calculate();

$match2 = new MatchGame($player1, $player2, 3, 2);
$match2->calculate();

// or match collection
$matchCollection = new MatchCollection();
$matchCollection->addMatch(new MatchGame($player1, $player2, 1, 0));
$matchCollection->addMatch(new MatchGame($player1, $player2, 3, 2));
$matchCollection->calculate();

$newPlayer1Rating = $player1->getRating();
$newPlayer2Rating = $player2->getRating();

// for example, save in DB

$userRating1->rating = $player1->getRating();
$userRating1->rating_deviation = $player1->getRatingDeviation();
$userRating1->rating_volatility = $player1->getRatingVolatility();
$userRating1->update();

// similarly save the second player

Author

Aleksandr Zelenin, e-mail: aleksandr@zelenin.me

Vlad Varlamov, e-mail: work@laxity.ru

统计信息

  • 总下载量: 43
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-09-23

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固