Implement Mersenne Twister Algorithm in Winxed for Rosella
completed by: Nagato Yuki
mentors: Andrew Whitworth
Rosella would like to have the ability to generate pseudo-random numbers without relying on C-level extensions or other external code. There are several important algorithms for generating pseudorandom numbers for various purposes, but one of the more versatile and famous is the Mersenne Twister. Rosella would like to have an implementation of this algorithm, but would like to provide a pluggable random number solution for applications that would prefer a different algorithm.
Provide an implementation of the Mersenne Twister algorithm, written in Winxed, for Rosella. Create a new file src/unstable/random/RandomNumber.winxed as a parent class to expose the general interface, and src/unstable/random/MersenneTwister.winxed as the subclass. Create the directory if necessary.
The random number generator system in general, and the Mersenne Twister implemenation specifically, should provide the following methods:
- void initialize(int seed)
- int get()
- float get_float()
- int get_range(int low, int high)
Please attempt to factor out as much reusable code as possible into the parent RandomNumber class.
Please add the new library to the Rosella build in setup.winxed. Follow existing examples for other unstable libraries for how to do this. Please create a small test/example program that shows random number generation. Add a file examples/mersenne.winxed for the example (create the directory if needed).
Steps To Complete This Task
- Create a fork of Rosella.git on github.com
- Implement the Mersenne Twister algorithm, and all all necessary files and classes.
- Add the new library files to the build in setup.winxed.
- Build Rosella to prove that the code compiles
- Add an example file to use your new library in examples/mersenne.winxed
- Create a Github pull request (button on the upper right of your fork) to have your changes incorporated into the master repository
- The ability to generate high-quality pseudo-random numbers without relying on external code or C libraries will help to make Rosella more portable and more dependable between platforms.
- Understanding of algorithms, especially pseudo-random number generation.