-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConnectFour.cpp
More file actions
49 lines (31 loc) · 828 Bytes
/
ConnectFour.cpp
File metadata and controls
49 lines (31 loc) · 828 Bytes
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
using namespace std;
#include <iostream>
#include "Board/Board.cpp"
int main (){
cout << "Welcome to Muhammad Talha's Connect Four game! \n";
cout << "Enter any key to get started. To exit type any non integer character." << endl;
cin.get();
Board board;
int x = 0;
cout << "Insert (x) : ";
while (cin >> x){
if (x < 0 || x > 6 || !board.valid(x)){
cout << "Please enter a valid coordinate." << endl;
continue;
}
cout << '\n';
board.insertHuman(x);
board.insertAI();
board.print();
if (board.win() == HUMAN){
cout << "You won!" << endl;
return 0;
} else if (board.win() == AI){
cout << "Unfortunately you lost. Better luck next time." << endl;
return 0;
}
cout << '\n';
cout << "Insert (x): ";
}
return 0;
}