Python

Play Pig

fork
loading
Files
  • main.py
main.py
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
import random
# player logic
PlayerScore = 0
CPUScore = 0
Play = input("Play Pig? [Y|N]: ")
while Play == "Y":
  PlayerPlay = input("Roll? [Y|N] ")
  while PlayerPlay == "Y":
    RandomDieRoll_Player = random.randint(1,6)
    print("Roll = ", RandomDieRoll_Player)
    if RandomDieRoll_Player != 1:
      PlayerScore = PlayerScore + RandomDieRoll_Player
      print(PlayerScore)
      PlayerPlay = input("Roll? [Y|N] ")
    else:
      PlayerScore = 0
      print("PlayerScore: ", PlayerScore)
      PlayerPlay = input("Roll? [Y|N] ")
  WhoseTurn = "CPU"
  CPUPlay = "Y"

  while CPUPlay == "Y" and WhoseTurn == "CPU":
    RandomDieRoll_CPU = random.randint(1,6)
    print("Roll = ", RandomDieRoll_CPU)
    if RandomDieRoll_CPU != 1:
      CPUScore = CPUScore + RandomDieRoll_CPU
      print(CPUScore)
    else:
      CPUScore = 0
      print("CPUScore: ", CPUScore)
      CPUPlay = input("Roll? [Y|N] N")
      WhoseTurn = PlayerPlay
print("Game End")