mercredi 31 août 2016

How to derive a pseudo random number, given a parent/seed number - which fits all criteria the parent number has

I need some help with maths. I am generating a derived seed value from a parent seed value.

I need to derive a number y given a number x which follows the following rules.

  1. x = math.random(1000, 9999)
  2. for a given x, y is constant. ie. y = f(x)
  3. y doesnt necessarily follows x. ie y doesnt needs to grow when x grows and y doesnt needs to reduce when x reduces. eg. if x = 1234 and in the next iteration x = 3456 then y also doesnt needs to grow. in fact y would better be a pseudo random number.
  4. y also is in the range (1000, 9999)

Early on i went for the following function:

y = tonumber(string.reverse(x))

ie. if x = 1234 then y = 4321

However there is a direct correlation between the two numbers and my terrain is looking way too symmetric as a result.




Aucun commentaire:

Enregistrer un commentaire