home *** CD-ROM | disk | FTP | other *** search
- /*
- * $Id: Rand.d,v 1.1.1.1 2003/11/28 17:26:30 kenta Exp $
- *
- * Copyright 2003 Kenta Cho. All rights reserved.
- */
- module abagames.util.Rand;
-
- import std.date;
- import mt;
-
- /**
- * Random number generator.
- */
- public class Rand {
-
- public this() {
- d_time timer = getUTCtime();
- init_genrand(timer);
- }
-
- public void setSeed(long n) {
- init_genrand(n);
- }
-
- public int nextInt(int n) {
- return genrand_int32() % n;
- }
-
- public int nextSignedInt(int n) {
- return genrand_int32() % (n * 2) - n;
- }
-
- public float nextFloat(float n) {
- return genrand_real1() * n;
- }
-
- public float nextSignedFloat(float n) {
- return genrand_real1() * (n * 2) - n;
- }
- }
-