Algorithm for number generation that is random but consistent

I am trying to make a number generator that will create a random number but as long as the input number is the same the output will be the same. Does anybody know of an article for generating an algorithm that will do this?

** I do not want a consistent output for each input.

** I also want the algorithm to be low cost. It is going to be run many times on a weekly basis and the game is going to be mobile based.

**** One idea I have is to use the date in the input for the algorithm, that way it is consistent among the players, but it will create a different output for each input on a daily basis.

You appear to contradict yourself:

  • “As long as the input number is the same the output will be the same”
  • “I do not want a consistent output for each input”

Which behaviour do you want?

RNGs don’t have an “input”: they generate a sequence of numbers using an algorithm based on a seed value. If you supply the same seed, you’ll get the same sequence.

You haven’t said what you need the number for, but it sounds like you might be looking for a hash function instead, which generates a deterministic output from any input.

You could generate a sequence that you store on a server and then send to clients, assuming that your users are connected to a webserver. Or you could deploy the game with a list of ~1000 sequences and just use a different list item every day.