Pathfinder: Kingmaker

Pathfinder: Kingmaker

View Stats:
Msalgado Sep 30, 2018 @ 4:45pm
About Dice Rolls - are they really totally random?
Just a simple question:
Are the dices TOTALLY random, no matter the Diff. level, or are they being changed by some unseen factor?

I searched but found no info on this.
Have any devs mentioned anything about this?

I really hope that they are totally random, but I got the felling that when I changed to easy or story mode I began seeing a lot more 4s... 7s.. from enemies.
BUT it may be totally a wrong impression.
So, anyone read anything to confirm they are NOT being changed by anything?
Originally posted by Marksteele:
Taking a brief look through the code it looks like they use the following for dice rolls

private static int D(int rolls, DiceType dice) { int num = 0; while (rolls-- > 0) { int num3 = Random.Range(1, dice.Sides() + 1); num += num3; } return num; }

So ya, no difficulty modifiers or anything effecting randomness unless its buried deeper in that specific event (all this shows is there's no "difficulty" modifer that effects every roll). Do note however; there are some "predetermined" dicerolls in the code that seem to trigger for specific events and there is also code to override a diceroll. They also have a die for 2, 3, 4, 6, 8, 10, 12 and 20 that could be used in various triggers (hence the dice.Sides() call)

Edit: for thsoe who live to dig like I do, this is located in the kingmaker.rulesystem namespace and is part of the rulebookEvent class
< >
Showing 16-26 of 26 comments
casius Oct 7, 2018 @ 11:24pm 
playing unfair. have amiri +38 attack (i know it dosnt matter). she rolled 5 times in raw 1. played engouhg pnp and crpg to know this is abnormal. just count proabolity if you want on d20 for 1 5 times in a raw. and on unfair to have twice in a raw 1 is normal thing, you have to take into account that this will happen in fight. the amount of times i loaded game becuase the amount of people rolled 1 in encounter is unreal.
Msalgado Oct 8, 2018 @ 4:58am 
Originally posted by Marksteele:
Taking a brief look through the code it looks like they use the following for dice rolls

private static int D(int rolls, DiceType dice) { int num = 0; while (rolls-- > 0) { int num3 = Random.Range(1, dice.Sides() + 1); num += num3; } return num; }

So ya, no difficulty modifiers or anything effecting randomness unless its buried deeper in that specific event (all this shows is there's no "difficulty" modifer that effects every roll). Do note however; there are some "predetermined" dicerolls in the code that seem to trigger for specific events and there is also code to override a diceroll. They also have a die for 2, 3, 4, 6, 8, 10, 12 and 20 that could be used in various triggers (hence the dice.Sides() call)

Edit: for thsoe who live to dig like I do, this is located in the kingmaker.rulesystem namespace and is part of the rulebookEvent class

Thanks a lot for the work, Mark, and all other for feedback.

Guess I can consider that if rolls are being manipulated, it's probably not "the norm" here.
At least difficulty is not actually handling rolls, from what data we have.
Banker721 Oct 23, 2018 @ 7:01pm 
Not sure how random this RNG is. I reloaded a skill check 10 times. Every single time, the roll is below 10. That's 1/2^10 chance.

I know all this about law of large numbers and confirmation bias but this is the first game things are as bad as this. I've seen this on multiple occasions too.
Last edited by Banker721; Oct 23, 2018 @ 7:03pm
wendigo211 Oct 23, 2018 @ 7:38pm 
There are a couple of issues:

First off random numbers aren't random. They are generated by a pseudo random number generator. Generally speaking these generators create a sequence of numbers that, for a uniform distribution, meet the following criteria:
  1. Every number in the sequence is equally likely to occur.
  2. The probability of outcome Y following outcome X, is the same for all values of X and Y.
  3. The sequence generated is the same on different computers (portability).
These are the basic tests of pseudo-random numbers and I've simplified them. The result of this is you get a deterministic sequence of numbers that looks random. For most software applications the onus is on the programmer to prove that their random numbers meet these criteria. For the gaming industry, the end user has to perform these tests or accept the results. There are enough example of games with bad RNGs that I'm not content to simply dismiss anecdotal evidence as confirmation bias out of hand (most of the time it is, but I can think of several games: NWN, Mordhiem, Blackguards, etc. that had to patch the RNG).

Secondly, as I mentioned the sequence is deterministic. The illusion of randomness is created by reading the sequence at a different starting point each time. The start point of the sequence is called the seed. How the game selects the seed and the conditions that it changes it for are very important for creating the illusion of randomness. Note that while an RNG may meet the criteria for randomness, the distribution of numbers created by reloading and looking at the first roll more than likely will not meet those criteria if the game reseeds on a reload. This is because the algorithm that handles reseeding more than likely is not a PRNG. I suspect that this game does reseed on reload, but I haven't bothered to test this.
Last edited by wendigo211; Oct 23, 2018 @ 7:43pm
Straph Oct 23, 2018 @ 7:44pm 
Originally posted by Ventus:
There is no such thing as random for a computer program. Its all based on an alglothrim and an input. The better the algorithm, the more "random" things feel. Owlcat has not made public or stated anything specifically about the d20 RNG method in the context you mentioned.

Also, there is no way to validate what your asking/suggesting due to its very nature:
-If the d20 rolls are being weighted, there is no way to know other than the observation that "in 100 rolls, I only got 1-11 and never 12-20s"
-If the d20 rolls are NOT being weighted, its still possible to observe that "in 100 rolls, I only got 1-11 and never a 12-20 result"

Since the same outcome is possible in both senarios, more than the observation itself is needed (and we don't have more to go on).

Wish I had better news for you. I too feel like I see way way way too many 4s (more than anything else) but that could be perception bias too.

Roll20 begs to differ. https://wiki.roll20.net/QuantumRoll
Drake Oct 25, 2018 @ 5:31am 
Originally posted by Straph:
Originally posted by Ventus:
There is no such thing as random for a computer program. Its all based on an alglothrim and an input. The better the algorithm, the more "random" things feel. Owlcat has not made public or stated anything specifically about the d20 RNG method in the context you mentioned.

Also, there is no way to validate what your asking/suggesting due to its very nature:
-If the d20 rolls are being weighted, there is no way to know other than the observation that "in 100 rolls, I only got 1-11 and never 12-20s"
-If the d20 rolls are NOT being weighted, its still possible to observe that "in 100 rolls, I only got 1-11 and never a 12-20 result"

Since the same outcome is possible in both senarios, more than the observation itself is needed (and we don't have more to go on).

Wish I had better news for you. I too feel like I see way way way too many 4s (more than anything else) but that could be perception bias too.

Roll20 begs to differ. https://wiki.roll20.net/QuantumRoll

In the case of quantum rolls, the seed is not generated by a computer, but from an external source, the computer is just reading and manipulating the raw result. It's as if you had someone roll real dice all day, use a camera to read all the rolls and have the server send them to people that are playing at the moment.

Real computer RNG only uses its internal clock and/or current time at the core, which is always pseudo random at best, because a clock is a clock, it's predictable.
VoD Oct 25, 2018 @ 6:38am 
Most of this is confirmation bias. You don't bat an eyelid when your roll to open the lock or disarm the trap succeeds. You certainly don't reload and roll again and again and then get mad that you successfully opened the lock 3 times in a row. But God forbid you fail 3 times in a row - then the dev coded the dice specifically to screw you over xD. If you were to track all your lock/trap rolls throughout the game you'd probably see that you're rolling high just as often as you're rolling low.
Gregorovitch Oct 25, 2018 @ 6:39am 
Originally posted by wendigo211:
Secondly, as I mentioned the sequence is deterministic. The illusion of randomness is created by reading the sequence at a different starting point each time. The start point of the sequence is called the seed. How the game selects the seed and the conditions that it changes it for are very important for creating the illusion of randomness. Note that while an RNG may meet the criteria for randomness, the distribution of numbers created by reloading and looking at the first roll more than likely will not meet those criteria if the game reseeds on a reload. This is because the algorithm that handles reseeding more than likely is not a PRNG. I suspect that this game does reseed on reload, but I haven't bothered to test this.

Well it doesn't look like any thing like that is going on here:

Originally posted by Marksteele:

private static int D(int rolls, DiceType dice) { int num = 0; while (rolls-- > 0) { int num3 = Random.Range(1, dice.Sides() + 1); num += num3; } return num; }

This is just making a straight call to the C# Random library function ( I assume it's C# 'cos Unity). All languages have a built in Random library function and all game devs use them as they are very fast and fit for purpose. Most library random functions use the system clock in milliseconds to seed the RNG calculation since this makes the result unpredictable in practice (although obviously predictable for any specific given value.

Some games, notably XCOM, implement an anti-savescumming scheme but grabbing a standard library random number call at the start of a level/mission to genenrate a fixed seed for the mission/level and saving it privately. This number is then fed into the first RNG call as the seed, then the output of the first call is used as seed for the second manually, then the output of the second to seed the third and so on. This can be accomplished in code becasue most language random library functions give you the option of providing your own seed as a parameter to the call if you so choose. This has the effect of creating an immutable list of rolls that don't change no matter how many times you reload.

That is not going on here (either anti-save scumming or manual seed feeding) as can be seen from the code.

Other games, again notably XCOM, fiddle the RNG results in favour of the player by smoothing out bad roll series. Except on Legendary difficulty (and possibly Commanderm I can't recall now) if you miss more than two shots you get an extra 5% To Hit, then another +5% if you miss again etc until you do hit.

Again that is not going on here as can be seen from the code.

Which means the rolls in PK are straight as a die (pun intended)

Ther are two reasons people think game die rolls are not straight:

1. Confirmation bias/loss aversion fallacies - you notice failed rolls about twice as much as you notice successful ones. Same reason you feel the loss of $10 roughly twice as bad as you feel joy at finding $10.

2. Gambler's fallacy - the belief that if something doesn't happen one time it is more likely to happen next time. In fact, if random, a series of bad rolls is exactly as likely to occur as a series of good rolls which itself is exactly as likely to occur as a series of mixed rolls. But humans perceive a series of mixed rolls as inherantly more random than a series of good or bad ones. Which is a fallacy and the source of many a gambler's fate and a casino's profit.
SIlverblade-T-E Oct 25, 2018 @ 1:51pm 
as said, the ONLY truly random computer generated number maker I know of, uses radioactive decay from an isotope, thus being truly random
but that's kind of expensive and not gonna be in every PC unless we end up like "Fallout" haha :p
Kyutaru Oct 25, 2018 @ 1:56pm 
Originally posted by SIlverblade-T-E:
as said, the ONLY truly random computer generated number maker I know of, uses radioactive decay from an isotope, thus being truly random
but that's kind of expensive and not gonna be in every PC unless we end up like "Fallout" haha :p
Though for the game's purposes, the Random library is random enough. Computers are simply prone to having strings of similar values once in a blue moon. Reload and try again is the solution in those circumstances. But it's exceedingly rare and considering they're using the default programming language version of RNG, which is used as a basis in most applications, it's plenty randomized.
wendigo211 Oct 25, 2018 @ 4:00pm 
Originally posted by Gregorovitch:
Well it doesn't look like any thing like that is going on here:

Originally posted by Marksteele:

private static int D(int rolls, DiceType dice) { int num = 0; while (rolls-- > 0) { int num3 = Random.Range(1, dice.Sides() + 1); num += num3; } return num; }

That code doesn't tell you if the game is being reseeded on a reload. You would actually have to check the code that executes on a reload and check if the seed function is being called for the RNG. Anyway that they are using the standard C# random function isn't good news. IIRC that would be Donald E. Knuth's subtractive random number generator algorithm. Subtractive RNGs have problems in that the lower bits are not random and there are several seed values for which it fails (It's better than a linear congruential generator, but not by much). If that's the algorithm they're using, then the game does have RNG issues.
< >
Showing 16-26 of 26 comments
Per page: 1530 50

Date Posted: Sep 30, 2018 @ 4:45pm
Posts: 26