【发布时间】:2020-09-02 13:14:17
【问题描述】:
所以我目前正在编写代码来检查 connect3 游戏中的对角线获胜,但由于某种原因,没有显示打印语句,有人可以检查一下有什么问题
board = [['_','X','X','O'],
['_','X','X','O'],
['X','X','O','O']]
num_row = 3
num_col = 4
num_piece = 3 #game pieces needed to win
game_piece = 'X'
# check / diagonal win
for rows in range(num_row - num_piece + 1):
for cols in range(num_piece, num_col):
index = 0
for counts in range(num_piece):
if board[rows + index][cols - index] == game_piece:
index += 1
else:
break
if index == num_piece:
print('game end')
【问题讨论】: