From: SHIRAKATA Kentaro Date: Wed, 11 Aug 2004 07:18:23 +0000 (+0000) Subject: add mt.patch X-Git-Url: http://git.osdn.net/view?p=jnethack%2Fhtdocs.git;a=commitdiff_plain;h=b2efcb0cbb4a8ba4f1e43e120f027952816d5b9d add mt.patch --- diff --git a/patch/index.html b/patch/index.html index 92c6fc8..37cf39b 100755 --- a/patch/index.html +++ b/patch/index.html @@ -13,9 +13,9 @@

¥Ñ¥Ã¥Á

-°Ê²¼¤Î¥Ñ¥Ã¥Á¤ÏÀΤÎJNetHack¤Î³ÈÄ¥µ¡Ç½¤È¤·¤Æ¼è¤êÆþ¤ì¤é¤ì¤Æ¤¤¤¿¤â¤Î¤Ç¤¹¡£ -´ðËÜŪ¤ËJNetHack1.2¥Ù¡¼¥¹¤Ç¤¹¤Î¤Ç¡¢3.4.0¥Ù¡¼¥¹¤ÇÆ°ºî¤¹¤ë¤«¤Ï¤ï¤«¤ê¤Þ¤»¤ó¡£ -»²¹ÍÄøÅ٤ˤɤ¦¤¾¡£ +°Ê²¼¤Î¥Ñ¥Ã¥Á¤ÏÀΤÎJNetHack¤Î³ÈÄ¥µ¡Ç½¤È¤·¤Æ¼è¤êÆþ¤ì¤é¤ì¤Æ¤¤¤¿¤â¤Î¤Ê¤É¤Ç¤¹¡£ +ÌÀµ­¤µ¤ì¤Æ¤¤¤Ê¤¤¤â¤Î¤ÏJNetHack1.2¥Ù¡¼¥¹¤Ç¤¹¤Î¤Ç¡¢ +3.4.0¥Ù¡¼¥¹¤ÇÆ°ºî¤¹¤ë¤«¤Ï¤ï¤«¤ê¤Þ¤»¤ó¡£»²¹ÍÄøÅ٤ˤɤ¦¤¾¡£


