Abstract
As we all know Tic Tac Toe is such an OG game which we all have played once in our childhood, typically there needs to be 2 players to start a game, instead what if I told you can play make your own tic tac toe and you can play with an AI and you can challenge yourself. So, this project allows you to experiment your tic tac toe skills on yourself and you can improve your skills and win among your friends. Happy Playing.
Algorithm Description
So, Basically, we have used 2 decision making algorithms such as Minmax and Mote Carlo Tree search algorithm.
Minmax Algorithm:
Min max algorithm is a recursive and back propagation algorithm which is mostly used in the game theory, where the AI or the opponent makes his/her optimal move thinking the opponent is also playing optimally. This algorithm is mostly used in the fields such as Chess, Checkers, Tic-Tac-Toe. The main goal of this algorithm is, it will try to get the maximum benefit for itself but it will try to give minimum benefit to the opponent. This algorithm will incorporate Depth-First Search Algorithm for exploring the entire game tree. Then it will back trace all the way from the bottom of the terminal node to make a Decision with the concept of recursion.
Monte-Carlo Tree Search
Monte Carlo Tree search is basically a probabilistic and heuristic approach which finds an optimal path for a given task. Unlike any Search algorithm this algorithm uses the approach of classic tree and some principles of reinforcement learning. In simple terms the main goal of this algorithm is when it finds an optimal path, it will directly not let the user know it has found the optimal path, it will also evaluate the neighboring path along with the learning phase i.e. while it is learning to find an optimal path, it will also learn and evaluate about the other alternative paths, Now this method might help us to explore the path which are not yet explored and also gives us the best optimal path since our algorithm is working and evaluating the entire tree we get to know best path. Now the issue with this algorithm might quickly become inefficient due to number of steps and repetitions and inorder to balance this issue, we use exploitation which basically evaluates the entire paths and sticks to the greatest estimated value.
Reference
- https://www.geeksforgeeks.org/ml-monte-carlo-tree-search-mcts/
- https://www.geeksforgeeks.org/minimax-algorithm-in-game-theory-set-3-tic-tac-toe-ai-finding-optimal-move/
How to Execute?
Make sure you have checked the add to path tick boxes while installing python, anaconda.
Refer to this link, if you are just starting and want to know how to install anaconda.
If you already have anaconda and want to check on how to create anaconda environment, refer to this article set up jupyter notebook. You can skip the article if you have knowledge of installing anaconda, setting up environment and installing requirements.txt
- Install the prerequisites/software’s required to execute the code from reading the above blog which is provided in the link above.
- Press windows key and type in anaconda prompt a terminal opens up.
- Before executing the code, we need to create a specific environment which allows us to install the required libraries necessary for our project.
- Type conda create -name “env_name”, e.g.: conda create -name project_1
- Type conda activate “env_name, e.g.: conda activate project_1
- Go to the directory where your requirement.txt file is present.
- cd <>. E.g., If my file is in d drive, then
- d:
7.cd d:\License-Plate-Recognition–main #CHANGE PATH AS PER YOUR PROJECT, THIS IS JUST AN EXAMPLE
8. If your project is in c drive, you can ignore step 5 and go with step 6
9. g., cd C:\Users\Hi\License-Plate-Recognition-main
10. CHANGE PATH AS PER YOUR PROJECT, THIS IS JUST AN EXAMPLE
11. Run pip install -r requirements.txt or conda install requirements.txt (Requirements.txt is a text file consisting of all the necessary libraries required for executing this python file. If it gives any error while installing libraries, you might need to install them individually.)
12. To run .py file make sure you are in the anaconda terminal with the anaconda path being set as your executable file/folder is being saved. Then type python main.py in the terminal, before running open the main.py and make sure to change the path of the dataset.
13. If you would like to run .ipynb file, Please follow the link to setup and open jupyter notebook, You will be redirected to the local server there you can select which ever .ipynb file you’d like to run and click on it and execute each cell one by one by pressing shift+enter.
14. Run tictactoe.py in your anaconda terminal and make sure to change the path where your executable files are located.
Please follow the above links on how to install and set up anaconda environment to execute files.
Data Description
No specific dataset was used in this project, we have used Min-Max and Monte-Carlo tree search algorithm to simulate an AI bot, you can find more details of the algorithms in the algorithm description section.
Final Results
Issues you may face while executing the code
- We might face an issue while installing specific libraries.
- Make sure you have the latest version of python, since sometimes it might cause version mismatch.
- Adding path to environment variables in order to run python files and setting up anaconda environment. Please follow the links given in the steps to execute section to get more information about this issue.
- Refer to the Below links to get more details on installing python and anaconda and how to configure it.
http://techieyantechnologies.com/2022/07/how-to-install-anaconda/
Note:
All the required data has been provided over here. Please feel free to contact me for any issues.
Click Here For The Source Code And Associated Files.
Let’s Connect
https://www.linkedin.com/in/abhinay-lingala-5a3ab7205/
Yes, you now have more knowledge than yesterday, Keep Going.