[Plugin] [REL] MerRandom v2.0 - Mersenne Twister Randoms
#1

MerRandom version 2.1 - Mersenne Twister Randoms for Pawn/SA:MP

Created by Cyber_Punk - Copyright 2009-2010

Special Thanks to Tannz0rz

Release notes: Thanks Yom for pointing out how shitty the first version really was.

v.2.1
Thanks to Kye's MapAndreas I was able to pass a true float value back to Pawn, MRandFloatRange now needs a variable passed to store the returned value. See this post for an example: http://forum.sa-mp.com/showthread.ph...843#post852843


v.2.0

This uses:
Mersenne Twister pseudo random number generator in assembly language By Agner Fog. © 2008 - 2010.
Apart of his randoma library.
http://www.agner.org/random/
GNU General Public License.
Version 2.01. 2010-08-03.

v.1.5 (not released was made hours before 2.0)

fixed extremely slow speeds by only init'd the MTrand class once on plugin load. (noob mistake lol)
Note: Even with this fix dispite being much much faster it still was slower then pawn by at least 3x.

Based on code by Makoto Matsumoto, Takuji Nishimura, and Shawn Cokus
Mersenne Twister Random Number Generator
The Mersenne Twister is an algorithm for generating random numbers. It was designed with consideration of the flaws in various other generators. It has an incredibly long period, 219937-1 (more than 106001), before its sequence of numbers will repeat. And it has 623 dimensions of equidistribution, meaning that all sequences up to 623 numbers long are equally probable. The generator is also fast; it avoids multiplication and division, and it benefits from caches and pipelines. See the inventors' page or Wikipedia article for more details.

__________________________________________________ ______________________________

native MRandom(max); // Get an integer in the range 0 to n (for n < 2^32-1)
native MRandRange(min, max); // Get an integer in a specified range
native MRandFloatRange(Float:min, Float:max, &Float:result); // Get a float in a specified range *return it to a Float variable... This function has been updated in v2.1
__________________________________________________ ________________________________

To Install:

Goto Samp Server folder and copy the respective files into the proper folder locations.

FOR WINDOWS:
In server config add merrandom to the line plugins (if you do not have this line you need to create it )

FOR LINUX:
In server config add merrandom.so(compiled on debian) to the line plugins (if you do not have this line you need to create it )

For a speed test vs. pawn load up rand_test in the gamemode folder, code from yom's post :P


DOWNLOAD:
http://www.sendspace.com/file/z90mqn


Special Note: If you are going to compile this yourself on Linux you have nothing to worry about your ready to go, BUT if you have windows, depending on your compiler you may have to switch library files in the makefile.

Compiler

MS C++ unmanaged, Intel, Gnu - randomacof32.lib (Default file no need to change....)

Borland C++, Digital Mars, Watcom - randomaomf32.lib
(remove randomacof32.lib from makefile.win32 and replace with randomaomf32.lib)



Happy randoming...
(New speed test results on last page)
Reply


