Larian Banner: Baldur's Gate Patch 9
Previous Thread
Next Thread
Print Thread
#884018 20/08/23 05:10 PM
Joined: Aug 2023
D
stranger
OP Offline
stranger
D
Joined: Aug 2023
Hi all,

I am a researcher in statistics who likes to play video games in his spare time. This idea of "karmic dice" intrigued me, and I thought about it for a bit. I came up with a simple strategy for generating (pseudo) random values that reduce the streaks of positive and negative events.

The main feature of this strategy is that it preserves the long-rung proportions of the usual 1d20 while displaying the desired "karma effect." This does not happen with weighted dice, which, unfortunately, affect the game's balance. Changing the rules is not necessarily bad, but any D&D player knows that there is a difference between 1d20 and 2d10!

Another plus is that the algorithm is straightforward to implement; it can be written in just a few lines of Python code.

I have summarized my thoughts in this blog post: https://tommasorigon.github.io/blogpost/karmic_dice/

I do not know whether Larian came up with the same idea, so I am not sure this idea is "better" than the current option, but I thought it was worth sharing it!

Last edited by DirichPr; 20/08/23 05:13 PM.
Joined: Aug 2021
Volunteer Moderator
Offline
Volunteer Moderator
Joined: Aug 2021
Sweet post! Method seems solid; I might steal it someday ^^

I’ve got two questions.

The first is tied to difficulty class, as in “the actual number threshold that determines success”. Your post seems to imply that any roll above an 11 is lucky and a roll below 10 isn’t. (In your opening example, rolling a bunch of 8s and 9s in a row could be completely fine when additional bonuses are taken into account.) Is there a way to compute the latent karma scores that takes into account the actual success or failure of the attempted action?

The second is about enemies. If you use the same latent karma for players and foes, wouldn’t the positive karma generated by my bad roll be used up by the next character, usually a baddie? Could you perhaps change the karma sign to account for the fact the enemy got lucky which, in a zero sum game, makes me unlucky?


Avatar art by Carly Mazur
Joined: Aug 2023
D
stranger
OP Offline
stranger
D
Joined: Aug 2023
Originally Posted by Flooter
The second is about enemies. If you use the same latent karma for players and foes, wouldn’t the positive karma generated by my bad roll be used up by the next character, usually a baddie? Could you perhaps change the karma sign to account for the fact the enemy got lucky which, in a zero sum game, makes me unlucky?

This is a great point; I should have better clarified this aspect! You are right; if you use the same karma score for PCs and all the NPCs, you get the weird behavior you describe. To fix this, you need to keep track of separate karma scores for each character. It could be a cumbersome operation if you are doing it pen-and-paper, but on a computer, this is a trivial modification of the original script.

Originally Posted by Flooter
The first is tied to difficulty class, as in “the actual number threshold that determines success”. Your post seems to imply that any roll above an 11 is lucky and a roll below 10 isn’t. (In your opening example, rolling a bunch of 8s and 9s in a row could be completely fine when additional bonuses are taken into account.) Is there a way to compute the latent karma scores that take into account the actual success or failure of the attempted action??

This is a more tricky question. Yes, in my post, I implied that 11 is lucky and 10 isn't because the focus was on the dice itself rather than success/failure. This was intentional, but I understand your logic: to some players, it doesn't matter whether you got 5 or 15 if, in the end, you hit the enemy. However, a method that adjusts the dice's roll based on the outcome would penalize good players and help bad players, therefore affecting the game balance. Once again, this could be okay, but it is a more intrusive operation with potentially radical consequences on the gameplay.

Joined: Aug 2021
Volunteer Moderator
Offline
Volunteer Moderator
Joined: Aug 2021
Thank you for your thoughtful answer! Here are further comments and questions.

Originally Posted by DirichPr
You are right; if you use the same karma score for PCs and all the NPCs, you get the weird behavior you describe. To fix this, you need to keep track of separate karma scores for each character. It could be a cumbersome operation if you are doing it pen-and-paper, but on a computer, this is a trivial modification of the original script.
In pen and paper, the GM has a screen behind which all sorts of fate-bending shenanigans can occur. I assume karmic dice exist to emulate this on some level, but that's part of the game design discussion; more on that below.

As far as implementing multiple karma scores in BG3, I'd only keep track of 2 or 3 (both teams get one and maybe a third for the neutrals) if only for optimization purposes. Your solution works perfectly fine, though; this is nitpickiping.

