-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsungka.py
executable file
·143 lines (118 loc) · 5.42 KB
/
sungka.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#QUILLO, LOIS JANE L.
#sungka game!! lols
import time
import os
import random
# starting array
player1=[0, 7, 7, 7, 7, 7, 7, 7]
player2=[7, 7, 7, 7, 7, 7, 7, 0]
# turn condition
p1=True
p2=False
missed=False
def printBoard():
move = 0
print("\t\t"," ________________________________________________________________")
print("\t\t"," /________________________________________________________________\\")
print("\t\t"," / 1 2 3 4 5 6 7 \\")
print("\t\t","|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |")
print("\t\t","| ____ ____ ____ ____ ____ ____ ____ |")
print("\t\t","| |","{0:0=2d}".format(player1[1]),"| |", "{0:0=2d}".format(player1[2]),"| |","{0:0=2d}".format(player1[3]),"| |", "{0:0=2d}".format(player1[4]),"| |","{0:0=2d}".format(player1[5]),"| |", "{0:0=2d}".format(player1[6]),"| |", "{0:0=2d}".format(player1[7]),"| |")
print("\t\t","| ‾‾‾‾ ‾‾‾‾ ‾‾‾‾ ‾‾‾‾ ‾‾‾‾ ‾‾‾‾ ‾‾‾‾ |")
print("\t\t","| ____ ____ |")
print("\t\t","| |","{0:0=2d}".format(player1[0]),"| |","{0:0=2d}".format(player2[7]),"| |")
print("\t\t","| ‾‾‾‾ ‾‾‾‾ |")
print("\t\t","| ____ ____ ____ ____ ____ ____ ____ |")
print("\t\t","| |","{0:0=2d}".format(player2[0]),"| |", "{0:0=2d}".format(player2[1]),"| |","{0:0=2d}".format(player2[2]),"| |", "{0:0=2d}".format(player2[3]),"| |","{0:0=2d}".format(player2[4]),"| |", "{0:0=2d}".format(player2[5]),"| |", "{0:0=2d}".format(player2[6]),"| |")
print("\t\t","| ‾‾‾‾ ‾‾‾‾ ‾‾‾‾ ‾‾‾‾ ‾‾‾‾ ‾‾‾‾ ‾‾‾‾ |")
print("\t\t","|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |")
print("\t\t"," \\ 1 2 3 4 5 6 7 /")
# print("\t\t","| |")
print("\t\t"," \\‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾/")
print("\t\t"," ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾")
print("\n")
print("\n")
def boardChecker():
flag=False
for i in range(1,6):
if player1[i] > 1:
flag=True
return flag
for i in range(0,5):
if player2[i] > 1:
flag=True
return flag
return flag
def updateTurn(p1State, p2State):
global p1,p2
p1=p1State
p2=p2State
def updateMissedTurn(missedTurn):
global missed
missed=missedTurn
def player2Move(move, numOfMoves):
if numOfMoves==0:
if p1:
updateTurn(False, True)
updateMissedTurn(True)
return
elif(move>=0 and numOfMoves>0):
player2[move]+=1
player2Move(move-1, numOfMoves-1)
else:
player1Move(move+1, numOfMoves)
return
def player1Move(move, numOfMoves):
if numOfMoves==0:
if p2:
updateTurn(True, False)
updateMissedTurn(True)
return
elif(move<=7 and numOfMoves>0):
player1[move]+=1
player1Move(move+1, numOfMoves-1)
else:
player2Move(move-1, numOfMoves)
return
def play():
move = 0
while(boardChecker()):
printBoard()
print("\t\tPlayer 2's move") if p2 else print("\t\tPlayer 1's move")
playerInput = input("\t\tEnter number: ")
startMove = int(playerInput)
if(p2):
startMove=startMove-1
numOfMoves = player2[startMove]
player2[startMove]=0
player2Move(startMove-1, numOfMoves)
else:
numOfMoves = player1[startMove]
player1[startMove]=0
player1Move(startMove+1, numOfMoves)
pdateTurn(p2,p1) if not missed else updateMissedTurn(False)
def start():
print("\n")
print("\n")
print("\n")
print("\n")
print("\t\t"," ,--. ,--. ")
print("\t\t"," .--.--. ,--.'| ,----.. ,--/ /| ,---, ")
print("\t\t"," / / '. ,--, ,--,: : | / / \ ,---,': / ' ' .' \ ")
print("\t\t","| : /`. / ,'_ /| ,`--.'`| ' :| : : : : '/ / / ; '. ")
print("\t\t","; | |--` .--. | | : | : : | |. | ;. / | ' , : : \ ")
print("\t\t","| : ;_ ,'_ /| : . | : | \ | :. ; /--` ' | / : | /\ \ ")
print("\t\t"," \ \ `. | ' | | . . | : ' '; |; | ; __ | ; ; | : ' ;. : ")
print("\t\t"," `----. \| | ' | | | ' ' ;. ;| : |.' .': ' \ | | ;/ \ \ ")
print("\t\t"," __ \ \ |: | | : ' ; | | | \ |. | '_.' :| | ' ' : | \ \ ,' ")
print("\t\t"," / /`--' /| ; ' | | ' ' : | ; .'' ; : \ |' : |. \| | ' '--' ")
print("\t\t","'--'. / : | : ; ; | | | '`--' ' | '/ .'| | '_\.'| : : ")
print("\t\t"," `--'---' ' : `--' \' : | | : / ' : | | | ,' ")
print("\t\t"," : , .-./; |.' \ \ .' ; |,' `--'' ")
print("\t\t"," `--`----' '---' `---` '---' ")
print("\n")
print("\n")
time.sleep(2)
print("\n")
play()
start()