At work I’ve been tasked with building real-time PvP systems (pushing data from server to client) as well as matchmaking systems for pairing players together (pretty similar stuff to what I’ve been doing since first learning Node.js two years ago).
While building matchmaking systems, of course the ELO system used by Chess was brought up (As well as TrueSkill, but that’s probably patented). It’s a system which rates every player and considers the difference in ratings and the outcome of a match to determine new ratings. For example, if you’re a newbie and you’re bested by a master, it’ll only slightly affect your ratings. However, if you’re a newbie and you beat a master, it would be a large change in ratings.
I did some research on ELO modules for Node and only came across two. One was incomplete and the other was literally a file with 10 lines of code. So, I went ahead and built my own:
It has unit tests and 100% code coverage. It’s also quite simple to use:
var Elo = require('arpad'); var elo = new Elo(); var alice = 1600; var bob = 1300; var new_alice = elo.newRatingIfWon(alice, bob); console.log("Alice's new rating if she won:", new_alice); // 1605
Latest posts by Thomas Hunter II (see all)
- Linux Mint Disable “Recently Used” - 2017-04-14
- Ubuntu 16.04 LTS Xen stuck on “Loading Initial Ramdisk” - 2017-04-05
- Online Colorscheme Configurator for i3, i3status, dmenu - 2017-02-08