mardi 21 novembre 2017

Tic Tac Toe horizontal check

Right, so I'm building a game of Tic Tac Toe and I have a vertical and horizontal check that look like this:

def check_win_left_vert (board):
win = True
x = 0
for y in range (2):
    if board[y][x] != board[y+1][x]:
        win = False
return win

As you can see it just looks through the board by incrementing the y axis, I use the same method for the x axis. Now how would I do this for a diagonal axis? Would I increment both?

Aucun commentaire:

Enregistrer un commentaire