| Number game! 
 
	 
	
		| Author | Message |   
		| bc123 
 
  
 
 
 | 
			
				|  Posted: Wed Oct 21, 2009 4:28 pm    Post subject: Number game! |  |   
				| 
 |  
				| Okay on my previous post, I asked how I could make a guessing game and i have completed that but after i went to challenge myself and I added difficulties. So at start u choose 1 for easy, 2 for medium and 3. Hope u like it and also i still want to make it where the var number  int is generated so i dont have to assign one myself.. cya   
 
 	  | Turing: |  	  | 
%gfx
setscreen ("graphics")
color (yellow)
colorback (black)
%Brandon
%October 19 2009
%Guessing Game
%________________________________________________________________________________________
% variables
var number : int
var  number_of_tries : int
var  easy : string
var  medium : string
var  hard : string
var  answer : string
var  guess : int
% number text
put "               #####                                              "
put "              #     # #    # ######  ####   ####  # #    #  ####  "
put "              #       #    # #      #      #      # ##   # #    # "
put "              #  #### #    # #####   ####   ####  # # #  # #      "
put "              #     # #    # #           #      # # #  # # #  ### "
put "              #     # #    # #      #    # #    # # #   ## #    # "
put "               #####   ####  ######  ####   ####  # #    #  ####  "
put "________________________________________________________________________________"
put "                         #####                       "
put "                        #     #   ##   #    # ###### "
put "                        #        #  #  ##  ## #      "
put "                        #  #### #    # # ## # #####  "
put "                        #     # ###### #    # #      "
put "                        #     # #    # #    # #      "
put "                         #####  #    # #    # ###### "
put "________________________________________________________________________________"
% Code
%___________________________________________________________________________________
% if/elsif/put/variables
put "Choose your dificulty (1 for easy, 2 for medium and 3 for hard"
get  answer
if  answer = "1" then
    put "You chose easy"
    put "You have 20 guesses" 
    number_of_tries := 20 
    number := 73
elsif  answer = "2" then
    put "You chose medium"
    put "You have 15 guesses" 
    number := 27 
    number_of_tries := 15
elsif  answer = "3" then
    put "You chose hard"
    put "You have 10 guesses" 
    number := 63 
    number_of_tries := 10
end if
% for loop
for  i : 1 . . number_of_tries
exit when  number >= 1 and  number <= 50    
put "Choose a number between 1 and 100"
    get  guess
    if  guess < number then
        put "Higher"
    elsif  guess > number then
    put "lower" 
    end if
    % end below
    if  guess =  number then
        put "you got it!"
exit        
    end if
end for | 
 bye! and if u can change the randint part plz do 8)
 |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| Sponsor Sponsor
 
  
   |  |   
		|  |   
		| andrew. 
 
 
 
 
 | 
			
				|  Posted: Wed Oct 21, 2009 4:56 pm    Post subject: RE:Number game! |  |   
				| 
 |  
				| Where you have number := 73 or 63 or whatever, put in Rand.Int (1, end). 1 is the starting number and end would be the highest number. It will then choose a random number between it. 
 e.g.
 
 	  | Turing: |  	  | var number : int
number := Rand.Int (1, 100)
 put number
 | 
 |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| ecookman 
 
  
 
 
 | 
			
				|  Posted: Wed Oct 21, 2009 5:08 pm    Post subject: RE:Number game! |  |   
				| 
 |  
				| Or you can do this 
 	  | code: |  	  | 