Powered by SourceForge.jp diff --git a/patch/mt.patch b/patch/mt.patch new file mode 100644 index 0000000..feee560 --- /dev/null +++ b/patch/mt.patch @@ -0,0 +1,224 @@ +diff -urN orig/include/config.h RND_MT/include/config.h +--- orig/include/config.h Sat Jan 10 19:06:48 2004 ++++ RND_MT/include/config.h Fri Jul 23 23:47:06 2004 +@@ -354,6 +354,7 @@ + + #define EXP_ON_BOTL /* Show experience on bottom line */ + /* #define SCORE_ON_BOTL */ /* added by Gary Erickson (erickson@ucivax) */ ++#define RAND_MT /* use mersenne twister for random number */ + + /* + * Section 5: EXPERIMENTAL STUFF +diff -urN orig/include/extern.h RND_MT/include/extern.h +--- orig/include/extern.h Thu Apr 29 20:14:34 2004 ++++ RND_MT/include/extern.h Fri Jul 23 23:48:12 2004 +@@ -1710,6 +1710,9 @@ + E int FDECL(d, (int,int)); + E int FDECL(rne, (int)); + E int FDECL(rnz, (int)); ++#ifdef RAND_MT ++E void FDECL(init_genrand, (unsigned long)); ++#endif /* RAND_MT */ + + /* ### role.c ### */ + +diff -urN orig/src/hacklib.c RND_MT/src/hacklib.c +--- orig/src/hacklib.c Fri Dec 5 01:21:28 2003 ++++ RND_MT/src/hacklib.c Fri Jul 23 23:50:30 2004 +@@ -482,6 +482,16 @@ + /* the types are different enough here that sweeping the different + * routine names into one via #defines is even more confusing + */ ++#ifdef RAND_MT ++ ++ #ifdef BSD ++ init_genrand((unsigned long) time((long *)0)); ++ #else ++ init_genrand((unsigned long) time((time_t *)0)); ++ #endif ++ ++#else /* RAND_MT */ ++ + #ifdef RANDOM /* srandom() from sys/share/random.c */ + srandom((unsigned int) time((time_t *)0)); + #else +@@ -502,6 +512,7 @@ + # endif + # endif + #endif ++#endif /* RAND_MT */ + } + + static struct tm * +diff -urN orig/src/rnd.c RND_MT/src/rnd.c +--- orig/src/rnd.c Sun Apr 28 00:36:36 2002 ++++ RND_MT/src/rnd.c Wed Aug 28 22:02:04 2002 +@@ -3,6 +3,8 @@ + + #include "hack.h" + ++#ifndef RAND_MT ++ + /* "Rand()"s definition is determined by [OS]conf.h */ + #if defined(LINT) && defined(UNIX) /* rand() is long... */ + extern int NDECL(rand); +@@ -16,6 +18,15 @@ + # endif + #endif /* LINT */ + ++#else /* RAND_MT */ ++ ++STATIC_DCL void NDECL(next_state); ++STATIC_DCL unsigned long NDECL(genrand_int32); ++/*#define RND(x) (int)(genrand_int32() % (unsigned long)(x))*/ ++#define RND(x) (int)((double)(x) * (double)genrand_int32() * (1.0/4294967296.0)) ++ ++#endif /* RAND_MT */ ++ + #ifdef OVL0 + + int +@@ -142,4 +153,120 @@ + + #endif /* OVLB */ + ++#ifdef RAND_MT ++ ++/* ++ A C-program for MT19937, with initialization improved 2002/2/10. ++ Coded by Takuji Nishimura and Makoto Matsumoto. ++ This is a faster version by taking Shawn Cokus's optimization, ++ Matthe Bellew's simplification, Isaku Wada's real version. ++ ++ Before using, initialize the state by using init_genrand(seed) ++ or init_by_array(init_key, key_length). ++ ++ Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura, ++ All rights reserved. ++ ++ Redistribution and use in source and binary forms, with or without ++ modification, are permitted provided that the following conditions ++ are met: ++ ++ 1. Redistributions of source code must retain the above copyright ++ notice, this list of conditions and the following disclaimer. ++ ++ 2. Redistributions in binary form must reproduce the above copyright ++ notice, this list of conditions and the following disclaimer in the ++ documentation and/or other materials provided with the distribution. ++ ++ 3. The names of its contributors may not be used to endorse or promote ++ products derived from this software without specific prior written ++ permission. ++ ++ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ++ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ++ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ++ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR ++ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ++ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, ++ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR ++ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF ++ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING ++ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ++ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ++ ++ ++ Any feedback is very welcome. ++ http://www.math.keio.ac.jp/matumoto/emt.html ++ email: matumoto@math.keio.ac.jp ++*/ ++ ++/* Period parameters */ ++#define N_MT 624 ++#define M_MT 397 ++#define MATRIX_A 0x9908b0dfUL /* constant vector a */ ++#define UMASK 0x80000000UL /* most significant w-r bits */ ++#define LMASK 0x7fffffffUL /* least significant r bits */ ++#define MIXBITS(u,v) ( ((u) & UMASK) | ((v) & LMASK) ) ++#define TWIST(u,v) ((MIXBITS(u,v) >> 1) ^ ((v)&1UL ? MATRIX_A : 0UL)) ++ ++static unsigned long state[N_MT]; /* the array for the state vector */ ++static int left = 1; ++/*static int initf = 0;*/ ++static unsigned long *next; ++ ++/* initializes state[N] with a seed */ ++void init_genrand(unsigned long s) ++{ ++ int j; ++ state[0]= s & 0xffffffffUL; ++ for (j=1; j> 30)) + j); ++ /* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */ ++ /* In the previous versions, MSBs of the seed affect */ ++ /* only MSBs of the array state[]. */ ++ /* 2002/01/09 modified by Makoto Matsumoto */ ++ state[j] &= 0xffffffffUL; /* for >32 bit machines */ ++ } ++ left = 1; /*initf = 1;*/ ++} ++ ++static void next_state(void) ++{ ++ unsigned long *p=state; ++ int j; ++ ++ /* if init_genrand() has not been called, */ ++ /* a default initial seed is used */ ++/* if (initf==0) init_genrand(5489UL);*/ ++ ++ left = N_MT; ++ next = state; ++ ++ for (j=N_MT-M_MT+1; --j; p++) ++ *p = p[M_MT] ^ TWIST(p[0], p[1]); ++ ++ for (j=M_MT; --j; p++) ++ *p = p[M_MT-N_MT] ^ TWIST(p[0], p[1]); ++ ++ *p = p[M_MT-N_MT] ^ TWIST(p[0], state[0]); ++} ++ ++/* generates a random number on [0,0xffffffff]-interval */ ++unsigned long genrand_int32(void) ++{ ++ unsigned long y; ++ ++ if (--left == 0) next_state(); ++ y = *next++; ++ ++ /* Tempering */ ++ y ^= (y >> 11); ++ y ^= (y << 7) & 0x9d2c5680UL; ++ y ^= (y << 15) & 0xefc60000UL; ++ y ^= (y >> 18); ++ ++ return y; ++} ++ ++#endif // RAND_MT + /*rnd.c*/ +diff -urN orig/src/rumors.c RND_MT/src/rumors.c +--- orig/src/rumors.c Thu Apr 29 19:59:36 2004 ++++ RND_MT/src/rumors.c Fri Jul 23 23:52:20 2004 +@@ -114,11 +114,19 @@ + switch (adjtruth = truth + rn2(2)) { + case 2: /*(might let a bogus input arg sneak thru)*/ + case 1: beginning = true_rumor_start; ++#ifdef RAND_MT ++ tidbit = rn2(true_rumor_size); ++#else + tidbit = Rand() % true_rumor_size; ++#endif + break; + case 0: /* once here, 0 => false rather than "either"*/ + case -1: beginning = false_rumor_start; ++#ifdef RAND_MT ++ tidbit = rn2(false_rumor_size); ++#else + tidbit = Rand() % false_rumor_size; ++#endif + break; + default: + impossible("strange truth value for rumor");