Messages In This Thread
[REL] MerRandom v2.1 - Mersenne Twister Randoms - by cyber_punk - 18.11.2009, 15:48
Re: [REL] MerRandom - Mersenne Twister Randoms - by Google63 - 18.11.2009, 16:42
Re: [REL] MerRandom - Mersenne Twister Randoms - by cyber_punk - 18.11.2009, 16:48
Re: [REL] MerRandom - Mersenne Twister Randoms - by Tannz0rz - 18.11.2009, 18:45
Re: [REL] MerRandom - Mersenne Twister Randoms - by Correlli - 18.11.2009, 18:47
Re: [REL] MerRandom - Mersenne Twister Randoms - by potato - 18.11.2009, 21:39
Re: [REL] MerRandom - Mersenne Twister Randoms - by cyber_punk - 18.11.2009, 22:40
Re: [REL] MerRandom - Mersenne Twister Randoms - by potato - 19.11.2009, 12:17
Re: [REL] MerRandom - Mersenne Twister Randoms - by yom - 19.11.2009, 12:58
Re: [REL] MerRandom - Mersenne Twister Randoms - by Tannz0rz - 19.11.2009, 19:08
Re: [REL] MerRandom - Mersenne Twister Randoms - by MenaceX^ - 19.11.2009, 19:54
Re: [REL] MerRandom - Mersenne Twister Randoms - by Tannz0rz - 19.11.2009, 20:21
Re: [REL] MerRandom - Mersenne Twister Randoms - by yom - 19.11.2009, 20:53
Re: [REL] MerRandom - Mersenne Twister Randoms - by MenaceX^ - 20.11.2009, 12:37
Re: [REL] MerRandom - Mersenne Twister Randoms - by yom - 20.11.2009, 12:39
Re: [REL] MerRandom - Mersenne Twister Randoms - by Woet - 20.11.2009, 12:46
Re: [REL] MerRandom - Mersenne Twister Randoms - by MenaceX^ - 20.11.2009, 12:55
Re: [REL] MerRandom - Mersenne Twister Randoms - by DiDok - 20.11.2009, 13:52
Re: [REL] MerRandom - Mersenne Twister Randoms - by cyber_punk - 20.11.2009, 18:12
Re: [REL] MerRandom - Mersenne Twister Randoms - by potato - 20.11.2009, 20:16
Re: [REL] MerRandom - Mersenne Twister Randoms - by cyber_punk - 21.11.2009, 02:45
Re: [REL] MerRandom - Mersenne Twister Randoms - by potato - 21.11.2009, 12:31
Re: [REL] MerRandom - Mersenne Twister Randoms - by cyber_punk - 21.11.2009, 12:55
Re: [REL] MerRandom - Mersenne Twister Randoms - by DiDok - 21.11.2009, 14:40
Re: [REL] MerRandom - Mersenne Twister Randoms - by DiDok - 26.11.2009, 14:19
Re: [REL] MerRandom - Mersenne Twister Randoms - by Destrojer - 26.11.2009, 15:31
Re: [REL] MerRandom - Mersenne Twister Randoms - by Google63 - 01.12.2009, 16:50
Re: [REL] MerRandom - Mersenne Twister Randoms - by MJ! - 11.12.2009, 17:55
Re: [REL] MerRandom - Mersenne Twister Randoms - by Correlli - 11.12.2009, 18:03
Re: [REL] MerRandom - Mersenne Twister Randoms - by Tannz0rz - 11.12.2009, 18:04
Re: [REL] MerRandom - Mersenne Twister Randoms - by MJ! - 11.12.2009, 18:38
Re: [REL] MerRandom - Mersenne Twister Randoms - by cyber_punk - 30.08.2010, 12:10
Re: [REL] MerRandom - Mersenne Twister Randoms - by wups - 05.09.2010, 12:09
Re: [REL] MerRandom - Mersenne Twister Randoms - by cyber_punk - 05.09.2010, 14:35
Re: [REL] MerRandom v2.0 - Mersenne Twister Randoms - by nemesis- - 07.09.2010, 03:18
Re: [REL] MerRandom v2.0 - Mersenne Twister Randoms - by cyber_punk - 07.09.2010, 13:49
Re: [REL] MerRandom v2.0 - Mersenne Twister Randoms - by nemesis- - 07.09.2010, 14:28
Respuesta: [REL] MerRandom v2.0 - Mersenne Twister Randoms - by xenowort - 07.09.2010, 17:43
Re: [REL] MerRandom v2.0 - Mersenne Twister Randoms - by cyber_punk - 26.09.2010, 23:01
Re: [REL] MerRandom v2.0 - Mersenne Twister Randoms - by cyber_punk - 27.10.2010, 20:52
Re: [REL] MerRandom v2.0 - Mersenne Twister Randoms - by MisterTickle - 22.09.2011, 08:53
Re: [REL] MerRandom v2.0 - Mersenne Twister Randoms - by [L3th4l] - 22.09.2011, 09:22
Re: [REL] MerRandom v2.0 - Mersenne Twister Randoms - by aRoach - 22.09.2011, 12:36
Re: [REL] MerRandom v2.0 - Mersenne Twister Randoms - by cyber_punk - 22.09.2011, 17:01
Re: [REL] MerRandom v2.0 - Mersenne Twister Randoms - by Edvin - 22.09.2011, 18:43
Re: [REL] MerRandom v2.0 - Mersenne Twister Randoms - by Kyle - 27.06.2012, 10:59
Respuesta: [REL] MerRandom v2.0 - Mersenne Twister Randoms - by Siralos - 15.08.2012, 15:23

Forum Jump:


Users browsing this thread: 2 Guest(s)