52 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
		
		
			
		
	
	
			52 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| 
								 | 
							
								// For more tutorials: https://blog.learngoprogramming.com
							 | 
						||
| 
								 | 
							
								//
							 | 
						||
| 
								 | 
							
								// Copyright © 2018 Inanc Gumus
							 | 
						||
| 
								 | 
							
								// Learn Go Programming Course
							 | 
						||
| 
								 | 
							
								// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
							 | 
						||
| 
								 | 
							
								//
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								package main
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								// ---------------------------------------------------------
							 | 
						||
| 
								 | 
							
								// EXERCISE: Dynamic Difficulty
							 | 
						||
| 
								 | 
							
								//
							 | 
						||
| 
								 | 
							
								//  Current game picks only 5 numbers (5 turns).
							 | 
						||
| 
								 | 
							
								//
							 | 
						||
| 
								 | 
							
								//  Make sure that the game adjust its own difficulty
							 | 
						||
| 
								 | 
							
								//  depending on the guess number.
							 | 
						||
| 
								 | 
							
								//
							 | 
						||
| 
								 | 
							
								// RESTRICTION
							 | 
						||
| 
								 | 
							
								//  Do not make the game to easy. Only adjust the
							 | 
						||
| 
								 | 
							
								//  difficulty if the guess is above 10.
							 | 
						||
| 
								 | 
							
								//
							 | 
						||
| 
								 | 
							
								// EXPECTED OUTPUT
							 | 
						||
| 
								 | 
							
								//  Suppose that the player runs the game like this:
							 | 
						||
| 
								 | 
							
								//    go run main.go 5
							 | 
						||
| 
								 | 
							
								//
							 | 
						||
| 
								 | 
							
								//    Then the computer should pick 5 random numbers.
							 | 
						||
| 
								 | 
							
								//
							 | 
						||
| 
								 | 
							
								//  Or, if the player runs it like this:
							 | 
						||
| 
								 | 
							
								//    go run main.go 25
							 | 
						||
| 
								 | 
							
								//
							 | 
						||
| 
								 | 
							
								//    Then the computer may pick 11 random numbers
							 | 
						||
| 
								 | 
							
								//    instead.
							 | 
						||
| 
								 | 
							
								//
							 | 
						||
| 
								 | 
							
								//  Or, if the player runs it like this:
							 | 
						||
| 
								 | 
							
								//    go run main.go 100
							 | 
						||
| 
								 | 
							
								//
							 | 
						||
| 
								 | 
							
								//    Then the computer may pick 30 random numbers
							 | 
						||
| 
								 | 
							
								//    instead.
							 | 
						||
| 
								 | 
							
								//
							 | 
						||
| 
								 | 
							
								//  As you can see, greater guess number causes the
							 | 
						||
| 
								 | 
							
								//  game to increase the game turns, which in turn
							 | 
						||
| 
								 | 
							
								//  adjust the game's difficulty dynamically.
							 | 
						||
| 
								 | 
							
								//
							 | 
						||
| 
								 | 
							
								//  Because, greater guess number makes it harder to win.
							 | 
						||
| 
								 | 
							
								//  But, this way, game's difficulty will be dynamic.
							 | 
						||
| 
								 | 
							
								//  It will adjust its own difficulty depending on the
							 | 
						||
| 
								 | 
							
								//  guess number.
							 | 
						||
| 
								 | 
							
								// ---------------------------------------------------------
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								func main() {
							 | 
						||
| 
								 | 
							
								}
							 |