var num : int
 var answer : int
 var yesno : string
 var yesno2 : string
 randint (num, 1, 5)
 loop
 
 drawfillbox (0,0,633,933,black)
 colorback (black)
 Text.Color (brightred)
 
 
 put "pick a number between 1 and 5"
 get answer
 
 if answer = num then
 put "LOL Y0U WIN"
 elsif answer not= num then
 put "WRRROONNNGGG YOU FAIL NOW LEAVE!"
 end if
 end loop
 
 | 
 |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| bc123 
 
  
 
 
 | 
			
				|  Posted: Wed Oct 21, 2009 5:34 pm    Post subject: RE:Number game! |  |   
				| 
 |  
				| ok 1 more thing, test my game and try using medium because alot of times when i press 2 and hit enter it will just endbut sumtimes it works and u can continue with that game... HELP PLZ!
 |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| bc123 
 
  
 
 
 | 
			
				|  Posted: Wed Oct 21, 2009 5:43 pm    Post subject: Re: RE:Number game! |  |   
				| 
 |  
				| oops this was i quote but i fixed sumthing but i got and error with 2 still |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| bc123 
 
  
 
 
 | 
			
				|  Posted: Wed Oct 21, 2009 5:53 pm    Post subject: Re: Number game! |  |   
				| 
 |  
				| Okay look ive added this but now when u choose your dificulty its glitchy
 
 
 	  | Turing: |  	  | 
%gfx 
setscreen ("graphics") 
color (yellow) 
colorback (black) 
%Brandon 
%October 19 2009 
%Guessing Game 
%________________________________________________________________________________________ 
% variables  
var number_of_tries : int 
var  easy : string 
var  medium : string 
var  hard : string 
var  answer : string 
var  guess : int 
var  number :=  Rand.Int (1 , 100)
% number text 
put "               #####                                              " 
put "              #     # #    # ######  ####   ####  # #    #  ####  " 
put "              #       #    # #      #      #      # ##   # #    # " 
put "              #  #### #    # #####   ####   ####  # # #  # #      " 
put "              #     # #    # #           #      # # #  # # #  ### " 
put "              #     # #    # #      #    # #    # # #   ## #    # " 
put "               #####   ####  ######  ####   ####  # #    #  ####  " 
put "________________________________________________________________________________" 
put "                         #####                       " 
put "                        #     #   ##   #    # ###### " 
put "                        #        #  #  ##  ## #      " 
put "                        #  #### #    # # ## # #####  " 
put "                        #     # ###### #    # #      " 
put "                        #     # #    # #    # #      " 
put "                         #####  #    # #    # ###### " 
put "________________________________________________________________________________" 
% Code 
%___________________________________________________________________________________ 
% if/elsif/put/variables 
put "Choose your dificulty (1 for easy, 2 for medium and 3 for hard" 
get  answer 
if  answer = "1" then 
    put "You chose easy" 
    put "You have 20 guesses" 
    number_of_tries := 20  
elsif  answer = "2" then 
    put "You chose medium" 
    put "You have 15 guesses" 
    number_of_tries := 15 
elsif  answer = "3" then 
    put "You chose hard" 
    put "You have 10 guesses" 
    number_of_tries := 10 
end if 
% for loop 
for  i : 1 . . number_of_tries 
exit when  number >= 1 and  number <= 50    
put "Choose a number between 1 and 100" 
    get  guess 
    if  guess < number then 
        put "Higher" 
    elsif  guess > number then 
    put "lower" 
    end if 
    % end below 
    if  guess =  number then 
        put "you got it!" 
exit        
    end if 
end for | 
 omg SO LOST! HELP
 |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| Zren 
 
  
 
 
 | 
			
				|  Posted: Wed Oct 21, 2009 11:45 pm    Post subject: Re: Number game! |  |   
				| 
 |  
				| bc123 @ Wed Oct 21, 2009 5:53 pm wrote: Okay look
 
ive added this but now when u choose your dificulty its glitchy
 	  | Turing: |  	  | 
