home *** CD-ROM | disk | FTP | other *** search
/ ring.yamanashi.ac.jp/pub/pc/freem/action/ / action.zip / a7xpg0_11.zip / a7xpg / src / abagames / util / Rand.d < prev    next >
Text File  |  2003-09-20  |  596b  |  33 lines

  1. /*
  2.  * $Id: Rand.d,v 1.1.1.1 2003/09/19 14:55:49 kenta Exp $
  3.  *
  4.  * Copyright 2003 Kenta Cho. All rights reserved.
  5.  */
  6. module abagames.util.Rand;
  7.  
  8. import random;
  9. import date;
  10.  
  11. /**
  12.  * Random number generator.
  13.  */
  14. public class Rand {
  15.   
  16.   public this() {
  17.     d_time timer = getUTCtime();
  18.     rand_seed(timer, 0);   
  19.   }
  20.  
  21.   public int nextInt(int n) {
  22.     return random.rand() % n;
  23.   }
  24.  
  25.   public int nextSignedInt(int n) {
  26.     return random.rand() % (n * 2) - n;
  27.   }
  28.  
  29.   public float nextFloat(float n) {
  30.     return ((float)(random.rand() % (n * 10000))) / 10000;
  31.   }
  32. }
  33.