-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.cpp
132 lines (119 loc) · 4.1 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#include <bits/stdc++.h>
#include "docs/clear.h"
#include "docs/winners/winner_X.hpp"
#include "docs/winners/winner_Y.hpp"
#include "docs/playerOne.hpp"
#include "docs/playerTwo.hpp"
#include "AI/aibot.hpp"
#include "AI/roboWin.hpp"
#include "misc.hpp"
using namespace std;
int main() {
/*
1 2 3
4 5 6
7 8 9
enter value 1-9
*/
// initialising the board
x:
int ch;
details();
char board[3][3]={
{'-','-','-'},
{'-','-','-'},
{'-','-','-'},
};
do{
string redo;
do{
cin>>ch;
if (ch==1) {
// do{
clr();
string players[2];
string p1,p2;
char player;
cout<<"Who is Player 1?: ";
cin.ignore();
getline(cin, p1);
cout<<"Who is Player 2?: ";
getline(cin, p2);
clr();
// real shit #1
int freeSpaces=9;
while(checkWinX(board,p1,p2)==false&&checkWinY(board,p1,p2)==false&&freeSpaces<=9){
playerOne(board,p1,p2);
freeSpaces--;
if (freeSpaces==0&&(checkWinX(board,p1,p2)==false&&checkWinY(board,p1,p2)==false)){
cout<<"Uh oh, no one won, match tied :(\nBetter luck next time!\n";
break;
}else
if (checkWinX(board,p1,p2)==false&&checkWinY(board,p1,p2)==false) {
playerTwo(board,p1,p2);
freeSpaces--;
if (freeSpaces==0&&(checkWinX(board,p1,p2)==false&&checkWinY(board,p1,p2)==false)){
cout<<"Uh oh, no one won, match tied :(\nBetter luck next time!\n";
break;
}
}
else {
break;
}
}
cout<<"do you want to play again?(y/n):";
cin>>redo;
if(redo=="y"||redo=="Y"||redo=="yes"||redo=="YES")
goto x;
// }while(redo=="y"||redo=="Y"||redo=="yes"||redo=="YES");
}
else if (ch==2) {
// lolFunct(board);
string p1,p2 ="Computer";
cout<<"What's your name?: ";
// cin>>p1;
cin.ignore();
getline(cin, p1);
int freeSpaces=9;
while(checkWinX(board,p1,p2)==false&&checkWinRobo(board,p1,p2)==false&&freeSpaces<=9){
// if (checkWinX(board,p1,p2)==false&&checkWinY(board,p1,p2)==false){
playerOne(board,p1,p2);
freeSpaces--;
if (freeSpaces==0&&(checkWinX(board,p1,p2)==false&&checkWinRobo(board,p1,p2)==false)){
cout<<"Uh oh, no one won, match tied :(\nBetter luck next time!\n";
break;
}else
// if (checkWinX(board,p1,p2)==false&&checkWinRobo(board,p1,p2)==false) {
if (checkWinX(board,p1,p2)==false&&checkWinRobo(board,p1,p2)==false) {
moverRobo(board);
// playerTwo(board,p1,p2);
freeSpaces--;
if (freeSpaces==0&&(checkWinX(board,p1,p2)==false&&checkWinRobo(board,p1,p2)==false)){
cout<<"Uh oh, no one won, match tied :(\nBetter luck next time!\n";
// moverRobo(board,m1);
break;
}
}
else break;
// freeSpaces--;
// playerOne(board,p1,p2);
}
// break;
// break;
// defCase();
cout<<"do you want to play again?(y/n):";
cin>>redo;
if(redo=="y"||redo=="Y"||redo=="yes"||redo=="YES")
goto x;
else break;
}
else if (ch==3) {
defCase();
}
else {
cout<<"Choice doesn't exits.., try again:";
}
}while(ch>=2||ch<=0);
}while(ch<=0||ch>=4);
// getch();
}