www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/11/21/08:44:38

Message-ID: <32945672.DB3@pobox.oleane.com>
Date: Thu, 21 Nov 1996 14:17:38 +0100
From: Francois Charton <deef AT pobox DOT oleane DOT com>
Organization: CCMSA
MIME-Version: 1.0
To: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
CC: djgpp AT delorie DOT com
Subject: Re: Proper use of rand()
References: <Pine DOT SUN DOT 3 DOT 91 DOT 961121131221 DOT 23836C-100000 AT is>

Eli Zaretskii wrote:
>  
> This is a feature.  All random functions return serias which can be
> repeated exactly on the next run.  Otherwise, people who run simulations
> could not debug their programs and compare the results from different
> runs.

Other uses of this: 
in games : 
suppose you generate a maze, use of rand() with the same seed enable you 
to generate twice the same maze, while keeping it random-like (in 
"dungeon" games, this is useful : you can save one maze as just a number, 
and hence save a lot of storage...)

in some picture generation programs, like raytracers : 
some functions such as those which generate clouds, bumps... use a random 
number generator. Using random series with the same seed enable to get 
the same image when you calculate it twice...


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019