MCPcopy Create free account
hub / github.com/ndleah/python-mini-project / GamePlay

Function GamePlay

Tic_Tac_Toe/tic_tac_toe.py:130–163  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

128scorecount = 0
129#gameplay design here
130def GamePlay():
131 global scorecount
132 if scorecount == 0:
133 #if the game is first time ran
134 print("Welcome to the game!")
135 if scorecount < 0:
136 #if the score is negative, set it to 0
137 scorecount = 0
138 printBoard(board)
139
140 while not(isBoardFull(board)):
141
142 if not(IsWinner(board, 'O')) :
143 playerMove()
144 CleanScreen()
145 printBoard(board)
146 else:
147 scorecount -= 1
148 print(f"Sorry, you lose 😢! Your Score is {scorecount}")
149 break
150
151 if (not(IsWinner(board, 'X'))) :
152 move = computerMove()
153 if move == 0:
154 print(" ")
155 elif not(isBoardFull(board)):
156 insertLetter('O', move)
157 print('computer placed an o on position', move, ':')
158 CleanScreen()
159 printBoard(board)
160 else:
161 scorecount += 1
162 print(f"You win! Your Score is {scorecount}")
163 break
164
165
166while True:

Callers 1

StartTheGameFunction · 0.85

Calls 7

printBoardFunction · 0.85
isBoardFullFunction · 0.85
IsWinnerFunction · 0.85
playerMoveFunction · 0.85
CleanScreenFunction · 0.85
computerMoveFunction · 0.85
insertLetterFunction · 0.85

Tested by

no test coverage detected