Learn how to create a Tic Tac Toe bot in python. Hey everyone welcome to another video. In this first part to a 2 part series on creating this bot we create the basic tic tac toe game. Linked below is a copy of the complete file I make in this video if you just want to hop straight into the second video.
checkWin function:
def checkWin():
if (board[1] == board[2] and board[1] == board[3] and board[1] != ' '):
return True
elif (board[4] == board[5] and board[4] == board[6] and board[4] != ' '):
return True
elif (board[7] == board[8] and board[7] == board[9] and board[7] != ' '):
return True
elif (board[1] == board[4] and board[1] == board[7] and board[1] != ' '):
return True
elif (board[2] == board[5] and board[2] == board[8] and board[2] != ' '):
return True
elif (board[3] == board[6] and board[3] == board[9] and board[3] != ' '):
return True
elif (board[1] == board[5] and board[1] == board[9] and board[1] != ' '):
return True
elif (board[7] == board[5] and board[7] == board[3] and board[7] != ' '):
return True
else:
return False
Code repository: https://github.com/watsojar/tictactoe
On this channel we focus on all things Python. Whether it is a project tutorial/showcase, teaching different Python concepts, or just live coding this is one of the best channels for programmers. Check out my links down below and think about supporting me on Patreon 👇
Links:
Patreon: / codecoach
Discord: / discord
Github: https://github.com/watsojar