def win_check(board,mark):
return ((board[7] == mark and board[8] == mark and board[9] == mark) or # across the top
(board[4] == mark and board[5] == mark and board[6] == mark) or # across the middley
(board[1] == mark and board[2] == mark and board[3] == mark) or # across the bottom
(board[7] == mark and board[4] == mark and board[1] == mark) or # down the middle
(board[8] == mark and board[5] == mark and board[2] == mark) or # down the middle
(board[9] == mark and board[6] == mark and board[3] == mark) or # down the right side
(board[7] == mark and board[5] == mark and board[3] == mark) or # diagonal
(board[9] == mark and board[5] == mark and board[1] == mark)) # diagonal
print('Welcome To Tic Tac Toe')
while True:
the_board =[' ']*10
player1_symbol, player2_symbol = player_symbol()
player_turn = play_first()
print(player_turn + 'Will go first')
Ready_to_play = input('Ready to play?, Yes or No')
print('ready to play running')
if Ready_to_play == 'Yes' or Ready_to_play == 'yes':
print('game on')
game_on = True
print('game on runs')
else:
game_on = False
while game_on :
if player_turn == 'Player 1':
print('am running player 1')
show_board(the_board)
print('am showing the board')
position = player_choice(the_board)
place_symbol(the_board, player1_symbol,position)
print('i added the marker')
show_board(the_board)
if win_check(the_board, player1_symbol): #this code is not executing
show_board(the_board)
print('check if there is a win')
print('Player 1 wins!!')
game_on = False
else:
if full_board_check(the_board): # this one also
show_board(the_board)
print('Tie game!!')
game_on = False
else:
player_turn = 'Player 2'
else:
print('am running player 2')
show_board(the_board)
print('showing the board')
position = player_choice(the_board)
place_symbol(the_board, player2_symbol,position)
print('adding the marker')
show_board(the_board)
if win_check(the_board, player2_symbol): # this code too not executing
show_board(the_board)
print('Player 2 wins!!')
game_on = False
else:
if full_board_check(the_board):
show_board(the_board)
print('Tie game!!')
game_on = False
else:
player_turn = 'Player 1 '
if not replay():
print('End of game')
break
我使用jupyter笔记本作为代码,当我运行它们的每个代码块时
所有程序运行正常,没有任何问题,但是整个运行了程序
win_check函数未运行,代码用于检查玩家是否获胜或棋盘是否已满,以便程序可以重置,但就目前而言,它只是跳转到重放函数。.任何帮助< / p>
我应该做什么