-
Notifications
You must be signed in to change notification settings - Fork 0
/
hw4.cpp
82 lines (75 loc) · 1.85 KB
/
hw4.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
#include <iostream>
#include "tboard.h"
#include <string>
#include <chrono>
#include <thread>
#include <cmath>
using namespace std;
int vct=0;
int vctry(tboard chk){
int sz=sqrt(chk.howBig());
for (int w=0;w<sz;w++){
if(chk.checkXwin(w)){cout << "victory detected in X direction"<<endl;vct=1;}}
for (int w=0;w<sz;w++){
if(chk.checkYwin(w)){cout << "victory detected in Y direction"<<endl;vct=1;}}
return vct;
}
int main(){
int sz=0;
cout <<"size? (between 3 and 9 inclusive): "<<endl;
cin >>sz;
tboard mn;
mn.nwbrd(sz);
system("clear");
mn.prntBd();
cout << endl;
char PLy1Sm[2]={'X','X'};
char PLy2Sm[2]={'O','O'};
//board editor testing
for (int i =1; i <= mn.howBig();i++){
std::this_thread::sleep_for(std::chrono::seconds(1));
system("clear");
mn.editCL(mn.resx(i), mn.resy(i), PLy1Sm[0], PLy1Sm[1]);
mn.prntBd();
cout <<"iteration: "<< (i)<< endl;
vctry(mn);
}
system("clear");
mn.clearBoard();
mn.prntBd();
std::this_thread::sleep_for(std::chrono::seconds(1));
for (int i =1; i <= mn.howBig();i++){
std::this_thread::sleep_for(std::chrono::seconds(1));
system("clear");
mn.editCL(mn.resx(i), mn.resy(i), PLy2Sm[0], PLy2Sm[1]);
mn.prntBd();
cout <<"iteration: "<< (i)<< endl;
vctry(mn);
}
system("clear");
mn.clearBoard();
mn.prntBd();
std::this_thread::sleep_for(std::chrono::seconds(1));
for (int i =1; i <= mn.howBig();i++){
std::this_thread::sleep_for(std::chrono::seconds(1));
system("clear");
mn.editCL(mn.resy(i), mn.resx(i), PLy1Sm[0], PLy1Sm[1]);
mn.prntBd();
cout <<"iteration: "<< (i)<< endl;
vctry(mn);
}
system("clear");
mn.clearBoard();
mn.prntBd();
std::this_thread::sleep_for(std::chrono::seconds(1));
for (int i =1; i <= mn.howBig();i++){
std::this_thread::sleep_for(std::chrono::seconds(1));
system("clear");
mn.editCL(mn.resy(i), mn.resx(i), PLy2Sm[0], PLy2Sm[1]);
mn.prntBd();
cout <<"iteration: "<< (i)<< endl;
vctry(mn);
}
//board editor testing*/
return 0;
}