XCOM 2
Grundy May 13, 2022 @ 2:12pm
RNG - Is there a mod?
I have been researching a little online about when the RNG gets seeded and it appears it gets seeded at the beginning of a mission and the seed is saved with the save.

This offends me.

Does anybody know if there is a mod that would reseed the RNG at the instant of each click that requires a random number? You know, like dice.

See, when dice are in my hand I cup my other hand over them and jiggle them around before I throw them. I do this so that their result is unpredictable.
< >
Showing 1-15 of 58 comments
Dallas S May 13, 2022 @ 2:59pm 
This comment is awaiting analysis by our automated content check system. It will be temporarily hidden until we verify that it does not contain harmful content (e.g. links to websites that attempt to steal information).
Amanoob105 May 13, 2022 @ 3:05pm 
Saying that a bunch of computer code "offends you" is a lot like saying that because a door doesn't open for you on its own you are offended by the door. You're getting offended at a thing that can only ever do exactly what it was made for in the way it was made to do it and nothing else.
It's not a smart comment.

----

Short answer to the question would be "no", simply because what you want isn't possible on a computer.

Not so short answer would be;
Computers can't do random like exactly like a dice, everything within them is all "1"s and "0"s, on or off, yes or no. Next you'll be asking that they think for themselves the same as we can.
What they can do is try to simulate random, which simply is what an RNG is.

The game effectively does already roll for each and every click but in order to to be able to do this it needs that opening roll, the seed, in place for this function to work.
But it can't just forgot the old rolls as they are needed to create the new ones.

If you want the really long answer where someone explains to you in heavy detail all the things you don't understand about computers and RNGs, I recommend giving it a few hours.
portnite May 13, 2022 @ 3:37pm 
"is there a mod that allows me to savescum because i made a bad decision?"
Grundy May 13, 2022 @ 4:08pm 
I have a degree in mathematics. I understand pseudo-random number generation.

What offends me, specifically, is the saving of the pseudo-random number generator's seed when I save. The reason it offends me is that it creates the situation where the computer is going to give me false information from that point on. I use information to make decisions. If the information given to me is false, then the decisions I make will be based on false information. The specific false information, in this case, is when I hover over an enemy to decide if I want to shoot it. It says I have a certain percentage of a chance to hit, when in fact, I don't.

Also, knowing that any of my games has unnecessarily pre-rolled my random numbers is distasteful to my mind. I say unnecessarily because the pseudo-random number can be re-seeded using the system clock based on the instant I click.

I understand the reasoning behind saving the seed with the save, I just don't like being misled. Thus, the offence.

It is like when a computer tells me that it is 100% complete with an update. I sometimes stare at the screen for minutes with the computer telling me it is 100% complete when It is clearly still not finished. I understand how this happens. I understand that just because my computer is informing me of something that it does not imply the information is accurate.

But every time it happens it offends me. It is not debilitating, but it is unnecessary. I write programs. When they update, they never tell the end user they are 100% complete because I write them to say 99.99% complete until they close.

The reason I created this post was to ask the question if a mod existed. I did see a mod that re-seeded after each save, I just thought, If I had my druthers, it would re-seed for every click. Still pseudo, but for this purpose, indistinguishable from rolling the dice.
Grundy May 13, 2022 @ 4:25pm 
To be clear, this is not about save scumming to me. I would prefer my pseudo-random numbers to be generated in the moment even for Ironman runs. I guess what I am really rallying against is fate.

When I play non-ironman I save scum, but not at the shot level. I usually will re-fight an entire mission if more than half of my crew get killed, or if even one of my best soldiers gets killed. I like that the mission will generate a different map with different enemies. But sometimes I will save scum in the middle of a mission if I have played the same mission several times with bad outcomes.

