()
| 128 | scorecount = 0 |
| 129 | #gameplay design here |
| 130 | def 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 | |
| 166 | while True: |
no test coverage detected