我需要帮助为我的井字游戏的每一轮制作计分板,我希望它在每轮结束时将 cscore(计算机得分)或 pscore(玩家得分)更新 1。
任何对我的代码的反馈将不胜感激,因为我对 python 还很陌生。
我已经把我已经拥有的分数相关代码放在下面
import random
def main():
global cscore
cscore = 0
global pscore
pscore = 0
if turn == 'player':
drawBoard(theBoard)
move = getPlayerMove(theBoard)
makeMove(theBoard, playerLetter, move)
if isWinner(theBoard, playerLetter):
drawBoard(theBoard)
print('Hooray! You have won the game!')
pscore += 1
print(main)
gameIsPlaying = False
else:
if isBoardFull(theBoard):
drawBoard(theBoard)
print('The game is a tie!')
print(main)
break
else:
turn = 'computer'
else:
move = getComputerMove(theBoard, computerLetter)
makeMove(theBoard, computerLetter, move)
if isWinner(theBoard, computerLetter):
drawBoard(theBoard)
print('The computer has beaten you! You lose.')
cscore += 1
print(main)
gameIsPlaying = False
else:
if isBoardFull(theBoard):
drawBoard(theBoard)
print('The game is a tie!')
print(main)
break
else:
turn = 'player'
if not playAgain():
break
main()