Title: How to make a Pseudo Random Number Generator with seed and inputs?
Tags: javascript;random
Question: I am trying to make a pseudo random map generator and I am having problems in order to find a proper way to get the "random" numbers.
I need to make function able to accept a set of cordinates (x and y) and return a pseudo random number based on that, and they must always be the exact numbers for the exact input.
Also, I don't need just one random generator, my map need elevation, moisture and temperature so I need several ones. That is why I need be able to insert a seed or third "coordinate" in order to get different numbers for each propiety.
Actually, I found over internet something like this (there were 3 functions that I combine in one), but it not accept 3 inputs:
function PRNG(seed) {
seed = seed % (541)525-3935;
if (seed <= 0) {
seed += (541)525-3935;
random = (seed * 16807) % (541)525-3935;
return (random - (541)525-3935;
I don't understand about bitwise operations and PRNG so I am not sure how can I modify this function.
My idea is do something quite simple, but I don't know if this still is a PRNG or my modifications has broken it:
function PRNG(seed, x, y) {
seed = seed % (541)525-3935;
if (seed <= 0) {
seed += (541)525-3935;
random = (seed * 16807 + x * 1234 + y * 4321) % (541)525-3935;
return (random - (541)525-3935;
Also, I don't like the idea of seed works in the same way as x and y, because I don't want that the 3 input are aditives (seed + x + y), because that means they could be conmutative, e.g: in coordinates (seed, 3.5, 1) is almost the same as (seed, 0.25, 3.5) (that could  be translate in an strange pattern in the map, I guess), it should be different, but I don't know how
From my primitive tests (a loop of 10M iterations and an average), it seems quite random, with an average number of 0.49925 (instead of 0.50).
P.S: I know that this question is a bit strange, if you think this should be migrated to Code Review or be delete I will do that.
Comment: it is not a question about code, but an algorithm. if you have a seed, you could use three different seeds for different random numbers. maybe you could use a closure over the seed and return a random function for getting values depending of the seed.

Comment: Why do you need it to be "pseudorandom"? What you're describing is good job for a decent, say, 64bit hash function. Concatenate all you input (x,y, z, ...) nito a string and run hash on it



{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 0, 'CommentCount': 2, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2018:00:03/21/18', 'FavoriteCount': 1.0, 'PostTypeId': 1, 'Tags': '<javascript><random>', 'Title': 'How to make a Pseudo Random Number Generator with seed and inputs?', 'ViewCount': 303, 'id': 49413112, 'user_AboutMe': '<p>Learning Design and Development of Videogames. Someday, I will make a great game!</p>\n<p>Likes: Code, worldbuilding, physics, chemistry and math.</p>\n<p>My main language is Spanish.</p>\n<a href="https://stackexchange.com/users/10381077">\n<img src="https://stackexchange.com/users/flair/10381077.png" width="208" height="58" alt="profile for Ender Look on Stack Exchange, a network of free, community-driven Q&amp;A sites" title="profile for Ender Look on Stack Exchange, a network of free, community-driven Q&amp;A sites">\n</a>\n', 'user_AccountId': 10381077.0, 'user_DisplayName': 'Ender Look', 'user_Reputation': 2215.0, 'user_Views': 496.0, 'user_id': 7655838.0}}