Pseudorandom number generator

What is the best way to do pseudorandom number generation through a seed? I am currently making a procedurally generated world where the position of actors in the world wont change so number random generation wont work here.

I think it will be best if I use the location as a seed and generate the surround around the player with each tick. The world should be technically endless.

So if I understand what you’re saying, you have actors that have a fixed location in an infinite world, so presumably an infinite number of actors.

PNG still works for this, but you must build the areas that are constrained first. So you start by building the player’s location, then you build the locations of nearest actors first. Finally you connect them using randomly generated structures so the player can get to all the actors.

When the player is moving around the world, you only want to build new area in the direction the player is moving. If you try to do more, your game will be too slow. You may also need to collect and store old regions to reduce memory useage as the play may never return there. If he does, you have to recreate the old geometry from the stored data.

I plan on giving every actor a timer that ticks every 0.5 seconds. If it detects the player is out of range then deletes itself. And if the player is moving to a new area, detect everything in the 500 radius or so and calculate what should be present there and build it.

I am going to use pseudo random number generator so everything would be the way it should be no matter how many times the player comes to that area.

I need help how do I use this. std::mersenne_twister_engine - cppreference.com work

Have you looked at Random Streams? It does everything you need (I think).

Hmm I wanted to do it in c++. I can still do it using the FMath::RandInit() and FMath::Rand but the algorithm they use are not that good. C++11 has mersenne wister engine but I cant seem to use it for some reason in UE4.

There is c++ version of randomstream. But sadly it still calls the FMath functions instead of some other algorithm. I think i will use it though cause its thread-safe. Bu cant we use C++11 random functions yet?

Hi Envenger,

Just generate a lookup table of random numbers. Sounds caveman ish I know, but it can actually be very efficient (depending on how you do it) and of course, very portable.

Basically just write a thousand random numbers to a text file. You can further augment the variation you get from it by using varying offsets and intervals when you get values from it.

Will be more efficient than using a random algorithm?