@AmeenShafeeq/

DiscordBot

Python

No description

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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import random

PileA = random.randint(5, 15)
PileB = random.randint(5, 15)
PileC = random.randint(5, 15)
current_player = "Player 1"
print("===== Welcome to Nim Game =====")
print("Below are 3 magic piles!")
SticksA = print(("Pile A:" + PileA * "*"))
SticksB = print(("Pile B:" + PileB * "*"))
SticksC = print(("Pile C:" + PileC * "*"))
print("(" + str(PileA) + ", " + str(PileB) + ", " + str(PileC) + ")")


def get_input():
    valid_piles = ["A", "B", "C"]
    global Choice, subtract
    while True:
        Choice = input(current_player + " Choose your pile (A, B or C): ")
        if Choice in valid_piles:
            break
        else:
            print(Choice + " is not a valid pile!")
    subtract = int(input(("How many sticks would you like to remove: ")))

def change_player():
    global current_player
    if current_player == "Player 1,":
        current_player = "Player 2,"
    else:
        current_player = "Player 1,"
    

def main():
    while True:
        get_input()
        pile()
        subtraction()
        UpdatedPiles()
        change_player()

def pile():
    global get_input, Choice
    if Choice != "A" and Choice != "B" and Choice != "C":
                print("ERR: this is not a vaild Pile")


def subtraction():
    global subtract, Choice, PileA, PileB, PileC, UpdatedPiles
    if subtract >= PileA + 1 or subtract >= PileB + 1 or subtract >= PileC + 1 or subtract <= 0:
        print("Err: That is not a valid amount of matchsticks!")
    elif Choice == "A":
        PileA = PileA - subtract
    elif Choice == "B":
        PileB = PileB - subtract
    elif Choice == "C":
        PileC = PileC - subtract


def UpdatedPiles():
    global PileA, PileB, PileC
  
    print(("Pile A:" + PileA * "*"))
    print(("Pile B:" + PileB * "*"))
    print(("Pile C:" + PileC * "*"))
    print("(" + str(PileA) + ", " + str(PileB) + ", " + str(PileC) + ")")
    return
    if PileB+PileA+PileC == 1:
      print("game has been reseted")
      PileA = random.randint(5,16)
      PileB =random.randint(5,16)
      PileC= randim.randint(5,16)
      main()


main()