Page 1 of 1

Math() - OpenSource please!!!

Posted: Mon Aug 04, 2003 7:51 pm
by Ralf
Hello Fred!
I would like to write a small tool in purebasic using the mathlib commands random(), randomseed() and save all the datas like following into an ini file:

Code: Select all

; File
rand = 12     ; Random value
seed = 612   ; RandomSeed value
...
Later i would like to read the inifiles with the values for random and randomseed (c based) and import into my C++/C# projects! Could you share us a working asm/c/c++/c# version of your purebasic random and randomseed (100% compatible) commands? So everybody could use this commands in purebasic and c/c++/c# and having everytime the same results! This is my problem! I dont know on which way you managed it! Many thanks in advance!

Posted: Mon Aug 04, 2003 8:33 pm
by aszid
i'm pretty sure the answer you will get will be "no"

quite simply, the user agreement for PB says you cannot use pb to simply wrap commands for use with other languages. and that sounds pretty much exactly what you're asking for in this case...

i could be wrong though i suppose...

good luck

Posted: Mon Aug 04, 2003 9:24 pm
by Ralf
aszid wrote:i'm pretty sure the answer you will get will be "no"

quite simply, the user agreement for PB says you cannot use pb to simply wrap commands for use with other languages. and that sounds pretty much exactly what you're asking for in this case...

i could be wrong though i suppose...

good luck
Aeehmm, i will still wait for Freds answer! I dont want wrap the full math lib or any other purebasic related stuff. Still only want to know how to write a Random and RandomSeed command that gives 100% same results in pb/asm/c/c++/c#... I think this should be no problem to share this routine to write tools in purebasic and produce the same results from the datafiles in any other language. I still think fred would be so friendly and help..!?

Posted: Tue Aug 05, 2003 11:50 am
by Fred
It was a similar thread about this random routine and the best for you if you want crossplatform random is to rewrite your own (not difficult, lot of example on the web) as the PB one can change without any notices for speed/size reason so it will break the compatibility.

Posted: Wed Aug 06, 2003 2:51 am
by Andy Amaya
There's a publicly available random number generator called the 'Mersenne Twister'. It's probably one of the best random number generators available, if not the best.

Have a look at: http://www.math.keio.ac.jp/~matumoto/emt.html

It's already been coded in many computer languages and looks to me like it's just what you need.

Hope this helps

Andy

Posted: Wed Aug 06, 2003 4:02 pm
by Ralf
Thanks to Andy Amaya. Can someone post a purebasic and a c# version of the random and randomseed algo?

Fred: your random and randomseed dont produces same results when using the commands on win/linux/amiga??? I only need it for win32 system and maybe any day for linux!? I would like to use a c# converted version of the purebasic commands due fact pure is fast and i dont know how to implent a c/c++ routine (random/randomseed) to pure nor having any knowledge about assembler :roll:

Posted: Sun Aug 10, 2003 4:41 pm
by Ralf
someone so nice here to post a random() and randomseed() function for purebasic (inline asm?) and a version for c/c++/c# (inline asm?), having same result on both languages?

10x a lot for help

Posted: Sun Aug 10, 2003 5:30 pm
by Paul
Did you visit the Resources Site?

Just go there and type "random" the the search box :)

There is a nice example written in ASM.

Posted: Sun Aug 10, 2003 5:33 pm
by Rings
www.rentacoder.com can be the solution

Posted: Sun Aug 10, 2003 5:54 pm
by Ralf
Paul wrote:Did you visit the Resources Site?

Just go there and type "random" the the search box :)

There is a nice example written in ASM.

cool! 10x paul! :wink: now i have a working asm random function in asm but can someone show me how to use this asm code as function inside c++/c#!? have never tried to mix asm and any c related stuff. Thanks for more input :wink:

Posted: Mon Aug 11, 2003 9:59 am
by TronDoc
Andy Amaya wrote:Have a look at: http://www.math.keio.ac.jp/~matumoto/emt.html
that link was broken, but there are many sites that have it. I found it here:
http://www-personal.engin.umich.edu/~wa ... ister.html
I just did a search for MersenneTwister
Joe