| 
16 | 16 | 
 
  | 
17 | 17 | //! Skillratings provides a collection of well-known (and lesser known) skill rating algorithms, that allow you to assess a player's skill level instantly.    | 
18 | 18 | //! You can easily calculate skill ratings instantly in 1vs1 matches, Team vs Team matches, or in tournaments / rating periods.    | 
19 |  | -//! This library is incredibly lightweight (no dependencies by default), user-friendly, and of course, *blazingly fast*.    | 
20 |  | -//!  | 
21 |  | -//! Currently we support these skill rating systems:    | 
22 |  | -//! - **[`Elo`](crate::elo)**  | 
23 |  | -//! - **[`Glicko`](crate::glicko)**  | 
24 |  | -//! - **[`Glicko-2`](crate::glicko2)**  | 
25 |  | -//! - **[`TrueSkill`](crate::trueskill)**  | 
26 |  | -//! - **[`Weng-Lin`](crate::weng_lin)**  | 
27 |  | -//! - **[`FIFA Men's World Ranking`](crate::fifa)**  | 
28 |  | -//! - **[`Sticko`](crate::sticko)**  | 
29 |  | -//! - **[`Glicko-Boost`](crate::glicko_boost)**  | 
30 |  | -//! - **[`USCF (US Chess Federation)`](crate::uscf)**  | 
31 |  | -//! - **[`EGF (European Go Federation)`](crate::egf)**  | 
32 |  | -//! - **[`DWZ (Deutsche Wertungszahl)`](crate::dwz)**  | 
33 |  | -//! - **[`Ingo`](crate::ingo)**  | 
 | 19 | +//! This library is incredibly lightweight (no dependencies by default), user-friendly, and of course, *blazingly fast*.  | 
 | 20 | +//!  | 
 | 21 | +//! Currently supported algorithms:  | 
 | 22 | +//!  | 
 | 23 | +//! - [Elo](https://docs.rs/skillratings/latest/skillratings/elo/)  | 
 | 24 | +//! - [Glicko](https://docs.rs/skillratings/latest/skillratings/glicko/)  | 
 | 25 | +//! - [Glicko-2](https://docs.rs/skillratings/latest/skillratings/glicko2/)  | 
 | 26 | +//! - [TrueSkill](https://docs.rs/skillratings/latest/skillratings/trueskill/)  | 
 | 27 | +//! - [Weng-Lin (Bayesian Approximation System)](https://docs.rs/skillratings/latest/skillratings/weng_lin/)  | 
 | 28 | +//! - [FIFA Men's World Ranking](https://docs.rs/skillratings/latest/skillratings/fifa/)  | 
 | 29 | +//! - [Sticko (Stephenson Rating System)](https://docs.rs/skillratings/latest/skillratings/sticko/)  | 
 | 30 | +//! - [Glicko-Boost](https://docs.rs/skillratings/latest/skillratings/glicko_boost/)  | 
 | 31 | +//! - [USCF (US Chess Federation Ratings)](https://docs.rs/skillratings/latest/skillratings/uscf/)  | 
 | 32 | +//! - [EGF (European Go Federation Ratings)](https://docs.rs/skillratings/latest/skillratings/egf/)  | 
 | 33 | +//! - [DWZ (Deutsche Wertungszahl)](https://docs.rs/skillratings/latest/skillratings/dwz/)  | 
 | 34 | +//! - [Ingo](https://docs.rs/skillratings/latest/skillratings/ingo/)  | 
34 | 35 | //!  | 
35 | 36 | //! Most of these are known from their usage in chess and various other games.    | 
36 | 37 | //! Click on the documentation for the modules linked above for more information about the specific rating algorithms, and their advantages and disadvantages.  | 
37 | 38 | //!  | 
38 |  | -//! # Installation  | 
 | 39 | +//! ## Table of Contents  | 
 | 40 | +//!  | 
 | 41 | +//! - [Installation](#installation)  | 
 | 42 | +//!     - [Serde Support](#serde-support)  | 
 | 43 | +//! - [Usage and Examples](#usage-and-examples)  | 
 | 44 | +//!     - [Player vs. Player](#player-vs-player)  | 
 | 45 | +//!     - [Team vs. Team](#team-vs-team)  | 
 | 46 | +//!     - [Free-For-Alls and Multiple Teams](#free-for-alls-and-multiple-teams)  | 
 | 47 | +//!     - [Expected Outcome](#expected-outcome)  | 
 | 48 | +//!     - [Rating Period](#rating-period)  | 
 | 49 | +//!     - [Switching between different rating systems](#switching-between-different-rating-systems)  | 
 | 50 | +//! - [Contributing](#contributing)  | 
 | 51 | +//! - [License](#license)  | 
 | 52 | +//!  | 
 | 53 | +//!  | 
 | 54 | +//! ## Installation  | 
39 | 55 | //!  | 
40 | 56 | //! If you are on Rust 1.62 or higher use `cargo add` to install the latest version:  | 
41 | 57 | //!  | 
 | 
50 | 66 | //! skillratings = "0.25"  | 
51 | 67 | //! ```  | 
52 | 68 | //!  | 
53 |  | -//! ## Serde support  | 
 | 69 | +//! ### Serde support  | 
