I’m using a seed to pull locations for actors to spawn at, and I increment it every iteration of the for loop.
I use this seed to determine the location and actor type from an array, but since the seed increment by just 1, the location and the switch on int seem to as well?
I was under the impression seeds were entirely random? How would it always be incrementing 1 if it uses a new “pattern” every seed? I’m breaking the seed the player sets, incrementing that int and using that to make a new seed which then decides random int values in a range. But since it just increments I get the same actors down the array list.
Yeah I understand that, but say I want the stream to decide the same location for multiple actors. How would I do that? If I use the same stream over and over again it will plop all actors in the same spot, since it pulls the same number.
But say I got an array of actors and I use a loop to generate a random int to say which actor to pull from array. In that loop, it will just reuse the same int once it is decided by the stream, I attempted to solve this with an increment int on the stream and then use that for the next number but it just increments down the array for some reason?
But I want the randomness to be predictable from the base stream. If player 1 finds a cool room in the dungeon, I want them to be able to share the dungeon seed for other players. If I use a random with no stream it will never generate the same again.
Let’s say I have an array of 5 actors, and a for loop that will spawn them in. The amount of actors, location and which actors are all based on the seed and decided in this loop. The player sets the seed to 0.
Stream 0 picks 2 for the first actor to spawn, and then it just repeatedly picks 2 everytime.
I attempted to solve this by making every iteration of my loop increment the random stream the player sets by 1. Since the stream is different surely the next number it chooses would be random. But it also increments the number it picks.
So then stream 0 picks 2 for the first actor, the loop increments the stream and then the new stream of 1 picks 3, the loop increments the stream and then the new stream of 2 picks 4, repeat.
Since the stream is different shouldn’t what it picks be different? I need the stream to give me a predictable random actor spawn loop.
It seems that if you use “pass by reference” on the random stream input on your functions it will actually create a random predictable set of numbers that is different per stream.
Keeping this up for posterity as it took me a couple solid hours of googling to find that nugget of info, cheers!