pseudorandom.lua 669 B

123456789101112131415161718192021222324252627
  1. ---@meta
  2. ---PseudoRandom
  3. ---------------
  4. --[[
  5. A 16-bit pseudorandom number generator. Uses a well-known LCG algorithm
  6. introduced by K&R.
  7. It can be created via `PseudoRandom(seed)`.
  8. ]]
  9. ---@class mt.PseudoRandom
  10. local PseudoRandomClass
  11. --- Create a pseudorandom number generator.
  12. ---@param seed number
  13. ---@return mt.PseudoRandom
  14. function PseudoRandom(seed) end
  15. -- Return next integer random number.
  16. --
  17. -- `((max - min) == 32767) or ((max-min) <= 6553))`
  18. -- must be true due to the simple implementation
  19. -- making bad distribution otherwise.
  20. ---@param min number|nil Default: `0`
  21. ---@param max number|nil Default: `32767`
  22. function PseudoRandomClass:next(min, max) end