Adjust parameters to make probability distributions looser

(i.e. outcomes depend more on chance).
This commit is contained in:
Condorra 2023-01-23 21:40:36 +11:00
parent 165f5671ac
commit 618d88bb06

View File

@ -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 { 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()) 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 // more positive numbers meaning they did a better job, and more negative numbers
// meaning it went really badly. // meaning it went really badly.
// If level = raw skill, there is a 50% chance of succeeding. // 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 + 3, there is a 75% chance of succeeding.
// level = raw skill - 1, there is a 25% chance of succeeding. // level = raw skill - 3, there is a 25% chance of succeeding.
// Past those differences, it follows the logistic function: // Outside those differences, it follows the logistic function:
// Difference: -5 -4 -3 -2 -1 0 1 2 3 4 5 // 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% // Probability: 13% 19% 25% 32% 41% 50% 59% 68% 75% 81% 86%
#[allow(unused)]
pub fn skill_check_only(who: &Item, skill: &SkillType, diff_level: f64) -> f64 { pub fn skill_check_only(who: &Item, skill: &SkillType, diff_level: f64) -> f64 {
skill_check_fn(calc_level_gap(who, skill, diff_level)) 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); let result = skill_check_fn(gap);
// If the skill gap is 0, probability of learning is 0.5 // 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). // If the skill gap is 1, probability of learning is 0.4 (20% less), and so on (exponential decrease).
const LAMBDA: f64 = -0.6931471805599453; // log 0.5 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 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((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 let Some(mut user) = trans.find_by_username(&who.item_code).await? {
if *user.raw_skills.get(skill).unwrap_or(&0.0) >= 15.0 || if *user.raw_skills.get(skill).unwrap_or(&0.0) >= 15.0 ||