|
@@ -22,35 +22,35 @@
|
|
package neko;
|
|
package neko;
|
|
|
|
|
|
/**
|
|
/**
|
|
- A seeded pseudo-random generator
|
|
|
|
|
|
+ A seeded pseudo-random generator.
|
|
*/
|
|
*/
|
|
class Random {
|
|
class Random {
|
|
|
|
|
|
var r : Dynamic;
|
|
var r : Dynamic;
|
|
|
|
|
|
/**
|
|
/**
|
|
- Create a new random with random seed
|
|
|
|
|
|
+ Create a new random with random seed.
|
|
*/
|
|
*/
|
|
public function new() {
|
|
public function new() {
|
|
r = random_new();
|
|
r = random_new();
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- Set the generator seed
|
|
|
|
|
|
+ Set the generator seed.
|
|
*/
|
|
*/
|
|
public function setSeed( s : Int ) {
|
|
public function setSeed( s : Int ) {
|
|
random_set_seed(r,s);
|
|
random_set_seed(r,s);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- Return a random integer modulo max
|
|
|
|
|
|
+ Return a random integer modulo max.
|
|
*/
|
|
*/
|
|
public function int( max : Int ) : Int {
|
|
public function int( max : Int ) : Int {
|
|
return random_int(r,max);
|
|
return random_int(r,max);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- Return a random float
|
|
|
|
|
|
+ Return a random float.
|
|
*/
|
|
*/
|
|
public function float() : Float {
|
|
public function float() : Float {
|
|
return random_float(r);
|
|
return random_float(r);
|