home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1995 August / NEBULA.mdf / Apps / Games / UnixGames / gnugo / Source / seed.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-25  |  2.2 KB  |  96 lines

  1. /*
  2.                 GNU GO - the game of Go (Wei-Chi)
  3.                 Version 1.1   last revised 4-10-92
  4.            Copyright (C) Free Software Foundation, Inc.
  5.                       written by Man L. Li
  6.                       modified by Wayne Iba
  7.                     documented by Bob Webber
  8.           NeXT port by Howard Pan
  9. */
  10. /*
  11. This program is free software; you can redistribute it and/or modify
  12. it under the terms of the GNU General Public License as published by
  13. the Free Software Foundation - version 1.
  14.  
  15. This program is distributed in the hope that it will be useful,
  16. but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18. GNU General Public License in file COPYING for more details.
  19.  
  20. You should have received a copy of the GNU General Public License
  21. along with this program; if not, write to the Free Software
  22. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  23.  
  24. Please report any bug/fix, modification, suggestion to
  25.  
  26. mail address:   Man L. Li
  27.                 Dept. of Computer Science
  28.                 University of Houston
  29.                 4800 Calhoun Road
  30.                 Houston, TX 77004
  31.  
  32. e-mail address: manli@cs.uh.edu         (Internet)
  33.                 coscgbn@uhvax1.bitnet   (BITNET)
  34.                 70070,404               (CompuServe)
  35. */
  36.  
  37. /*
  38. #define  IBM  8086
  39. */
  40.  
  41. /*
  42. #define  SUN  68000
  43. */
  44.  
  45. #define _NeXT_
  46.  
  47. #include <stdio.h>
  48.  
  49. #ifdef SUN
  50. #include <sys/time.h>
  51. #endif
  52.  
  53. #ifdef  _NeXT_
  54. #include <time.h>
  55. #endif
  56.  
  57. #ifdef IBM
  58. seed(i)
  59. /* start seed of random number generator for PC */
  60. /* Computer Innovation C86 compiler version */
  61. int *i;
  62.   {
  63.    struct regval {int ax, bx, cx, dx, si, di, ds, es;};
  64.    struct regval sreg, rreg;
  65.  
  66.    sreg.ax = 0x2c00;
  67.    sysint21(&sreg, &rreg);
  68.    *i = rreg.dx;
  69. }  /* end seed */
  70. #endif
  71.  
  72.  
  73. #ifdef SUN
  74. seed(i)
  75. /* start seed of random number generator for Sun */
  76. int *i;
  77.   {
  78.    struct timeval tp;
  79.    struct timezone tzp;
  80.  
  81.    gettimeofday(&tp, &tzp);
  82.    *i = tp.tv_usec;
  83. }  /* end seed */
  84. #endif
  85.  
  86.  
  87. #ifdef  _NeXT_
  88. int seed (int *i)            /* Note that i is the variable where the seed is passed through */
  89. /* This procedure uses ANSI C to generate a random seed for the NeXT */
  90. {
  91.     time_t     *tp;
  92.     
  93.     tp = NULL;
  94.     *i = (int) time (tp);
  95. } /* seed */
  96. #endif