Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int winner = 0;
- const int COLcount = 3;
- const int ROWcount = 3;
- int col;
- int row;
- int movecounter = 0;
- bool gameover = false;
- string p1;
- string p2;
- char board[COLcount][ROWcount] = {};
- //
- int one;
- int two;
- int three;
- int four;
- int five;
- int six;
- int seven;
- int eight;
- int nine;
- //
- void welcome(){
- cout << "Hello! Welcome to Theup511's Tic Tac Toe Game! AKA Bad Code Simulator!" << endl;
- // follow me on twitter @Devin__72
- cout << "Please enter a name for Player 1: ";
- cin >> p1;
- cout << "Please enter a name for Player 2: ";
- cin >> p2;
- }
- void draw(){
- cout << board[0][2] << "|" << board[1][2] << "|" << board[2][2] << "|" << endl;
- cout << "______" << endl;
- cout << board[0][1] << "|" << board[1][1] << "|" << board[2][1] << "|" << endl;
- cout << "______" << endl;
- cout << board[0][0] << "|" << board[1][0] << "|" << board[2][0] << "|" << endl;
- }
- void usedcheck(){
- board[0][2] = one;
- board[1][2] = two;
- board[2][2] = three;
- board[0][1] = four;
- board[1][1] = five;
- board[2][1] = six;
- board[0][0] = seven;
- board[1][0] = eight;
- board[2][0] = nine;
- //not doing anything with these yet!
- }
- void moveX(){
- cout << "Please enter a column: ";
- cin >> col;
- cout << "Please enter a row: ";
- cin >> row;
- board[col][row] = 'X';
- cin.get();
- }
- void moveO(){
- cout << "Please enter a column: ";
- cin >> col;
- cout << "Please enter a row: ";
- cin >> row;
- board[col][row] = 'O';
- cin.get();
- }
- void winnercheck()
- {
- if (gameover == false)
- {
- winner = -1;
- }
- else if (board[0][2] == board[1][2] == board[2][2])
- {
- if (board[0][2] == 'X')
- {
- winner = 1;
- }
- else
- {
- winner = 2;
- }
- }
- else if (board[0][1] == board[1][1] == board[2][1])
- {
- if (board[0][1] == 'X')
- {
- winner = 1;
- }
- else
- {
- winner = 2;
- }
- }
- else if (board[0][0] == board[1][0] == board[2][0])
- {
- if (board[0][0] == 'X')
- {
- winner = 1;
- }
- else
- {
- winner = 2;
- }
- }
- else if (board[0][0] == board[0][1] == board[0][2])
- {
- if (board[0][0] == 'X')
- {
- winner = 1;
- }
- else
- {
- winner = 2;
- }
- }
- else if (board[1][0] == board[1][1] == board[1][2])
- {
- if (board[1][0] == 'X')
- {
- winner = 1;
- }
- else
- {
- winner = 2;
- }
- }
- else if (board[2][0] == board[2][1] == board[2][2])
- {
- if (board[2][0] == 'X')
- {
- winner = 1;
- }
- else
- {
- winner = 2;
- }
- }
- else if (board[0][2] == board[1][1] == board[2][0])
- {
- if (board[0][2] == 'X')
- {
- winner = 1;
- }
- else
- {
- winner = 2;
- }
- }
- else if (board[0][0] == board[1][1] == board[2][2])
- {
- if (board[0][0] == 'X')
- {
- winner = 1;
- }
- else
- {
- winner = 2;
- }
- }
- else if (gameover == true)
- {
- winner = 5;
- }
- }
- void gameovercheck(){
- /*board[0][2] = one;
- board[1][2] = two;
- board[2][2] = three;
- board[0][1] = four;
- board[1][1] = five;
- board[2][1] = six;
- board[0][0] = seven;
- board[1][0] = eight;
- board[2][0] = nine;
- */
- }
- int main(){
- welcome();
- while (gameover){
- void moveX();
- draw();
- void moveO();
- return 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement