MUD-Dev
mailing list archive
[ Other Periods
| Other mailing lists
| Search
]
Date:
[ Previous
| Next
]
Thread:
[ Previous
| Next
]
Index:
[ Author
| Date
| Thread
]
Re: [MUD-Dev] Algorithms for an Infinite Universe
Quzah wrote:
> Is it just me, or is this guy totally, 100% wrong? I've
> tried both by following his explanation, and by just taking
> his code, to get his pesudo-random number generator to
> work, and it doesn't. He's wrong.
Ack... I only skimmed the article. Hoped it would stimulate some discussion
on the topic, not this kind of discussion though. :(
> A quick copy-paste into a text file and his pseudo-random
> generator returns all zeros for the random numbers. Sad.
Yes. Very sad, but replace Max with a prime (2039 for example) and it may
work. Random generators are not my speciality, but here are some examples
that ought to work without too much pain (haven't tried it in five years,
but...):
#define RND_A 16807
#define RND_M 2147483647
#define RND_Q 127773
#define RND_R 2836
/* RND_Q = M DIV A RND_R = M MOD A */
long rnd_seed;
long random(){
long tmp_seed;
tmp_seed = RND_A * (rnd_seed % RND_Q) - RND_R*(rnd_seed/RND_Q);
rnd_seed = (tmp_seed >= 0 ? tmp_seed : tmp_seed + RND_M);
return rnd_seed;
}
/** a simple random for 16 bit mod ***/
unsigned short frnd_seed;
unsigned short frnd_a;
#define FRND_A 17
#define FRND_M 65521
unsigned short fastrandom(){
return frnd_seed = (unsigned short)(((unsigned long)FRND_A *frnd_seed)
% (unsigned short)FRND_M);
}
--
Ola
_______________________________________________
MUD-Dev maillist - MUD-Dev#kanga,nu
http://www.kanga.nu/lists/listinfo/mud-dev
- Thread context:
- Re: [MUD-Dev] weather, (continued)
- Re: [MUD-Dev] Algorithms for an Infinite Universe,
Quzah quzah#hotmail,com, Mon 11 Oct 1999, 17:36 GMT
- Re: [MUD-Dev] Algorithms for an Infinite Universe,
Jp Calderone exarkun#flashmail,com, Mon 11 Oct 1999, 21:29 GMT
- Re: [MUD-Dev] Algorithms for an Infinite Universe,
Ola Fosheim Grøstad olag#ifi,uio.no, Fri 15 Oct 1999, 19:20 GMT
- Re: [MUD-Dev] Algorithms for an Infinite Universe,
Ola Fosheim Grøstad olag#ifi,uio.no, Fri 15 Oct 1999, 19:20 GMT
- [MUD-Dev] Skill Power vs Skill Rarity,
Philip Loguinov -- Draymoor fibhufky#erols,com, Mon 11 Oct 1999, 17:36 GMT
- [MUD-Dev] Alternate Character Sets (Telnet Question),
Chimera chimera#SoftHome,net, Mon 11 Oct 1999, 17:36 GMT
[ Other Periods
| Other mailing lists
| Search
]