Skip to content

Commit

Permalink
Major restructuring
Browse files Browse the repository at this point in the history
  • Loading branch information
atomflunder committed Oct 22, 2022
1 parent 6e90d69 commit b26744f
Show file tree
Hide file tree
Showing 23 changed files with 1,243 additions and 1,225 deletions.
1 change: 1 addition & 0 deletions .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
format_code_in_doc_comments = true
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

This is a broad overview of the changes that have been made over the lifespan of this library.

## v0.18.0 - 2022-10-23

- Major restructuring of ratings, configs and outcomes
- Ratings and Configs now reside in the rating algorithms files
- Outcomes now reside in the lib.rs file

## v0.17.0 - 2022-10-21

- Added USCF rating algorithms
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "skillratings"
version = "0.17.0"
version = "0.18.0"
edition = "2021"
description = "Calculate a player's skill rating using algorithms like Elo, Glicko, Glicko-2, TrueSkill and many more."
readme = "README.md"
Expand Down
28 changes: 13 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Alternatively, you can add the following to your `Cargo.toml` file manually:

```toml
[dependencies]
skillratings = "0.17"
skillratings = "0.18"
```

## Usage and Examples
Expand All @@ -54,7 +54,8 @@ We use *Glicko-2* in this example here.

```rust
use skillratings::{
glicko2::glicko2, outcomes::Outcomes, rating::Glicko2Rating, config::Glicko2Config
glicko2::{glicko2, Glicko2Config, Glicko2Rating},
Outcomes,
};

// Initialise a new player rating.
Expand All @@ -64,7 +65,7 @@ let player_one = Glicko2Rating::new();
// Or you can initialise it with your own values of course.
// Imagine these numbers being pulled from a database.
let (some_rating, some_deviation, some_volatility) = (1325.0, 230.0, 0.05932);
let player_two = Glicko2Rating{
let player_two = Glicko2Rating {
rating: some_rating,
deviation: some_deviation,
volatility: some_volatility,
Expand All @@ -90,10 +91,8 @@ This example shows a 3v3 game using *TrueSkill*.

```rust
use skillratings::{
trueskill::trueskill_teams,
outcomes::Outcomes,
rating::TrueSkillRating,
config::TrueSkillConfig,
trueskill::{trueskill_teams, TrueSkillConfig, TrueSkillRating},
Outcomes,
};

// We initialise Team One as a Vec of multiple TrueSkillRatings.
Expand Down Expand Up @@ -139,14 +138,14 @@ Every rating algorithm has an `expected_score` function that you can use to pred
This example is using *Glicko* (*not Glicko-2!*) to demonstrate.

```rust
use skillratings::{glicko::expected_score, rating::GlickoRating};
use skillratings::glicko::{expected_score, GlickoRating};

// Initialise a new player rating.
// The default values are: 1500.0, and 350.0.
let player_one = GlickoRating::new();

// Initialising a new rating with custom numbers.
let player_two = GlickoRating{
let player_two = GlickoRating {
rating: 1812.0,
deviation: 195.0,
};
Expand All @@ -170,21 +169,20 @@ We are using the *Elo* rating algorithm in this example.

```rust
use skillratings::{
elo::elo_rating_period, outcomes::Outcomes, rating::EloRating, config::EloConfig
elo::{elo_rating_period, EloConfig, EloRating},
Outcomes,
};

// We initialise a new Elo Rating here.
let player = EloRating {
rating: 1402.1,
};
let player = EloRating { rating: 1402.1 };

// We need a list of results to pass to the elo_rating_period function.
let mut results = Vec::new();

// And then we populate the list with tuples containing the opponent,
// And then we populate the list with tuples containing the opponent,
// and the outcome of the match from our perspective.
results.push((EloRating::new(), Outcomes::WIN));
results.push((EloRating {rating: 954.0}, Outcomes::DRAW));
results.push((EloRating { rating: 954.0 }, Outcomes::DRAW));
results.push((EloRating::new(), Outcomes::LOSS));

// The elo_rating_period function calculates the new rating for the player and returns it.
Expand Down
6 changes: 2 additions & 4 deletions benches/benchmarks/elo_bench.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use skillratings::{
config::EloConfig,
elo::{elo, elo_rating_period, expected_score},
outcomes::Outcomes,
rating::EloRating,
elo::{elo, elo_rating_period, expected_score, EloConfig, EloRating},
Outcomes,
};

use criterion::{black_box, criterion_group, criterion_main, Criterion};
Expand Down
6 changes: 2 additions & 4 deletions benches/benchmarks/glicko2_bench.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use skillratings::{
config::Glicko2Config,
glicko2::{expected_score, glicko2, glicko2_rating_period},
outcomes::Outcomes,
rating::Glicko2Rating,
glicko2::{expected_score, glicko2, glicko2_rating_period, Glicko2Config, Glicko2Rating},
Outcomes,
};

use criterion::{black_box, criterion_group, criterion_main, Criterion};
Expand Down
5 changes: 2 additions & 3 deletions benches/benchmarks/trueskill_bench.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use skillratings::{
config::TrueSkillConfig,
outcomes::Outcomes,
rating::TrueSkillRating,
trueskill::{
expected_score, expected_score_teams, trueskill, trueskill_rating_period, trueskill_teams,
TrueSkillConfig, TrueSkillRating,
},
Outcomes,
};

use criterion::{black_box, criterion_group, criterion_main, Criterion};
Expand Down
5 changes: 2 additions & 3 deletions benches/benchmarks/weng_lin_bench.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use skillratings::{
config::WengLinConfig,
outcomes::Outcomes,
rating::WengLinRating,
weng_lin::{
expected_score, expected_score_teams, weng_lin, weng_lin_rating_period, weng_lin_teams,
WengLinConfig, WengLinRating,
},
Outcomes,
};

use criterion::{black_box, criterion_group, criterion_main, Criterion};
Expand Down
Loading

0 comments on commit b26744f

Please sign in to comment.