Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rangercyh/chance
A library for Mersenne Twister random number generator in lua
https://github.com/rangercyh/chance
Last synced: 12 days ago
JSON representation
A library for Mersenne Twister random number generator in lua
- Host: GitHub
- URL: https://github.com/rangercyh/chance
- Owner: rangercyh
- Created: 2016-04-08T10:56:07.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-06-24T17:19:45.000Z (over 8 years ago)
- Last Synced: 2024-08-01T22:54:13.577Z (3 months ago)
- Language: Lua
- Size: 1.95 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Description
=====
A library for Mersenne Twister random number generator in lua
Using
=====
``` lua
local chance = require "chance"--[[
chance.random()
return a random number on [0,1)-real-interval
]]
for i = 1, 20 do
print(chance.random())
end--[[
chance.seed(seed)
set the random seed
]]
chance.seed(123)
for i = 1, 10 do
print(chance.random())
end
chance.seed(123)
for i = 1, 10 do
print(chance.random())
end--[[
chance.integer(a, b)
return a random integer on [a, b]
]]
for i = 1, 10 do
print(chance.integer(1, 2))
print(chance.integer(1, 1000))
print(chance.integer(1, math.maxinteger))
print(chance.integer(-11000, 2))
print(chance.integer(math.mininteger, 1))
end
-- chance.integer(2, 1)
```Todo
=====
maybe add some function like [chance.js](http://chancejs.com/)
Licence
=====[WTFPL](http://en.wikipedia.org/wiki/WTFPL)