diff --git a/AI_for_Guess_the_number/AI_for_Guess_the_number.py b/AI_for_Guess_the_number/AI_for_Guess_the_number.py new file mode 100644 index 0000000..f59a412 --- /dev/null +++ b/AI_for_Guess_the_number/AI_for_Guess_the_number.py @@ -0,0 +1,127 @@ +import random +print("wassup hommie, care to play a game?") +print("i'll try to guess the number YOU choose.") +print("please tell me the borders: ") + +a = int(input("Min: ")) +b = int(input("Max: ")) +while True: + if(a > b): + (print("error, min can't be more than max. ")) + a = int(input("Min: ")) + b = int(input("Max: ")) + else: + break; +breaking = "------------" +print("now type in the number: ") +c = int(input(" ")) +tries = 1; +d = random.randint(a, b) +while True: + if(d == c and tries == 1): + print("guess 1: " + str(d)) + print("HA, gotcha. I got it in 1 time!") + print("Wanna go again? y for yes and anykey for no. ") + i = input(""); + if(i == "y"): + print(breaking * 10); + a = int(input("Min: ")) + b = int(input("Max: ")) + + print("now type in the number") + c = int(input(" ")) + tries = 1; + if(a > b): + print("error, min can't be more than max. ") + a = int(input("Min: ")) + b = int(input("Max: ")) + print("now type in the number") + c = int(input(" ")) + else: + d = random.randint(a, b) + + else: + break; + elif(d == c): + print("HA, gotcha. I got it in " + str(tries - 1) + " times!") + print("Wanna go again? y for yes and anykey for no. ") + i = input(""); + if(i == "y"): + print(breaking * 10); + a = int(input("Min: ")) + b = int(input("Max: ")) + + print("now type in the number") + c = int(input(" ")) + tries = 1; + if(a > b): + print("error, min can't be more than max. ") + a = int(input("Min: ")) + b = int(input("Max: ")) + print("now type in the number") + c = int(input(" ")) + else: + d = random.randint(a, b) + + else: + break; + + elif(c > b): + print("error, number can't be bigger than max."); + print("Wanna go again? y for yes and anykey for no. ") + i = input(""); + if(i == "y"): + print(breaking * 10); + a = int(input("Min: ")) + b = int(input("Max: ")) + + print("now type in the number") + c = int(input(" ")) + tries = 1; + if(a > b): + (print("error, min can't be more than max. ")) + a = int(input("Min: ")) + b = int(input("Max: ")) + print("now type in the number") + c = int(input(" ")) + else: + d = random.randint(a, b) + + else: + break; + elif(c < a): + print("error, number can't be smaller than min."); + print("Wanna go again? y for yes and anykey for no. ") + i = input(""); + if(i == "y"): + print(breaking * 10); + a = int(input("Min: ")) + b = int(input("Max: ")) + + print("now type in the number") + c = int(input(" ")) + tries = 1; + if(a > b): + print("error, min can't be more than max. ") + a = int(input("Min: ")) + b = int(input("Max: ")) + print("now type in the number") + c = int(input(" ")) + else: + d = random.randint(a, b) + else: + break; + elif(d < c): + a = d + 1; + d = random.randint(a, b) + print( "guess " + str(tries) + " :" + str(d)); + tries += 1; + + elif(d > c): + b = d - 1; + d = random.randint(a, b) + print( "guess " + str(tries) + " :" + str(d)) + tries += 1 + +input="" + diff --git a/AI_for_Guess_the_number/README.md b/AI_for_Guess_the_number/README.md new file mode 100644 index 0000000..73ca898 --- /dev/null +++ b/AI_for_Guess_the_number/README.md @@ -0,0 +1 @@ +This is a simulation of a computer trying to guess a number, it works with any number of zeroes, furthest i got was 13000 zeroes, so have fun . :) diff --git a/AI_for_Guess_the_number/Requirements b/AI_for_Guess_the_number/Requirements new file mode 100644 index 0000000..6d41754 --- /dev/null +++ b/AI_for_Guess_the_number/Requirements @@ -0,0 +1 @@ +no requirements, just have python installed. :) diff --git a/README.md b/README.md index 4052399..103cf55 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ So far, the following projects have been integrated to this repo: | Project Name | Contributors | |--|--| +| [AI for guess the number](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/AI_for_Guess_the_number) | [Omar Sameh](https://github.com/ShadowHunter15) | | [sudoku-solver](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/sudoku-solver) | [Rishabh Umrao](https://github.com/ayedaemon) | |[File Encrypt Decrypt](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/file-encrypt-decrypt)|[Aditya Arakeri](https://github.com/adityaarakeri)| | [Address locator](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/Location_Of_Adress) | [Chris]() |