origami_rating 1.8.0
Rating related algorithm library for Dojo based games.
The Origami Rating crate is a library that provides rating-related algorithms for Dojo-based games. It offers efficient implementations of rating systems commonly used in game development and competitive matchmaking.
The Rating crate focuses on providing rating algorithms that are essential for game development, particularly for competitive games. Its primary scope includes:
The crate is designed to work seamlessly with the Dojo engine and other Origami crates.
Add the Origami Rating crate from the scarbs.xyz registry:
scarb add origami_rating@1.8.0
Or from git, in the [dependencies] section of your Scarb.toml:
[dependencies]
origami_rating = { git = "https://github.com/dojoengine/origami" }
Make sure you have dojo installed and configured in your project.
Here are some examples of how to use the Rating crate:
This example demonstrates how to calculate and apply a rating change using the Elo system. The rating_change function takes the current ratings of both players, the game outcome, and the K-factor as inputs. It returns the magnitude of the rating change and a boolean indicating whether the change is negative.
use origami_rating::elo::EloTrait;
// Calculate rating change for player A
let (change, is_negative) = EloTrait::rating_change(
1200_u64, // Player A's current rating
1400_u64, // Player B's current rating
100_u16, // Outcome (100 = win, 50 = draw, 0 = loss)
20_u8 // K-factor
);
// Apply the rating change
let new_rating_a = if is_negative {
1200 - change
} else {
1200 + change
};
println!("Player A's new rating: {}", new_rating_a);
Remember to import the necessary traits and types when using the Rating crate in your project.
Version 1.8.0
Uploaded 14 hours ago
License MIT
Size 3.8 KB
Run the following command in your project dir
scarb add origami_rating@1.8.0
Or add the following line to your Scarb.toml
origami_rating = "1.8.0"