exit when number >= 1 and number <= 50
 
 | 
 omg SO LOST! HELP
 Why's that there? Remove it and it works.
 
 Also, you realize that it's possible to find the answer no matter what in a matter of 6 attempts. All you need to do is guess halfway between the ranges. It's basic recursion (for when you learn it).
 
 Say it's 1
 Guess: 50, 25, 12, 6, 3, 2, 1
 
 Another thing.
 
 
 This will make the entire canvas black instead of leaving the white patches.
 |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| bc123 
 
  
 
 
 | 
			
				|  Posted: Thu Oct 22, 2009 1:54 pm    Post subject: Re: Number game! |  |   
				| 
 |  
				| Ok i think i got it all to work!! wooot lmao here it is
 
 
 	  | Turing: |  	  | 
setscreen ("graphics")
            color (yellow)
            colorback (black)
% Brandon
% Guessing game with stages
% October 20 2009
%__________________________________________________________________________________
put "I               #####                                                          I"
put "I              #     # #    # ######  ####   ####  # #    #  ####              I"
put "I              #       #    # #      #      #      # ##   # #    #             I"
put "I              #  #### #    # #####   ####   ####  # # #  # #                  I"
put "I              #     # #    # #           #      # # #  # # #  ###             I"
put "I              #     # #    # #      #    # #    # # #   ## #    #             I"
put "I               #####   ####  ######  ####   ####  # #    #  ####              I"
put "I_______________________________________________________________________________"
put "I                        #####                                                 I"
put "I                        #     #   ##   #    # ######                          I"
put "I                        #        #  #  ##  ## #                               I"
put "I                        #  #### #    # # ## # #####                           I"
put "I                        #     # ###### #    # #                               I"
put "I                        #     # #    # #    # #                               I"
put "I                        #####  #    # #    # ######                           I"
put "I_______________________________________________________________________________"
% Code
%____________________________________________________________________________________
%variables
var guess :=  Rand.Int (1 , 100)
var  easy : int
var  medium : int
var  hard : int
var  level : int
var  number : int
var  number_of_tries : int
%put statements
%asking for difficulty
% easy
% level 1 settings
locate (17 ,1)
% askes for stage selection 
put "Choose your Stage, 1, 2 or 3"
get  level
if  level = 1 then
    put "You chose easy"
    put "choose a number between 1 and 100"
    put "You have 20 guesses" 
    number_of_tries := 20 
    guess :=  Rand.Int (1 , 100)
else
% hard
% level 3 setting    
if  level = 3 then
        put "you chose hard"
        put "choose a number between 1 and 100"
        put "You have 10 guesses" 
        number_of_tries := 10 
        guess :=  Rand.Int (1 , 100)
    else
% medium
    % level 2 settings    
    if  level = 2 then
            put "you chose meduim"
            put "choose a number between 1 and 100"
            put "You have 15 guesses" 
            number_of_tries := 15 
            guess :=  Rand.Int (1 , 100)
        end if
    end if
end if
% for loop 
% loops as manytimes as settings in level 1-3 and read number_of_tries variable
for  i : 1 . . number_of_tries
    get  number
    if  number <=guess then
    put "Higher"
    else
    put "lower"
    end if
% End of game when answer is correct
    if  number =  guess then
        put "you win!!!"
        exit when  number >= 1 and  number <= 100
        if  number < guess then
        end if
    end if 
    end for | 
 i dont think theres any glitches, it should all be working fine, if there is errors pleace let me know
 |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| Sponsor Sponsor
 
  
   |  |   
		|  |   
		| BigBear 
 
 
 
 
 | 
			
				|  Posted: Thu Oct 22, 2009 4:35 pm    Post subject: RE:Number game! |  |   
				| 
 |  
				| Why do you have it say "Higher" when you guess it right? 
 Also try using elsif
 |  
				|  |  |   
		|  |  |  
	  
		|  |   
		| DemonWasp 
 
 
 
 
 | 
			
				|  Posted: Thu Oct 22, 2009 6:14 pm    Post subject: RE:Number game! |  |   
				| 
 |  
				| I'd also like to point out that you can always guess the number in 7 guesses if you follow a decent strategy. |  
				|  |  |   
		|  |  |  
	  
		|  |   
		|  |  
 |