Originally Posted by DirichPr
However, a method that adjusts the dice's roll based on the outcome would penalize good players and help bad players, therefore affecting the game balance. Once again, this could be okay, but it is a more intrusive operation with potentially radical consequences on the gameplay.
Presumably, Larian were hoping for some kind of impact to gameplay when designing karmic dice, which were created in response to some players' complaints that the dice seemed to yield more failure than intuition would suggest. For those players, it's all about hits and misses. We can infer that this is the case from the way karmic dice were implemented in early access (I've no intel on how it works in the release version): The AI would hit high AC characters far more than expected, effectively giving a gameplay advantage to a bad player, in this case the AI.

In a sense, impact on gameplay is unavoidable because the goal is for the player's perception of randomness in the game to match their intuition, biased though it might be. In other words, if players don't notice the feature, it's not really doing it's job. That's not to say your method wouldn't be noticeable, I believe it should be tested in a mod, but "better" to Larian means "makes the target audience happier", so we shouldn't shy away from mathematically inelegant solutions if they're effective.

Here's the tweak I'd like to propose and subsequently study. I think that the distribution remains uniform despite the influence of latent karma because the kappa coefficient is constant, ie bad karma is weighted the same as good karma. If kappa increased whenever the player failed and decreased when they succeeded (inversely for AI), players would benefit from good runs while being less likely to experience bad runs, which "feels fair" to our flawed brains. This would hopefully achieve an effect similar to a GM reading the room. Calibrating kappa's rate of change (arithmetic? geometric?) requires testing; I'm curious to know if there's a way to establish a formal equation linking kappa and the new random variable we've created.

P.S. I realize there wasn't a question in there, aside from an implicit request for comment, but I do have a stats question I can't wrap my head around involving Magic the Gathering, odds of streaks and card counting. Would you mind if I DMed some specifics?

Last edited by Flooter; 21/08/23 09:54 PM. Reason: Various tweaks

Avatar art by Carly Mazur
Joined: Aug 2023
D
stranger
OP Offline
stranger
D
Joined: Aug 2023
Originally Posted by Flooter
Here's the tweak I'd like to propose and subsequently study. I think that the distribution remains uniform despite the influence of latent karma because the kappa coefficient is constant, ie bad karma is weighted the same as good karma. If kappa increased whenever the player failed and decreased when they succeeded (inversely for AI), players would benefit from good runs while being less likely to experience bad runs, which "feels fair" to our flawed brains. This would hopefully achieve an effect similar to a GM reading the room. Calibrating kappa's rate of change (arithmetic? geometric?) requires testing; I'm curious to know if there's a way to establish a formal equation linking kappa and the new random variable we've created.

Once you accept that the game balance can be changed, we have a lot of modeling flexibility as we enter into the realm of "weighted dice". Let us try to modify the original karma dice, for the sake of simplicity. I am not against having a parameter that dynamically changes (statisticians would call it time-dependent), but instead of modifying \kappa I would include an additional parameter, say \mu_t, which plays the role of the *trend*. By modifying \kappa, we would tweak the level of determinism of the dice (entirely random vs almost deterministic) but that's not what we want. Instead, by changing \mu we get the desired effect of modifying the average success rate.

The modified karma equation, only for players and not NPCs, would look like this (you need a bit of imagination as LaTeX does not work here):

Y_t = \mu_t - \kappa_t Y_{t - 1} + \epsilon_t.

Now, if \mu_t = \mu (i.e. a constant trend that does not change over time), this is essentially adding a hidden bonus if \mu > 0, and a malus otherwise, to all the rolls. The parameter \mu could be selected by the players as part of the "game difficulty". The mathematics is particularly neat in this special case: we still get closed-form expressions for the stationary law, and therefore, we can study the resulting random variable. Hence, we could select \mu so that the expected value of the dice is, say, 12-13 (bonus, easy mode) or 8-9 (malus, hard mode).

A more elaborate idea would be to allow \mu_t to change over time and be *adaptively* selected. A complication is that the same score, say 15, is sometimes a success and, in other cases, a failure. Nonetheless, a first idea could be keeping track of the average number of the most recent successes and failures, say \pi_t, and then set \mu_t = qnorm(\pi_t, 0, sigma), where qnorm is the quantile function of a Gaussian with a variance depending on \kappa. There is a tight connection between this approach and probit regression and Kalman filtering, so I can certainly envision more sophisticated ideas based on supervised learning, but I guess I will stop here smile It looks already like an overshoot!

Originally Posted by Flooter
P.S. I realize there wasn't a question in there, aside from an implicit request for comment, but I do have a stats question I can't wrap my head around involving Magic the Gathering, odds of streaks and card counting. Would you mind if I DMed some specifics?

Sure, go ahead! But I cannot guarantee I will have any smart ideas smile

Last edited by DirichPr; 22/08/23 07:27 AM.

Link Copied to Clipboard
Powered by UBB.threads™ PHP Forum Software 7.7.5