❌ | ⭕ | ⭕ |
---|---|---|
⭕ | ❌ | |
❌ | ⭕ | ❌ |
This C++ program uses backtracking algorithm to find best possible move by calculation winning and loosing probabilities of each move it does and eventually selecting the best possible move.
- Properly Modularised.
- Optimized.
- Always Wins or Draws
- Randomised Moves so it doesn't feels same
- Include game Include file after downlaoding...
#include "TicTacToe/Game.cpp"
- Create the Object
Game *g = new Game(3,userPlayFirst=true);
Note : Do Not Use n greater than 3 or it may take a day for CPU 🤡 to play his chance
3. Execute Play
g->play();
Note : srand(time(0));
for randomly choosing from equal possibilities
#include <bits/stdc++.h>
#include "TicTacToe/Game.cpp"
using namespace std;
int main()
{
srand(time(0));
Game *g = new Game(3,userPlayFirst=true);
g->play();
return 0;
}
g++ play.cpp -o play.exe
play.exe
To Input Consider the grid from 1 to 9 and enter from keyboard