I need help setting up the write logic for the winning condition "The game end when either player's king reaches row 8, unless it is white's turn and black's king is in row 7, then black has one turn to reach row 8 to tie game."
I have tried this and it keeps giving me draws
def check_endgame():
for i, row in enumerate(board):
if 'WK' in row:
if i == 7:
return "White Wins!"
if 'BK' in row:
if i == 7:
return "Black Wins!" if board[6].count('WK') == 0 else "Draw!"
return None
I have also tried this but the game starts out with White winning.
def check_endgame():
for i, row in enumerate(board):
if 'WK' in row:
if i == 7:
if 'BK' in board[6]:
return "Draw!"
else:
return "White Wins!"
if 'BK' in row:
if i == 7:
return "Black Wins!"
return None