承接 avoo/elo 相关项目开发

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

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

avoo/elo

Composer 安装命令:

composer require avoo/elo

包简介

Elo calculator library

README 文档

README

![Build Status] (https://scrutinizer-ci.com/g/avoo/Elo/badges/build.png?b=master) ![Scrutinizer Code Quality] (https://scrutinizer-ci.com/g/avoo/Elo/badges/quality-score.png?b=master) ![License] (https://poser.pugx.org/avoo/elo/license.svg)

This is a PHP library to calculate the Elo rank between two players.

Documentation

into your composer.json file:

{
    "require": {
        "avoo/elo": "~0.2"
    }
}

Default Usage

You need to implement the class Avoo\Elo\Model\EloPlayerInterface on your own player class

use Avoo\Elo\Model\EloPlayerInterface;
use Avoo\Elo\Model\EloUserInterface;

class EloPlayer implements EloPlayerInterface
{
    /**
     * @var integer
     */
    protected $elo;

    /**
     * @var EloUserInterface $user
     */
    protected $user;

    /**
     * {@inheritdoc}
     */
    public function setElo($elo)
    {
        $this->elo = $elo;

        return $this;
    }

    /**
     * {@inheritdoc}
     */
    public function getElo()
    {
        return $this->elo;
    }

    /**
     * {@inheritdoc}
     */
    public function setUser(EloUserInterface $user)
    {
        $this->user = $user;

        return $this;
    }

    /**
     * {@inheritdoc}
     */
    public function getUser()
    {
        return $this->user;
    }

    //... Your own code
}

Consider the player A with 2300 elo and the player B 1800, the player A lose.

The default setup for winner is: - 0 Player A lose - 0.5 Draw - 1 Player A win

Example 1

use Avoo\Elo\EloPoint;
use Avoo\Elo\EloVersusInterface;
use Avoo\Elo\EloAggregagtionInterface;

$eloCalculator = new EloPoint();

/** @var EloVersusInterface $match */
$eloPoint->calculate($match);

/** @var EloAggregationInterface $aggregation */
$aggregation = $eloPoint->getAggregation(); 

Example 2

use Avoo\Elo\EloPoint;
use Avoo\Elo\EloVersusInterface;
use Avoo\Elo\EloAggregagtionInterface;

/** @var EloVersusInterface $match */
$eloCalculator = new EloPoint($match);
$eloPoint->calculate();

/** @var EloAggregationInterface $aggregation */
$aggregation = $eloPoint->getAggregation(); 

Override configuration

You can override the default configuration for adjust your elo calculator

use Avoo\Elo\EloPoint;
use Avoo\Elo\EloVersusInterface;
use Avoo\Elo\EloAggregagtionInterface;
use Avoo\Elo\ConfigurationInterface;

/** @var ConfigurationInterface $configuration */
$configuration = new Configuration();

/**
 * Floor is the experience range calculator
 */
$configuration->setFloor(200);

/**
 * Base range is ratio number for calculate the new elo
 * In this case between 0 and 1700 elo point the range is 50, over it's 20
 * For example with 1500 elo point for both players, with 50 elo range, the new elo will be 18 and -18,
 * and for 20 elo range, the new elo will be 7 and -7
 */
$configuration->setBaseRange(array(
    0 => 50
    1700 => 20
));

/*
 * Base elo is the start elo point for a new player
 */
$configuration->setBaseElo(1000);

/** @var EloVersusInterface $match */
$eloCalculator = new EloPoint($match, $configuration);
$eloPoint->calculate();

/** @var EloAggregationInterface $aggregation */
$aggregation = $eloPoint->getAggregation();

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-09-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固