Tic Tac Toe AI with MiniMax using Python | Part 1: Programming Tic Tac Toe

Опубликовано: 13 Февраль 2021
на канале: Java Coding Community
38,669
517

How to create Tic Tac Toe AI with Minimax using Python. Tic Tac Toe AI Bot with Minimax Tutorial. Learn how to create unbeatable Tic Tac Toe AI using minimax and Python.

Today I will show you how to create a tic tac toe AI using Python. The AI will be programmed with the Minimax algorithm which will make it unbeatable.
In this first part we will create the actual tic tac toe game and in the next part we will implement the AI.



Patreon:   / javacodingcommunity  
Find the code here: https://github.com/javacodingcommunit...

Follow me on Instagram:   / javacodingcommunity  

Minimax is a kind of backtracking algorithm that is used in decision making and game theory to find the optimal move for a player, assuming that your opponent also plays optimally. It is widely used in two player turn-based games such as Tic-Tac-Toe, Backgammon, Mancala, Chess, etc.
In Minimax the two players are called maximizer and minimizer. The maximizer tries to get the highest score possible while the minimizer tries to do the opposite and get the lowest score possible.


def checkForWin():
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


Смотрите видео Tic Tac Toe AI with MiniMax using Python | Part 1: Programming Tic Tac Toe онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Java Coding Community 13 Февраль 2021, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 38,669 раз и оно понравилось 517 людям.