To all my viewers I'm currently a member of the internship program for a human welfare council and I need your help to assist the people who need us by donating any amount you can. YOUR SMALL GESTURE WILL HELP A FAMILY SMILE. Follow the link and you will get to our campaign page :
Please after funding whatever amount you can, share me the screenshot of the receipt along with my your name and contact number(optional) to my email : sumanmukherjee2001@gmail.com
So that I can send you a receipt for the contribution you made and tell the happiness you shared. 😊
So, here we go our first tutorial on programming. Let’s start the basic thing that every python programmer must have made . Yeah its nothing but a TIC TAC TOE game..
This uses an algorithm named “Minimax Algorithm”. And yeah this code is strictly for PYTHON 3 not PYTHON 2.
You can get the Python file for this game here :-
https://mega.nz/#!74B1kLRD!cYJ9XTuFGCTam5BiXhV72Crp2-AdWze9EsDKTDxaPZY
So how does this algorithm works ?
here’s the answer. It follows some simple instructions that runs like this-
STEP 1 –check whether there’s a move where the computer can win. If yes take it and if not move to STEP 2 .
STEP2– check whether there’s a move where the player can win .If yes block it and if not move to STEP 3.
THIS IS THE STEP WHERE I MADE A LITTLE CHANGE THAN THE OTHER CODES THAT YOU’LL GET IN THE INTERNET. THIS CHANGE MAKES THE GAME UNBEATABLE HOWEVER THERE CAN BE TIE.
STEP3– check whether the center piece is empty. If yes take it if not move to STEP4.
STEP4– check whether the corners are empty . If yes take it if not move to STEP5.
STEP5– check whether the sides are empty . If yes take it .
when you reach to step 5 it means that the board is full and there isn’t any further moves available.
Just try this code in your python 3 idle. And for any further information or explanation regarding this , feel free to mail me –sumanmukherjee2001@gmail.com.
Good One but please type the code in Consolas. That makes reading the code easier.
ReplyDeleteDone aditya and I've also added a video for your ease :)
ReplyDelete