rand() and srand() method with TinyMT
C Ruby
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
example
src
.travis.yml
.travis_build_config.rb
README.md
mrbgem.rake

README.md

rand and srand method with TinyMT

rand and srand method with Tiny Mersenne Twister

install by mrbgems

  • add conf.gem line to build_config.rb
MRuby::Build.new do |conf|

    # ... (snip) ...

    conf.gem :git => 'https://github.com/matsumoto-r/mruby-tinymt.git'
end

example

# generate parameter from tinymt32dc
tmt = TinyMT.new(0xf50a1d49, 0xffa8ffeb, 0x0bf2bfff)

tmt.srand(5)
p tmt.rand()
tmt.srand(5)
p tmt.rand()
tmt.srand(10)
p tmt.rand()

5.times do |i|
  p "---" + i.to_s + "---"
  tmt.srand
  p tmt.rand
  p tmt.rand(0)
  p tmt.rand(25)
  p tmt.rand(50)
  p tmt.rand(75)
  p tmt.rand(100)
end

License

under the MIT License:

tinymt32.{c.h} under the BSD New License: