U++ framework
Do not panic. Ask here before giving up.

Home » U++ Library support » U++ Core » random functions proposal
Re: random functions proposal [message #35171 is a reply to message #35170] Wed, 18 January 2012 17:45 Go to previous messageGo to previous message
dolik.rce is currently offline  dolik.rce
Messages: 1796
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

cbpporter wrote on Wed, 18 January 2012 15:44

What Random needs is the ability to give it a seed. So you can produce the same sequence of numbers twice. Or is there already support for this?

These functions should be able to do that:
void SeedRandom(dword *seed,int len){
	if(!sRng) {
		sRng = new(sRb) MTrand;
	}
	sRng->init_by_array(seed,len);
}

void SeedRandom(dword Seed){
	if(!sRng) {
		sRng = new(sRb) MTrand;
	}
	sRng->init_genrand(Seed);
}

But I didn't have the time to test it Wink

Honza
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Init a ctrl inside INITBLOCK
Next Topic: problem with new and delete
Goto Forum:
  


Current Time: Wed Aug 05 06:38:48 GMT+2 2026

Total time taken to generate the page: 0.00638 seconds