-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
67 lines (53 loc) · 1.42 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
#include <iostream>
#include <vector>
#include "ttt_functions.hpp"
using namespace std;
/* below while set inputs = to inputs_list
and change argument and parameters to accept inputs*/
int main() {
vector<char> input = {'_', '_', '_', '_', '_', '_', '_', '_', '_'};
vector<int> inputs;
int p_input;
int p_two_input;
game_board(input);
cout << "Input a number from 1-9 with numbers on the box going from left to right order.\n";
for(int i = 0;;){
cout << "Player 1 which box do you select?\n";
cin >> p_input;
//check if p_input has already in input list
while(input_list(p_input, 0, inputs) == 0){
cout << "You cannot choose that option as it has already been chosen. Choose again: \n";
cin >> p_two_input;
}
inputs.push_back(p_input);
input[p_input-1] = 'x';
game_board(input);
i++;
//result check
if(result(input) == 1){
cout << "Player 1 wins!\n";
break;
}
//player 2
if(i>8){
break;
}
cout << "Player 2 which box do you select?\n";
cin >> p_two_input;
//check if p_two_input is already in list
while(input_list(0, p_two_input, inputs) == 0){
cout << "You cannot choose that option as it has already been chosen. Choose again: \n";
cin >> p_two_input;
}
inputs.push_back(p_two_input);
input[p_two_input-1] = 'o';
game_board(input);
i++;
//result check
if(result(input) == 1){
cout << "Player 2 wins!\n";
break;
}
}
return 0;
}