C
C
Chetupek2018-11-14 13:31:18
PHP
Chetupek, 2018-11-14 13:31:18

How to make random number generator based on seed?

Hello, can you tell me how to make an RNG based on seed?
Something like a hash function that returns a number from min to max
Type rand(min, max, seed);
With the same seed, you must always get the same number from min to max, when the seed changes to any value, the returned number changes like an avalanche
Thank you!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
Lander, 2018-11-14
@usdglander

seed is just a seed value.
All random number generators use a seed (except physical ones, of course).
Take any and implement. Fortunately, in the internet descriptions of this all - the sea!
upd : Here you already have to choose the right one for you. They differ a lot! :)

A
Andrew, 2018-11-14
@mhthnz

function myRand($min, $max, $seed)
{
    srand($seed);
    return rand($min, $max);
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question