SHARE
TWEET

Calculating period of love.math.noise in 1 dimension

TangentFox Sep 22nd, 2018 (edited) 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- finds the number of pseudo-random vectors the LÖVE engine uses for its noise function
  2. -- (256 is the answer by the way, as expected)
  3. local results = { }
  4. local sequence_found = false
  5. local check
  6. check = function(results)
  7.   local j = math.floor(#results / 2)
  8.   for i = 1, j do
  9.     j = j + 1
  10.     print(results[i], results[j], results[i] == results[j])
  11.     if results[i] ~= results[j] then
  12.       return false
  13.     end
  14.   end
  15.   return true
  16. end
  17. local i = 0.5
  18. table.insert(results, love.math.noise(i))
  19. i = i + 1
  20. while not sequence_found do
  21.   table.insert(results, love.math.noise(i))
  22.   sequence_found = check(results)
  23.   i = i + 1
  24. end
  25. return print(#results/2)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top