From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,4231869cc877ceb9 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-09-27 01:00:42 PST Path: news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-post-01!supernews.com!corp.supernews.com!not-for-mail From: Andrew Newsgroups: comp.lang.ada Subject: Re: random number generation Date: Fri, 26 Sep 2003 23:48:56 -0500 Organization: Posted via Supernews, http://www.supernews.com Message-ID: User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 X-Accept-Language: en-us, en MIME-Version: 1.0 References: <3F74EA69.2090105@comcast.net> In-Reply-To: <3F74EA69.2090105@comcast.net> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@supernews.com Xref: news1.google.com comp.lang.ada:43208 Date: 2003-09-26T23:48:56-05:00 List-Id: Robert I. Eachus wrote: > Andrew wrote: > >> any help is appreciated. > > > Another thing. If you don't call Reset for the random number generator, > you will get the same sequence of random numbers every time you run the > program. This is intentional. (It makes debugging easier.) > > So once you have gotten far enough along, right after the begin put in > > Reset(A_Generator); -- or whatever you called your generator. > > That will set the generator based on the computer's real-time clock, and > shouldn't repeat a seed during the next 50 years. (Unless you run your > program on two different computers. There are other ways of > initializing the generator to be used when you have multiple generators, > each running on its own CPU.) > thank you again for everyones help. this is one of the reasons why I am a firm believer in newsgroups...a person has a question, and they can find an answer. here is the working code.. just in case anyone is/was curious: =============================== -- This program is to open file 'Map2', then print a -- bunch of characters 'x' in the form of a square. -- It will also randomly grab a number from 1 - 4. with TEXT_IO, ADA.NUMERICS.DISCRETE_RANDOM; use TEXT_IO; procedure Mazecreate is spot: CHARACTER:='x'; spott: CHARACTER:='T'; sitt: Boolean:=True; orig: INTEGER:=5; -- point of origin for map down: Integer:=10; -- down map acros: INTEGER:=11; -- across map row: INTEGER:=1; col: INTEGER:=1; X: INTEGER; map_file:FILE_TYPE; package Number_IO is new INTEGER_IO(INTEGER); use Number_IO; package FLOAT1_IO is new FLOAT_IO(FLOAT); use FLOAT1_IO; subtype Options is INTEGER range 1 .. 4; package Generate_Options is new Ada.Numerics.Discrete_Random(Options); use Generate_Options; A_Generator : Generate_Options.Generator; Begin Reset (A_Generator); X:=Generate_Options.Random(A_Generator); Put_Line("Selected option is" & Options'image(X)); Create (map_file, out_FILE, "Map2"); -- ********************* -- ** section to ** -- ** create the ** -- ** square of Stars ** -- ********************* if IS_OPEN(map_file) then for i in 1..down loop for j in 1..acros loop put (map_file, spot); end loop; NEW_LINE(map_file); end loop; Put(map_file, spott); CLOSE (map_file); else Put_Line("Map file didn't open .. Killing Program"); Return; end if; end Mazecreate; ==========================