GithubHelp home page GithubHelp logo

eduardo's Introduction

Eduardo

Eduardo is an implementation of the Elo rating system. The expected scores of players are calculated using the logistic curve, and the k-factor can be parameterized.

Installation

pip install eduardo

Testing

python eduardo/tests/test.py

Usage

# default elo is 1000 and default k-factor is 32
chess_world = Elo()

# pass a unique, immutable value to register the player
names = ['magnus', 'garry', 'bobby', 'lawrence']
chess_players = [chess_world.create_player(name) for name in names]

# register results of games using player objects
magnus, garry, bobby, lawrence = chess_players
magnus.beat(bobby)
lawrence.lost_to(garry)

assert lawrence.rating == 984.0
assert garry.rating == 1016.0

# find players by id
assert chess_world.find_player('lawrence') == lawrence

# get all players as a dict
assert chess_world.players == {'bobby': bobby, 'garry': garry, 'lawrence': lawrence, 'magnus': magnus}


# modify defaults: higher k-factor means higher sensitivity
photo_world = Elo(starting_elo=1400, k_factor=16)

# use log_game to record batches of games
with open('data/players.txt', 'r') as players, open('data/games.txt', 'r') as games:
    urls = [line.rstrip() for line in players.readlines()]
    photo_players = [photo_world.create_player(url) for url in urls]

    games = [line.rstrip() for line in games.readlines()]
    for winner, loser in [game.split('>') for game in games]:
        photo_world.log_game(winner, loser)

eduardo's People

Contributors

lvwrence avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  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.