How to make it so that the program repeats it self? 
	 
	
		| Author | 
		Message | 
	 
		 
		legendz98
 
 
 
    
		 | 
		
		
			
				  Posted: Wed Dec 14, 2011 7:23 pm    Post subject: How to make it so that the program repeats it self?  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				What is it you are trying to achieve?
 
Write a program to simulate the playing of a simple dice game (played with one die).  Roll the die to get a value from 1 to 6.  This we will call your
 
point.  Now keep rolling until you get the same value (that is your point) again and see how many rolls it takes. Program it so you can play the game repeated.
 
 
What is the problem you are having?
 
I have done everything, except making it so that the game is repeatable. I got the program to stop if the user types 
 
 
 
Describe what you have tried to solve this problem
 
I haven't tried much because I don't know where to start.
 
 
 
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
 
 
 
	  | Turing: | 	 		  
var dice, dice1, counter  : int
var question:  string
counter  := 0
loop
    randint (dice,  1,  6)
    put "Your first point is ", dice
     delay (500)
    loop
        randint (dice1,  1,  6)
        put dice1
         delay (500)
        counter  := counter +  1
        exit when dice1  = dice
     end loop
    put "It took ", counter,  " times to roll on the number ", dice
     put "Do you want to play again Y/N?"
    get question
     exit when question  = "N" or question  = "n"
end loop
  | 	  
 
 
Please specify what version of Turing you are using
 
4.11 | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
		 
		Sponsor Sponsor 
		 
  
		 | 
		
 | 
	 
	 
		  | 
	 
				 
		Velocity
 
  
 
    
		 | 
		
		
			
				  Posted: Wed Dec 14, 2011 7:45 pm    Post subject: RE:How to make it so that the program repeats it self?  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				| what do you mean by repeatable? the game does repeat itself after you type "y". Please be more specific with what you aim to achieve? i'll help you. | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		Velocity
 
  
 
    
		 | 
		
		
			
				  Posted: Wed Dec 14, 2011 7:48 pm    Post subject: RE:How to make it so that the program repeats it self?  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				if you mean to make it start without saying yes or no then you might want to make an if statement that says if the roll is equal to the rolled number then ...
 
elsif the roll doesnt equal the rolled number then ...
 
 
kind of makes it more simpler? if not.. then please elaborate on what you want to achieve exactly and ill simplify what you are looking for. | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		RandomLetters
 
 
 
    
		 | 
		
		
			
				  Posted: Wed Dec 14, 2011 7:48 pm    Post subject: RE:How to make it so that the program repeats it self?  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				The lazy way to restart a program:
 
 
1.  Compile it to an EXE
 
2.  Sys.Exec
 
 
The good way to do it:
 
 
1. Reset the state of your program, that is, change all the variables (except "settings", etc) back to the initial value
 
 
2. Go back to the beginning of the code | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		legendz98
 
 
 
    
		 | 
		
		
			
				  Posted: Wed Dec 14, 2011 7:52 pm    Post subject: Re: How to make it so that the program repeats it self?  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				| I want to make the program restart when the user types Y. | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		Velocity
 
  
 
    
		 | 
		
		
			
				  Posted: Wed Dec 14, 2011 8:05 pm    Post subject: RE:How to make it so that the program repeats it self?  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				var counter : int := 0
 
var dice, dice1 : int
 
var question : string
 
loop
 
    randint (dice, 1, 6)
 
    put "Your first point is ", dice
 
    delay (500)
 
    loop
 
        randint (dice1, 1, 6)
 
        put dice1
 
        delay (500)
 
        counter += 1
 
        if dice1 = dice then
 
        cls
 
        end if
 
        exit when dice1 = dice
 
    end loop
 
    put "It took ", counter, " times to roll on the number ", dice
 
    counter := 0
 
    % put "Do you want to play again Y/N?"
 
    % get question
 
    % exit when question = "N" or question = "n"
 
end loop | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		legendz98
 
 
 
    
		 | 
		
		
			
				  Posted: Wed Dec 14, 2011 8:14 pm    Post subject: Re: How to make it so that the program repeats it self?  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				| Thank you so much. | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
				 
		Velocity
 
  
 
    
		 | 
		
		
			
				  Posted: Wed Dec 14, 2011 8:23 pm    Post subject: RE:How to make it so that the program repeats it self?  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				| You are welcome. | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
		 
		Sponsor Sponsor 
		 
  
		 | 
		
 | 
	 
	 
		  | 
	 
				 
		 | 
	 
 
	
	
	 
	
	 |