-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpig.py
More file actions
56 lines (54 loc) · 1.62 KB
/
pig.py
File metadata and controls
56 lines (54 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import random
pone = 0
bot = 0
rchoice = random.choice(['true','false'])
choice = rchoice
di = random.randint(1,6)
sn = 0
print("Hello! Welcome to the game Pig! The rules are as follows:\nWe will go in turns, randomly picked at the start.\nIf you roll it and it lands on numbers 2-6,\nyou gain those points and you can decide to go again.\nIf you land on 1, your points reset!\n")
a = input("Press any key and enter to start")
while(bot < 100 and pone < 100):
if(rchoice == "true"):
print("Players turn!")
a = input("Roll?(yes or no): ")
while(a == "yes" or a== "Yes"):
di = random.randint(1,6)
sn = sn + di
print("You rolled a " + str(di) + "!")
if(di == 1):
print("You rolled a one!")
sn = 0
rchoice = "false"
else:
pone = pone + sn
print("Your score: " + str(pone))
sn = 0
a = input("Roll?(yes or no): ")
if(a == "no" or a == "No"):
print("Turn ending score: " + str(pone))
rchoice = "false"
while(rchoice == "false"):
print("Bot's turn!")
di = random.randint(1,6)
yesno = random.choice(["yes","no"])
if(yesno == "yes"):
print("I'm rolling!")
yesno = random.choice(["yes","no"])
di = random.randint(1,6)
sn = sn + di
print("I rolled a " + str(di) + "!")
if(di == 1):
print("I rolled a one!")
sn = 0
rchoice = "true"
else:
bot = bot + sn
print("Bot score: " + str(bot))
sn = 0
yesno = random.choice(["yes","no"])
if(yesno == "no"):
print("My turn ending score: " + str(bot))
rchoice = "false"
print("Final Score:")
print("Player = " + str(pone))
print("bot = " + str(bot))