Adjust parameters to make probability distributions looser
(i.e. outcomes depend more on chance).
This commit is contained in:
parent
165f5671ac
commit
618d88bb06
@ -166,7 +166,7 @@ pub fn calc_level_gap(who: &Item, skill: &SkillType, diff_level: f64) -> f64 {
|
||||
}
|
||||
|
||||
pub fn skill_check_fn(level_gap: f64) -> f64 {
|
||||
const K: f64 = 1.0986122886681098; // log 3
|
||||
const K: f64 = 0.3662040962227033; // log 3 / 3
|
||||
rand::thread_rng().gen::<f64>() - 1.0 / (1.0 + (-K * (level_gap as f64)).exp())
|
||||
}
|
||||
|
||||
@ -176,12 +176,11 @@ pub fn skill_check_fn(level_gap: f64) -> f64 {
|
||||
// more positive numbers meaning they did a better job, and more negative numbers
|
||||
// meaning it went really badly.
|
||||
// If level = raw skill, there is a 50% chance of succeeding.
|
||||
// level = raw skill + 1, there is a 75% chance of succeeding.
|
||||
// level = raw skill - 1, there is a 25% chance of succeeding.
|
||||
// Past those differences, it follows the logistic function:
|
||||
// Difference: -5 -4 -3 -2 -1 0 1 2 3 4 5
|
||||
// Probability: 0.4% 1.2% 3.5% 10% 25% 50% 75% 90% 96% 99% 99.6%
|
||||
#[allow(unused)]
|
||||
// level = raw skill + 3, there is a 75% chance of succeeding.
|
||||
// level = raw skill - 3, there is a 25% chance of succeeding.
|
||||
// Outside those differences, it follows the logistic function:
|
||||
// Difference: -5 -4 -3 -2 -1 0 1 2 3 4 5
|
||||
// Probability: 13% 19% 25% 32% 41% 50% 59% 68% 75% 81% 86%
|
||||
pub fn skill_check_only(who: &Item, skill: &SkillType, diff_level: f64) -> f64 {
|
||||
skill_check_fn(calc_level_gap(who, skill, diff_level))
|
||||
}
|
||||
@ -193,9 +192,9 @@ pub async fn skill_check_and_grind(trans: &DBTrans, who: &mut Item, skill: &Skil
|
||||
let result = skill_check_fn(gap);
|
||||
|
||||
// If the skill gap is 0, probability of learning is 0.5
|
||||
// If the skill gap is 1, probability of learning is 0.25, and so on (exponential decrease).
|
||||
const LAMBDA: f64 = -0.6931471805599453; // log 0.5
|
||||
if who.item_type == "player" && rand::thread_rng().gen::<f64>() < 0.5 * (-LAMBDA * (gap as f64)).exp() {
|
||||
// If the skill gap is 1, probability of learning is 0.4 (20% less), and so on (exponential decrease).
|
||||
const LAMBDA: f64 = -0.2231435513142097; // log 0.8
|
||||
if who.item_type == "player" && rand::thread_rng().gen::<f64>() < 0.5 * (LAMBDA * (gap as f64)).exp() {
|
||||
if let Some((sess, _sess_dat)) = trans.find_session_for_player(&who.item_code).await? {
|
||||
if let Some(mut user) = trans.find_by_username(&who.item_code).await? {
|
||||
if *user.raw_skills.get(skill).unwrap_or(&0.0) >= 15.0 ||
|
||||
|
Loading…
Reference in New Issue
Block a user