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.3 required=5.0 tests=BAYES_00,FREEMAIL_FROM, INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,d689deb693648481 X-Google-Attributes: gid103376,public From: rentaz13@aol.com Subject: Desperately in need of help!!!!!! Please read Date: 1996/11/19 Message-ID: <19961119005400.TAA11804@ladder01.news.aol.com>#1/1 X-Deja-AN: 197317252 sender: news@aol.com organization: AOL http://www.aol.com newsgroups: comp.lang.ada Date: 1996-11-19T00:00:00+00:00 List-Id: Im doing a project in school, its the Master Mind game, pretty simple, but when I compile it I get a bunch of errors. Syntax mostly, but Im totally lost. I cant get to school until Wed. morning when its due so im in a little trouble. If you have the time and are willing are to help, please do so. If not then its no big deal, but anyways heres the source.: with Text_IO; procedure Master_Mind is package Integer_IO is new Text_IO.Integer_IO (Num => Integer); --Master_Mind vars. NextRnd : Integer :=0; tries: integer := 0; user_num:integer :=0; act_num: integer :=0; --Subprogs. -------------------------------------------- procedure RndSeed(X : IN Integer) is begin NextRnd := X; end RndSeed; -------------------------------------------- function Rnd(Max : in Integer) return Integer is MagicNumber : Constant Integer := 133; RandomFloat : Float; RandomInteger : Integer; DeltaRnd : Float; Index : Integer; begin NextRnd := ((NextRnd REM 128) * MagicNumber) + 37; RandomFloat := Float(NextRnd) / 16_928.0; DeltaRnd := 1.0 / (Float(Max) + 1.0); Index := 1; PickNumber: loop if RandomFloat < Float(Index) * DeltaRnd then RandomInteger := Index - 1; exit PickNumber; end if; Index := Index + 1; end loop PickNumber; if RandomInteger > Max then RandomInteger := Max; end if; return RandomInteger; end Rnd; -------------------------------------------------- --SUB = Compare vars. both converted to String Vars procedure compare (act_num: in integer; user_num: in integer) is i: integer:=0; j: integer:=0; type user_char is array(1..4) of integer; type act_char is array(1..4) of integer; corr_pos: integer; hits: integer; act_num2: string(1..4); user_num2: string(1..4); --split act_num into a char1, ...2, etc for each char. --split user_num also -- Compare 1st char of user_num w/ each char of act_num begin act_num2:= String(act_num); user_num2:= String(user_num); UserCheck: loop -- user_num check (i as index) i:=i+1; -- May need to be changed to fit 1st char index (0/1 based) user_char(i):= user_num2(i..i); ActCheck: loop -- act_num2 comparision loop j:=j+1; act_char(j):= act_num2(j..j); --Actual comparision if user_char(i) = act_char(i) then corr_pos:= corr_pos + 1; -- +1 for every match in the correct position exit ActCheck; end if; if user_char(i) = act_char(j) then hits:= hits + 1; -- +1 for every match in the actual # exit ActCheck; end if; if j = 4 then exit ActCheck; end loop ActCheck; if i = 4 then exit UserCheck; end loop UserCheck; --user_num. Top loop --PickNumber: -- loop -- if RandomFloat < Float(Index) * DeltaRnd then -- RandomInteger := Index - 1; -- exit PickNumber; -- end if; -- Index := Index + 1; -- end loop PickNumber; --Screen output any similarities Integer_IO.put (hits); Text_IO.put ("numbers are correct"); Integer_IO.put(corr_pos); Text_IO.put ("of those numbers are in the correct position."); end compare; ---------------------------------------------- --SUB to output degree of insult procedure response (tries: in integer) is begin Text_IO.put("You took "); Intrger_IO.put(tries); Text_IO.put( " to get the correct number"); if tries < 10 then Text_IO.Put("Good Job!!"); if tries > 50 then Text_IO.put("Your Brain dead"); end Response; --------------------------------------------- begin --Master_Mind loop --init. vars. --Text_IO.put("Enter a 4 digit number guess"); --Integer_IO.get(user_num); --call Rnd to get act_num loop call compare; --if guess incorrect prompt for another answer tries := tries + 1; exit loop when guess = "correct"; call response Text_IO.put ("Do you want to play again (y/n) ?"); Text_IO.get (again); exit loop when again = "n"; end program; I know it may be kinda large, but basically it takes a 4 digit # from the user, and compares it to randomly generated #. It then lists the results (how many corect, in the right position, etc) I thought it was pretty good, but in the compare loop I get a couple errors, in fact all over the program, its up to 47 or something. It all looks pretty much syntactily correct to me, but I guess the compiler doesnt like it. Any help would be greatly appreciated. Thanx Mike