#include
#include
#include
#include
using namespace std;
int topLeft=0,topCenter=0,topRight=0,middleLeft=0,middleCenter=0,middleRight=0,bottomLeft=0,bottomCenter=0,bottomRight=0,turn=0,restart=1,playerMove=0,compMove=0,playerMoveAccept=0,compMoveAccept=0,win=0,fourCorners=0,care=0,chance=0,difficulty=0,placement=0;
void compAI(){
care=1;
srand(time(0));
chance=((rand()%10)+1);
if(chance>=difficulty){
if(middleCenter==1 and topLeft==0 and topRight==0 and bottomLeft==0 and bottomRight==0){
srand(time(0));
placement=((rand()%4)+1);
if(placement==1){topLeft=2;care=0;}
if(placement==2){topRight=2;care=0;}
if(placement==3){bottomLeft=2;care=0;}
if(placement==4){bottomRight=2;care=0;}
}
if(fourCorners==1 and care==1){
if(topLeft==0 and topRight==2 and bottomLeft==2 and bottomRight==2 and care==1){topLeft=2;care=0;}
if(topLeft==2 and topRight==0 and bottomLeft==2 and bottomRight==2 and care==1){topRight==2;care=0;}
if(topLeft==2 and topRight==2 and bottomLeft==0 and bottomRight==2 and care==1){bottomLeft=2;care=0;}
if(topLeft==2 and topRight==2 and bottomLeft==2 and bottomRight==0 and care==1){bottomRight==2;care=0;}
}
if(topLeft==2 and topRight==2 and bottomLeft==2 and bottomRight==2 and middleCenter==0 and care==1){middleCenter=2;care=0;}
if(topCenter==2 and bottomCenter==2 and middleLeft==2 and middleRight==2 and middleCenter==0 and care==1){middleCenter=2;care=0;}
if(topLeft==2 and topCenter==0 and topRight==2 and middleCenter==2 and bottomCenter==2 and care==1){topCenter=2;care=0;}
if(bottomLeft==2 and bottomCenter==0 and bottomRight==2 and middleCenter==2 and topCenter==2 and care==1){bottomCenter=0;care=0;}
if(topLeft==2 and middleLeft==0 and bottomLeft==2 and middleCenter==2 and middleRight==2 and care==1){middleLeft=2;care=0;}
if(topRight==2 and middleRight==0 and bottomRight==2 and middleCenter==2 and middleLeft==2 and care==1){middleRight=2;care=0;}
if(topLeft==2 and middleLeft==0 and bottomLeft==2 and care==1){middleLeft=2;care=0;}
if(topCenter==2 and middleCenter==0 and bottomCenter==2 and care==1){middleCenter=2;care=0;}
if(topRight==2 and middleRight==0 and bottomRight==2 and care==1){middleRight=2;care=0;}
if(topLeft==0 and middleLeft==2 and bottomLeft==2 and care==1){topLeft=2;care=0;}
if(topCenter==0 and middleCenter==2 and bottomCenter==2 and care==1){topCenter=2;care=0;}
if(topRight==0 and middleRight==2 and bottomRight==2 and care==1){topRight=2;care=0;}
if(topLeft==2 and middleLeft==2 and bottomLeft==0 and care==1){bottomLeft=2;care=0;}
if(topCenter==2 and middleCenter==2 and bottomCenter==0 and care==1){bottomCenter=2;care=0;}
if(topRight==2 and middleRight==2 and bottomRight==0 and care==1){bottomRight=2;care=0;}
if(topLeft==2 and topCenter==2 and topRight==0 and care==1){topRight=2;care=0;}
if(middleLeft==2 and middleCenter==2 and middleRight==0 and care==1){middleRight=2;care=0;}
if(bottomLeft==2 and bottomCenter==2 and bottomRight==0 and care==1){bottomRight=2;care=0;}
if(topLeft==2 and topCenter==0 and topRight==2 and care==1){topCenter=2;care=0;}
if(middleLeft==2 and middleCenter==0 and middleRight==2 and care==1){middleCenter=2;care=0;}
if(bottomLeft==2 and bottomCenter==0 and bottomRight==2 and care==1){bottomCenter=2;care=0;}
if(topLeft==0 and topCenter==2 and topRight==2 and care==1){topLeft=2;care=0;}
if(middleLeft==0 and middleCenter==2 and middleRight==2 and care==1){middleLeft=2;care=0;}
if(bottomLeft==0 and bottomCenter==2 and bottomRight==2 and care==1){bottomLeft=2;care=0;}
if(topLeft==2 and middleCenter==0 and bottomRight==2 and care==1){middleCenter=2;care=0;}
if(topLeft==0 and middleCenter==2 and bottomRight==2 and care==1){topLeft=2;care=0;}
if(topLeft==2 and middleCenter==2 and bottomRight==0 and care==1){bottomRight=2;care=0;}
if(topRight==2 and middleCenter==0 and bottomLeft==2 and care==1){middleCenter=2;care=0;}
if(topRight==0 and middleCenter==2 and bottomLeft==2 and care==1){topRight=2;care=0;}
if(topRight==2 and middleCenter==2 and bottomLeft==0 and care==1){bottomLeft=2;care=0;}
if(fourCorners==1 and care==1){
if(topLeft==0 and topRight==1 and bottomLeft==1 and bottomRight==1 and care==1){topLeft=2;care=0;}
if(topLeft==1 and topRight==0 and bottomLeft==1 and bottomRight==1 and care==1){topRight==2;care=0;}
if(topLeft==1 and topRight==1 and bottomLeft==0 and bottomRight==1 and care==1){bottomLeft=2;care=0;}
if(topLeft==1 and topRight==1 and bottomLeft==1 and bottomRight==0 and care==1){bottomRight==2;care=0;}
}
if(topLeft==1 and topRight==1 and bottomLeft==1 and bottomRight==1 and middleCenter==0 and care==1){middleCenter=2;care=0;}
if(topCenter==1 and bottomCenter==1 and middleLeft==1 and middleRight==1 and middleCenter==0 and care==1){middleCenter=2;care=0;}
if(topLeft==1 and topCenter==0 and topRight==1 and middleCenter==1 and bottomCenter==1 and care==1){topCenter=2;care=0;}
if(bottomLeft==1 and bottomCenter==0 and bottomRight==1 and middleCenter==1 and topCenter==1 and care==1){bottomCenter=0;care=0;}
if(topLeft==1 and middleLeft==0 and bottomLeft==1 and middleCenter==1 and middleRight==1 and care==1){middleLeft=2;care=0;}
if(topRight==1 and middleRight==0 and bottomRight==1 and middleCenter==1 and middleLeft==1 and care==1){middleRight=2;care=0;}
if(topLeft==1 and middleLeft==0 and bottomLeft==1 and care==1){middleLeft=2;care=0;}
if(topCenter==1 and middleCenter==0 and bottomCenter==1 and care==1){middleCenter=2;care=0;}
if(topRight==1 and middleRight==0 and bottomRight==1 and care==1){middleRight=2;care=0;}
if(topLeft==0 and middleLeft==1 and bottomLeft==1 and care==1){topLeft=2;care=0;}
if(topCenter==0 and middleCenter==1 and bottomCenter==1 and care==1){topCenter=2;care=0;}
if(topRight==0 and middleRight==1 and bottomRight==1 and care==1){topRight=2;care=0;}
if(topLeft==1 and middleLeft==1 and bottomLeft==0 and care==1){bottomLeft=2;care=0;}
if(topCenter==1 and middleCenter==1 and bottomCenter==0 and care==1){bottomCenter=2;care=0;}
if(topRight==1 and middleRight==1 and bottomRight==0 and care==1){bottomRight=2;care=0;}
if(topLeft==1 and topCenter==1 and topRight==0 and care==1){topRight=2;care=0;}
if(middleLeft==1 and middleCenter==1 and middleRight==0 and care==1){middleRight=2;care=0;}
if(bottomLeft==1 and bottomCenter==1 and bottomRight==0 and care==1){bottomRight=2;care=0;}
if(topLeft==1 and topCenter==0 and topRight==1 and care==1){topCenter=2;care=0;}
if(middleLeft==1 and middleCenter==0 and middleRight==1 and care==1){middleCenter=2;care=0;}
if(bottomLeft==1 and bottomCenter==0 and bottomRight==1 and care==1){bottomCenter=2;care=0;}
if(topLeft==0 and topCenter==1 and topRight==1 and care==1){topLeft=2;care=0;}
if(middleLeft==0 and middleCenter==1 and middleRight==1 and care==1){middleLeft=2;care=0;}
if(bottomLeft==0 and bottomCenter==1 and bottomRight==1 and care==1){bottomLeft=2;care=0;}
if(topLeft==1 and middleCenter==0 and bottomRight==1 and care==1){middleCenter=2;care=0;}
if(topLeft==0 and middleCenter==1 and bottomRight==1 and care==1){topLeft=2;care=0;}
if(topLeft==1 and middleCenter==1 and bottomRight==0 and care==1){bottomRight=2;care=0;}
if(topRight==1 and middleCenter==0 and bottomLeft==1 and care==1){middleCenter=2;care=0;}
if(topRight==0 and middleCenter==1 and bottomLeft==1 and care==1){topRight=2;care=0;}
if(topRight==1 and middleCenter==1 and bottomLeft==0 and care==1){bottomLeft=2;care=0;}
}
}
void gameDisplay(){
if(topLeft==0){cout<>playerMove;
if(playerMove==1 and topLeft==0){topLeft=1;playerMoveAccept=1;}
if(playerMove==1 and topLeft==1 and topLeft==2){playerMove=0;}
if(playerMove==2 and topCenter==0){topCenter=1;playerMoveAccept=1;}
if(playerMove==2 and topCenter==1 and topCenter==2){playerMove=0;}
if(playerMove==3 and topRight==0){topRight=1;playerMoveAccept=1;}
if(playerMove==3 and topRight==1 and topRight==2){playerMove=0;}
if(playerMove==4 and middleLeft==0){middleLeft=1;playerMoveAccept=1;}
if(playerMove==4 and middleLeft==1 and middleLeft==2){playerMove=0;}
if(playerMove==5 and middleCenter==0){middleCenter=1;playerMoveAccept=1;}
if(playerMove==5 and middleCenter==1 and middleCenter==2){playerMove=0;}
if(playerMove==6 and middleRight==0){middleRight=1;playerMoveAccept=1;}
if(playerMove==6 and middleRight==1 and middleRight==2){playerMove=0;}
if(playerMove==7 and bottomLeft==0){bottomLeft=1;playerMoveAccept=1;}
if(playerMove==7 and bottomLeft==1 and bottomLeft==2){playerMove=0;}
if(playerMove==8 and bottomCenter==0){bottomCenter=1;playerMoveAccept=1;}
if(playerMove==8 and bottomCenter==1 and bottomCenter==2){playerMove=0;}
if(playerMove==9 and bottomRight==0){bottomRight=1;playerMoveAccept=1;}
if(playerMove==9 and bottomRight==1 and bottomRight==2){playerMove=0;}
if(playerMove==99){cout<>playerMove;
}
if(playerMove==1){playerMove=99;win=8;}
if(playerMove==2){playerMove=0;cout<>difficulty;
}
cout<>fourCorners;
}
cout<>restart;}
cout<