Java : Random setSeed -


i'm having small conceptual problem.

i need seed random same radom when reload levels.

so therefore need use random#setseed.

the problem have then need

random r = new random(); r.setseed(currentseed); 

the problem have have pass/fetch instance of r across code.

i know if there solution close c:

math.random(currentseed); 

the closest have is:

classa:   public static random r;   private int currentseed = ...;   initrandom(){     r = new radom(currentseed);   }  classb:   ...   //instead of math.random();   r.random();   ... 

but doesn't seem nice.

any ideas?

yes, need pass same random instance around, either parameter, or mean of global (static variable or singleton).


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -