Article View: comp.os.msdos.programmer
Article #36Looking for FAST random-number generator
From: Ummm... me!
Date: Fri, 30 Oct 1992 01:07
Date: Fri, 30 Oct 1992 01:07
26 lines
1554 bytes
1554 bytes
Hello fellow Netters,
(I'm sure that the following question has been asked before, and I'm almost
positive that it's a FAQ, so please pardon my ignorance...)
I'm tinkering around with the writing of an arcade-type game, and in my
main sprite-drawing loop I'm using the Turbo C rand() function in order to
generate a random number. This function seems to be a major CPU-hog because
it is being called so many times, and it has the effect of drastically
slowing down the number of animation frames per second.
Does anyone have a function (in either C or ASM) which will generate
random numbers *quickly*? Or is there a possible solution which would avoid
having to use a random-number generator at all? (I thought about generating
them all beforehand and saving them in an array, but the array would be much
too big.)
This function only needs to generate a random number from 0 to n, but the
upper bound (n) is different for each iteration of the loop.
Any help would be greatly appreciated. Please e-mail me at either of the
two addresses below (preferably the first one)...
- Mark Rosteck -
(ematias@csri.toronto.edu)
(g1marker@cdf.toronto.edu)
Technical Details
Message-ID:
<1992Oct29.200743.29715@jarvis.csri.toronto.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!utcsri!csri.toronto.edu!ematiasShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!utcsri!csri.toronto.edu!ematias Newsgroups: comp.os.msdos.programmer,rec.games.programmer From: ematias@csri.toronto.edu (Ummm... me!) Subject: Looking for FAST random-number generator Message-ID: <1992Oct29.200743.29715@jarvis.csri.toronto.edu> Organization: CSRI, University of Toronto Date: 30 Oct 92 01:07:43 GMT Lines: 27