54 | 70 | //!  | 
55 | 71 | //! Serde support is gated behind the `serde` feature. You can enable it like so:  | 
56 | 72 | //!  | 
 | 
67 | 83 | //! skillratings = {version = "0.25", features = ["serde"]}  | 
68 | 84 | //! ```  | 
69 | 85 | //!  | 
70 |  | -//! # Usage and Examples  | 
 | 86 | +//! ## Usage and Examples  | 
71 | 87 | //!  | 
72 | 88 | //! Below you can find some basic examples of the use cases of this crate.    | 
73 | 89 | //! There are many more rating algorithms available with lots of useful functions that are not covered here.    | 
 | 
285 | 301 | //! // The rating of the player decreased by around ~40 points.  | 
286 | 302 | //! assert_eq!(new_player.rating.round(), 1362.0);  | 
287 | 303 | //! ```  | 
 | 304 | +//!  | 
 | 305 | +//! ### Switching between different rating systems  | 
 | 306 | +//!  | 
 | 307 | +//! If you want to switch between different rating systems, for example to compare results or do scientific analyisis,  | 
 | 308 | +//! we provide the `Rating`, `RatingSystem` (1v1), `RatingPeriodSystem` (1v1 Tournaments), `TeamRatingSystem` (Team vs. Team)  | 
 | 309 | +//! and `MultiTeamRatingSystem` (FFA) traits to make switching as easy as possible.  | 
 | 310 | +//!  | 
 | 311 | +//! In the following example, we are using the `RatingSystem` (1v1) Trait with Glicko-2:  | 
 | 312 | +//!  | 
 | 313 | +//! ```rust  | 
 | 314 | +//! use skillratings::{  | 
 | 315 | +//!     glicko2::{Glicko2, Glicko2Config},  | 
 | 316 | +//!     Outcomes, Rating, RatingSystem,  | 
 | 317 | +//! };  | 
 | 318 | +//!  | 
 | 319 | +//! // Initialise a new player rating with a rating value and uncertainty value.  | 
 | 320 | +//! // Not every rating system has an uncertainty value, so it may be discarded.  | 
 | 321 | +//! let player_one = Rating::new(Some(1200.0), Some(120.0));  | 
 | 322 | +//! // If you want the default values for the rating system, use None instead.  | 
 | 323 | +//! let player_two = Rating::new(None, None);  | 
 | 324 | +//!  | 
 | 325 | +//! // The config needs to be specific to the rating system.  | 
 | 326 | +//! // When you swap rating systems, make sure to update the config.  | 
 | 327 | +//! let config = Glicko2Config::new();  | 
 | 328 | +//!  | 
 | 329 | +//! // You may also need to use a type annotation here for the compiler.  | 
 | 330 | +//! let rating_system: Glicko2 = RatingSystem::new(config);  | 
 | 331 | +//!  | 
 | 332 | +//! // The outcome of the match is from the perspective of player one.  | 
 | 333 | +//! let outcome = Outcomes::WIN;  | 
 | 334 | +//!  | 
 | 335 | +//! // All rating systems share a `rate` function for performing the actual calculations,  | 
 | 336 | +//! // plus an `expected_score` function for calculating the expected performances.  | 
 | 337 | +//! // Some rating systems might have additional functions,  | 
 | 338 | +//! // which are only available when you use them directly.  | 
 | 339 | +//! let expected_score = rating_system.expected_score(&player_one, &player_two);  | 
 | 340 | +//! let (new_one, new_two) = rating_system.rate(&player_one, &player_two, &outcome);  | 
 | 341 | +//!  | 
 | 342 | +//! // After that, you can access the players rating and uncertainty with the functions below.  | 
 | 343 | +//! assert_eq!(new_one.rating().round(), 1241.0);  | 
 | 344 | +//! // Note that because not every rating system has an uncertainty value,  | 
 | 345 | +//! // the uncertainty function returns an Option<f64>.  | 
 | 346 | +//! assert_eq!(new_one.uncertainty().unwrap().round(), 118.0);  | 
 | 347 | +//! ```  | 
 | 348 | +//!  | 
 | 349 | +//! ## Contributing  | 
 | 350 | +//!  | 
 | 351 | +//! Contributions of any kind are always welcome!    | 
 | 352 | +//!  | 
 | 353 | +//! Found a bug or have a feature request? [Submit a new issue](https://github.com/atomflunder/skillratings/issues/).    | 
 | 354 | +//! Alternatively, [open a pull request](https://github.com/atomflunder/skillratings/pulls) if you want to add features or fix bugs.    | 
 | 355 | +//! Leaving other feedback is of course also appreciated.  | 
 | 356 | +//!  | 
 | 357 | +//! Thanks to everyone who takes their time to contribute.  | 
 | 358 | +//!  | 
 | 359 | +//! ## License  | 
 | 360 | +//!  | 
 | 361 | +//! This project is licensed under either the [MIT License](/LICENSE-MIT), or the [Apache License, Version 2.0](/LICENSE-APACHE).  | 
288 | 362 | 
  | 
289 | 363 | #[cfg(feature = "serde")]  | 
290 | 364 | use serde::de::DeserializeOwned;  | 
 | 
0 commit comments