mirror of
https://github.com/hastagAB/Awesome-Python-Scripts.git
synced 2024-11-23 20:11:07 +00:00
AI simulation for guessing the number (#219)
* Add files via upload * Create README.md * Create Requirements * Update README.md
This commit is contained in:
parent
5df866d1d2
commit
968bb023f7
127
AI_for_Guess_the_number/AI_for_Guess_the_number.py
Normal file
127
AI_for_Guess_the_number/AI_for_Guess_the_number.py
Normal file
|
@ -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=""
|
||||
|
1
AI_for_Guess_the_number/README.md
Normal file
1
AI_for_Guess_the_number/README.md
Normal file
|
@ -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 . :)
|
1
AI_for_Guess_the_number/Requirements
Normal file
1
AI_for_Guess_the_number/Requirements
Normal file
|
@ -0,0 +1 @@
|
|||
no requirements, just have python installed. :)
|
|
@ -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]() |
|
||||
|
|
Loading…
Reference in New Issue
Block a user