I made a game called a bin-picking game in Python. However, it is very weak because it only randomly decides how many to take ...
BottlePickingGame.py
import random
import time
import sys
print("""
Start the bin picking game. What is a bottle-picking game?
Decide the number of bottles and take the bottles alternately,
The person who took the last bottle loses.
The minimum number of bottles is 15
You can take one, two, or three at a time.
""")
time.sleep(2)
Number=0
while 15>Number:
try:
Number=int(input("How many bottles do you want?\n"))
if 15>Number:
print("The minimum number of bottles is 15")
except ValueError:
print("Please enter an integer in half-width numbers")
remaining=0
remaining=int(remaining)
turn=0
take=0
take=int(take)
print("\n\n start the game")
time.sleep(1)
while Number>=remaining:
print("\n The remaining number is",Number-remaining,"It's a book",sep="")
time.sleep(0.5)
print("\n It's your turn")
turn=0
take=0
time.sleep(0.5)
while take>3 or 0>=take:
try:
take=int(input("How many bottles do you take?\n"))
if take>3 or 0>=take:
print("The number that can be taken is 1 to 3")
except ValueError:
print("Please enter an integer in half-width numbers")
remaining=remaining+take
print("\n The remaining number is",Number-remaining,"It's a book",sep="")
if remaining>=Number:
break
time.sleep(0.8)
print("\It's nCP's turn")
turn=1
if Number>remaining+3:
take=random.randint(1,3)
take=int(take)
elif Number>remaining+2:
take=2
take=int(take)
elif Number>remaining+1:
take=1
take=int(take)
else:
take=1
take=int(take)
remaining=remaining+take
time.sleep(0.5)
print(take, "I took the book",sep="")
if remaining>=Number:
break
if turn==0:
time.sleep(0.5)
print("\n\n you lose...")
else:
time.sleep(0.5)
print("\n\n you win!!")
time.sleep(1)
print("End the game")
time.sleep(5)
sys.exit(0)
Recommended Posts