| MadSci Network: Computer Science |
Hi April! I can't say that I know the game, but from its description, it
reminds me of two (very) old games... "Crush, Crumble, and Chomp" on the
Atari & Apple II, and a later revamp of it called "The Movie Monster Game"
on the Commodore 64. (Does anyone know if "Monster Rancher" is a remake?)
Anyway, in those games, the player would define (I.E. Create) a monster by
supplying various characteristics to the game. The object was, of course,
to create a monster that would win in as many "combat" situations as
possible (like all such games). [Computer Science Tidbit: such values are
stored as integers, rather than words because it is computationally cheaper
to deal with them. Thus, if I wanted Color to be yellow, internally color
might be represented by 2 (e.g. Red=1, Orange=2, Yellow=3, ...) ]
Now, since what I really want to do is slash and maim, I really do not want
to take all the time to define my "monster". I would be just as happy if
a Random Number Generator would supply values for me. A Random Number
Generator is a small bit of code which supplies a sequence of numbers in
some APPARENTLY random order (The GNU Scientific Library has a nice
writeup on them...see http://sourceware.cygnus.com/gsl/html/gsl-ref_4.html)
The BSD rand() generator is an example of a very common class of RNG's:
x{n+1} = (a * x(n) + c) mod m
where a and m must be relatively prime. BSD uses a = 1103515245, c = 12345
and m = 2^{31}. The seed specifies the initial value, x(1). The period of
this generator is 2^{31}.
The range of values returned by this function are integers in [0..m-1]
(read as "from 0 to m-1, including both 0 and m-1"). But, since we want
an integer from 1-10 (for example), we can do the following "trick".
Let us create a new function frand() which returns a floating-point value
in the range of [0..1) "from 0 to 1, including 0, but excluding 1". This
can be done by (((float)rand()) / m). Now, if we want a random integer from
1 to Q, we can use (int)(frand() * Q) + 1.
Note that this RNG is actually "Pseudo-Random", that it, with the same
seed, the same random sequence gets generated. This is actually very
important, because scientists need a way to reproduce results. (RNG are
useful for more than just games; Monte Carlo methods are a life saver for
simulation programs). For a game, we might seed the RNG with the current
Time-Of-Day to get a more "random" sequence.
OK, enough of the computer science. Back to the game. The engineers at
SONY (or whoever authored this game) wanted a real RNG. But, from within a
programming perspective, this is very difficult (pseudo is easy, but, here
we DO NOT want to duplicate results). So they came up with a clever
solution. Since a CD just contains a lot of digital data, they will read a
few bytes off of it (and, since they are out of context [their correct
context is music], they are truely random!) and map them (as above) into
the correct range. Since each CD has a different sequence of "values",
each one will give you a different monster.
I hope this answers your question!!! Enjoy!
Try the links in the MadSci Library for more information on Computer Science.