In all cases, ironman, non-ironman fresh mission, non-ironman mid mission, I prefer the outcome to not be predetermined. But it may be that I have been fated to write this entire post since the big bang. I just don't have to like it.
Steve (Dawn's Hubby) (Banned) May 13, 2022 @ 4:28pm 
Obvious irony people. If not, then...
Hammer_Squirrel May 13, 2022 @ 4:40pm 
Originally posted by Grundy:
I have a degree in mathematics.

Unless you (1) specialized in number theory and cryptographic applications and (2) can prove this then this doesn't really carry much weight.

A common junior developer mistake is to reseed a PRNG every time a random number request is made. PRNGs are statistically random along a sequence and are not designed to have statistically random values across the first value across seeds.

https://en.wikipedia.org/wiki/Pseudorandom_number_generator

In practice, the output from many common PRNGs exhibit artifacts that cause them to fail statistical pattern-detection tests. These include:

Shorter-than-expected periods for some seed states (such seed states may be called "weak" in this context);
Lack of uniformity of distribution for large quantities of generated numbers;
Correlation of successive values;
Poor dimensional distribution of the output sequence;
Distances between where certain values occur are distributed differently from those in a random sequence distribution.

https://blog.unity.com/technology/a-primer-on-repeatable-random-numbers

Can't I just use random number generators with different seed values?
No! This is a very common misconception about RNGs. The fact is that while the different numbers in the same sequence are random in relation to each other, the same indexed numbers from different sequences are not random in relation to each other, even if it may look like it at first glance.

So if you have 100 sequences and take the first number from each, those numbers will not be random in relation to each other. And it won't be any better if you take the 10th, 100th, 1000th number from each sequence.

NIST recommends a reseed interval of 2^48 if I remember correctly, which is perfectly fine for a PRNG like in XCOM 2 where the internal state is not revealed, even with mods. SP800-90a, SP800-90b. and SP800-90c should make for good reading,
Steve (Dawn's Hubby) (Banned) May 13, 2022 @ 4:53pm 
Maybe they have a mod where you can roll two 10 sided dice to generate the shot percentage every attack and then enter it in manually. (JK).
Hammer_Squirrel May 13, 2022 @ 4:56pm 
This thread also has some really good information https://steamcommunity.com/app/268500/discussions/0/3270185687326744259/
Steve (Dawn's Hubby) (Banned) May 13, 2022 @ 5:01pm 
Yeah, what it amounts to is that computers don't generate random numbers well, so they have to generate a lot of them and make them average to simulate reality. As a side note, I had a 90 percent shot average at the end of the game last time, you know when it shows you all of the stats just to prove it's not cheating you, and I am honestly a rather average player.
Dallas S May 13, 2022 @ 5:32pm 
Originally posted by Grundy:
To be clear, this is not about save scumming to me. I would prefer my pseudo-random numbers to be generated in the moment even for Ironman runs. I guess what I am really rallying against is fate.

When I play non-ironman I save scum, but not at the shot level. I usually will re-fight an entire mission if more than half of my crew get killed, or if even one of my best soldiers gets killed. I like that the mission will generate a different map with different enemies. But sometimes I will save scum in the middle of a mission if I have played the same mission several times with bad outcomes.

In all cases, ironman, non-ironman fresh mission, non-ironman mid mission, I prefer the outcome to not be predetermined. But it may be that I have been fated to write this entire post since the big bang. I just don't have to like it.


Your railing against fate is really irrelevant if you are not save scumming.

Despite the fact that the rolls are pre rolled, you have absolutely no way of knowing what the pre roll is. If you're not save scumming, it functions 100% exactly like if it was rolling a new roll every shot.

In a sense imagine you roll the dice a hundred times, don't get to see the results, and then as you play you take the rolls in order. It's still random whether you did the rolls 5 minutes ago or right now as you shoot.

When you miss you get upset that you missed, because that was already determined before you made the shot and perhaps you would have hit if the roll was rolled right then rather than fated, right? Well that is really exactly the same when you roll as you shoot, and happen to miss. Without save scumming, your fate is determined regardless whether it was pre rolled or you roll it now.

It seems to just be a mental block for you for something that is functionally exactly the same (as long as you aren't reloading and doing the same rolls).
Last edited by Dallas S; May 13, 2022 @ 5:42pm
99Random May 13, 2022 @ 5:47pm 
Originally posted by Grundy:

I understand the reasoning behind saving the seed with the save, I just don't like being misled. Thus, the offence.

You are not being misled, it is just your perception of the event. If a shot from a character says 90% and the pre-rolled number is 91, you miss. Your perception is that the game is telling you there is only 10% chance the attack will fail, but the failure has already been determined and therefore you are "being misled". As the above post pointed out, you only know there is a pre-rolled outcome if you save scum.

This is functionally no different from the RNG rolling a 91 at the time of the attack.

It is only different if you save scum. You can save scum here by re-loading and looking for an attack from another character that has 91% or better chance. This is different from RNG at time of attack where you re-load endlessly until you get a roll that is successful.
Last edited by 99Random; May 13, 2022 @ 5:48pm
Heau May 13, 2022 @ 6:11pm 
Originally posted by Hammer_Squirrel:
Originally posted by Grundy:
I have a degree in mathematics.

Unless you (1) specialized in number theory and cryptographic applications and (2) can prove this then this doesn't really carry much weight.

My personal experience in applied statistics/survey methodology where we do a lot of simulation, is that the majority of people with either statistical training or computer science training misunderstand and misuse PRNG seeding as they work from their abstract conception rather than the specific algorithm documentation which can vary accross software or across methods within software.

Most code I was provided from past project in my early years exhibited reseeding in places where the programming could've avoided it and the specific algorithm had severe risks of strong sequences correlation from 2 seeds which is an undesirable property single seeded sequences don't exhibit until you hit their period.

Originally posted by Grundy:
The reason I created this post was to ask the question if a mod existed. I did see a mod that re-seeded after each save, I just thought, If I had my druthers, it would re-seed for every click. Still pseudo, but for this purpose, indistinguishable from rolling the dice.

This is very much a mathematical conception error. If the resulting sequence of random numbers generated by using the PRNG to reseed and pick the first number from a seed at every step, then the PRNG would do that built in.

But realistically, if you do that, why stop at 1 reseeding? Why not recursively reseed to some stopping condition, wouldn't that be even better then? The simple answer is because the single seeded sequence of number is actually what is being studied in depth for its statistical properties when new PRNG algorithms are proposed in scientific literature. There's a wide range of algorithms and many, in particular the few older ones I've come across, actually run a risk that sequences from 2 seeds could be extremely strongly correlated to one another thus joining multiple seeds together to generate a string of numbers would have far worse statistical properties than single seeded sequence. Now those concerns are more for monte carlo simulations of scale beyond an xcom gaming session or even an entire playthrough.



But really my point is you (and many other people unhappy about saved seeds) are trying to argue about the statistical properties with solutions that would be at best the same but quite possibly worse for most PRNG.

People don't need to make a mathematical demonstration that the implementation is somehow statistically wrong or outright "cheating" to dislike the software design decision to save a seed in the save file in order to curb save scumming. And people shouldn't be ashamed of save scumming or wanting to if that is how they find the most enjoyment in games.

But understand that other players appreciate the effort from the designers to curb save scumming. I know I would spend far more time reloading than playing the game if it weren't for ironman+fixed seed. I did it in my blind playthrough and it worsened my experience to a degree.

Trying to shift blame towards statistical properties rather than owning up to the desire to save scum more easily only repeatedly drives the conversations away from your main goal, i.e. merely wanting a mod that makes the rng mechanism more convenient for how you feel you would best enjoy the game.


Good luck finding such a mod, or making your own. I am sadly of no help for that core question of yours.
Last edited by Heau; May 13, 2022 @ 6:34pm
Hammer_Squirrel May 13, 2022 @ 7:09pm 
I'll add to the above that there are some scenarios where you do want to reseed at some point because the internal state of the PRNG has to be revealed and there are potential adversarial actors, particularly in casino gaming. Doing so, though, requires a really good source of entropy with which to seed the PRNG. And even then you wouldn't reseed with every pull of the slot machine because you'd deplete your source of good seed values.

Originally posted by Heau:
Good luck finding such a mod, or making your own. I am sadly of no help for that core question of yours.

As far as I'm aware this is not possible to mod. The developers did a good job of offloading logic from the main executable to allow a wide array of mods, but the randomness generation and hit resolution mechanics are baked in to the compiled code.
Grundy May 13, 2022 @ 7:32pm 
Like I said, I saw a mod that re-seeds upon reloading a save, which made me think there might be one that does it different. None of this has anything whatsoever to do with my being unhappy with the developers of this amazing game or being angry at the outcome of anything in game. I play ironman on some runs and save scum on other runs. I impose all kinds of personal restrictions in some of my saves.

When playing, there have been many times when I have been frustrated by the outcome of a roll or a series of rolls. I have yelled at the game and my luck, but I have never blamed the code or the methods which bring about the outcomes. My curiosity about the existence of a mod did not come about from being in anyway disgruntled by the way the game is right now.

I think this may just be a sore spot in the community.

I understand that different methods for generating numbers give different statistical outcomes. I understand that a given method may be deficient at producing a statistically good approximation to actual random numbers until sufficiently iterated. I understand that since I don't see the pre-generated list that in essence it is identical to a list being generated as needed from my perspective.

I am not wanting a mod that makes it so that I can save, shoot, miss, then reload and repeat this until I hit. That would be equivalent to a mod that makes it so that I can''t miss ever, just easier to use.

But it seems to me by saving the seed with the save, I am saving the future rolls with the save. Maybe I know the next shot is a miss so I wait one turn and then miss something less important. I just want my decisions to be based solely on the percentage shown.

It's like the many worlds hypotheses where each new chance generates multiple realities once each for all the outcomes. I think of saves that way. If you don't save the seed with the save, then anything can happen. If you do, then some things can happen and some things can't. :(

But perhaps what I want isn't possible. When I generate a random number I want two things, that I don't know what it will be ahead of time and the universe doesn't either.
< >
Showing 1-15 of 58 comments
Per page: 1530 50

Date Posted: May 13, 2022 @ 2:12pm
Posts: 58