From cda93af6431b2c2f9bb17ef7db6a741eb967c15b Mon Sep 17 00:00:00 2001 From: Putnam Date: Sat, 29 Aug 2020 01:41:42 -0700 Subject: [PATCH] Fixes dynamic... again. --- .../gamemodes/dynamic/dynamic_storytellers.dm | 54 ++++++++++--------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/code/game/gamemodes/dynamic/dynamic_storytellers.dm b/code/game/gamemodes/dynamic/dynamic_storytellers.dm index 148de9568a..21178baa12 100644 --- a/code/game/gamemodes/dynamic/dynamic_storytellers.dm +++ b/code/game/gamemodes/dynamic/dynamic_storytellers.dm @@ -126,8 +126,9 @@ Property weights are: for(var/property in property_weights) if(property in rule.property_weights) // just treat it as 0 if it's not in there property_weight += rule.property_weights[property] * property_weights[property] - if(property_weight > 0) - drafted_rules[rule] = rule.get_weight() * property_weight * rule.weight_mult + var/calced_weight = (rule.get_weight() + property_weight) * rule.weight_mult + if(calced_weight > 0) // negatives in the list might cause problems + drafted_rules[rule] = calced_weight return drafted_rules /datum/dynamic_storyteller/proc/midround_draft() @@ -144,21 +145,22 @@ Property weights are: for(var/property in property_weights) if(property in rule.property_weights) // just treat it as 0 if it's not in there property_weight += rule.property_weights[property] * property_weights[property] - if(property_weight > 0) - var/threat_weight = 1 - if(!(rule.flags & TRAITOR_RULESET) || (rule.flags & MINOR_RULESET)) // makes the traitor rulesets always possible anyway - var/cost_difference = abs(rule.cost-(mode.threat_level-mode.threat)) - /* Basically, the closer the cost is to the current threat-level-away-from-threat, the more likely it is to - pick this particular ruleset. - Let's use a toy example: there's 60 threat level and 10 threat spent. - We want to pick a ruleset that's close to that, so we run the below equation, on two rulesets. - Ruleset 1 has 30 cost, ruleset 2 has 5 cost. - When we do the math, ruleset 1's threat_weight is 0.538, and ruleset 2's is 0.238, meaning ruleset 1 - is 2.26 times as likely to be picked, all other things considered. - Of course, we don't want it to GUARANTEE the closest, that's no fun, so it's just a weight. - */ - threat_weight = abs(1-abs(1-LOGISTIC_FUNCTION(2,0.05,cost_difference,0))) - drafted_rules[rule] = rule.get_weight() * property_weight * rule.weight_mult * threat_weight + var/threat_weight = 1 + if(!(rule.flags & TRAITOR_RULESET) || (rule.flags & MINOR_RULESET)) // makes the traitor rulesets always possible anyway + var/cost_difference = abs(rule.cost-(mode.threat_level-mode.threat)) + /* Basically, the closer the cost is to the current threat-level-away-from-threat, the more likely it is to + pick this particular ruleset. + Let's use a toy example: there's 60 threat level and 10 threat spent. + We want to pick a ruleset that's close to that, so we run the below equation, on two rulesets. + Ruleset 1 has 30 cost, ruleset 2 has 5 cost. + When we do the math, ruleset 1's threat_weight is 0.538, and ruleset 2's is 0.238, meaning ruleset 1 + is 2.26 times as likely to be picked, all other things considered. + Of course, we don't want it to GUARANTEE the closest, that's no fun, so it's just a weight. + */ + threat_weight = abs(1-abs(1-LOGISTIC_FUNCTION(2,0.05,cost_difference,0))) + var/calced_weight = (rule.get_weight() + property_weight) * rule.weight_mult * threat_weight + if(calced_weight > 0) + drafted_rules[rule] = calced_weight return drafted_rules /datum/dynamic_storyteller/proc/latejoin_draft(mob/living/carbon/human/newPlayer) @@ -180,12 +182,13 @@ Property weights are: for(var/property in property_weights) if(property in rule.property_weights) property_weight += rule.property_weights[property] * property_weights[property] - if(property_weight > 0) - var/threat_weight = 1 - if(!(rule.flags & TRAITOR_RULESET) || (rule.flags & MINOR_RULESET)) - var/cost_difference = abs(rule.cost-(mode.threat_level-mode.threat)) - threat_weight = 1-abs(1-(LOGISTIC_FUNCTION(2,0.05,cost_difference,0))) - drafted_rules[rule] = rule.get_weight() * property_weight * rule.weight_mult * threat_weight + var/threat_weight = 1 + if(!(rule.flags & TRAITOR_RULESET) || (rule.flags & MINOR_RULESET)) + var/cost_difference = abs(rule.cost-(mode.threat_level-mode.threat)) + threat_weight = 1-abs(1-(LOGISTIC_FUNCTION(2,0.05,cost_difference,0))) + var/calced_weight = (rule.get_weight() + property_weight) * rule.weight_mult * threat_weight + if(calced_weight > 0) + drafted_rules[rule] = calced_weight return drafted_rules /datum/dynamic_storyteller/proc/event_draft() @@ -196,8 +199,9 @@ Property weights are: for(var/property in property_weights) if(property in rule.property_weights) property_weight += rule.property_weights[property] * property_weights[property] - if(property_weight > 0) - drafted_rules[rule] = rule.get_weight() + property_weight * rule.weight_mult + var/calced_weight = (rule.get_weight() + property_weight) * rule.weight_mult + if(calced_weight > 0) + drafted_rules[rule] = calced_weight return drafted_rules