Tic tac toe

This is a fun little program to play tic tac toe with basic C++ commands. It took 13 days to finish. It was fun to test, make and play.

#include <iostream>
using namespace std;

string p1;

string p2;

string a1=” “;

string a2=” “;

string a3=” “;

string b1=” “;

string b2=” “;

string b3=” “;

string c1=” “;

string c2=” “;

string c3=” “;

string p1t1;

string p2t1;

string p1t2;

string p2t2;

string p1t3;

string p2t3;

string p1t4;

string p2t4;

string p1t5;

string yn;

int p1sc;

int p2sc;

int main()

{

/*Tic Tac Toe by Rares */

cout << “Welcome to Tic Tac Toe by Rares \nRules: you need to choose a box from the tic tac toe play space. \nThis is the space: \n”;

cout << ”   a   b   c”<< endl;

cout << “1    |   |   ” << endl;

cout << ”  ———–” << endl;

cout << “2    |   |   ” << endl;

cout << ”  ———–” << endl;

cout << “3    |   |   ” << endl;

cout << “If, for example you want to choose this box: \n”;

cout << ”   a   b   c”<< endl;

cout << “1    |   |   ” << endl;

cout << ”  ———–” << endl;

cout << “2    | X |   ” << endl;

cout << ”  ———–” << endl;

cout << “3    |   |   ” << endl;

cout << “You first type in b for the column and you type 2 for the line. \nYou should type b2. \nAlso in any text box you can write exit to terminate the program, undo to go to the last text box and rules to see the rules.\n”;

n1:

cout << “What’s your name player 1/X?” << endl;

cin >> p1;

cout << “\033[2J\033[1;1H”;

if (p1==”exit”)

return 0;

if (p1==”rules”){

cout << “Rules: you need to choose a box from the tic tac toe play space. \nThis is the space: \n”;

cout << ”   a   b   c”<< endl;

cout << “1    |   |   ” << endl;

cout << ”  ———–” << endl;

cout << “2    |   |   ” << endl;

cout << ”  ———–” << endl;

cout << “3    |   |   ” << endl;

cout << “If, for example you want to choose this box: \n”;

cout << ”   a   b   c”<< endl;

cout << “1    |   |   ” << endl;

cout << ”  ———–” << endl;

cout << “2    | X |   ” << endl;

cout << ”  ———–” << endl;

cout << “3    |   |   ” << endl;

cout << “You first type in b for the column and you type 2 for the line. \nYou should type b2. \nAlso in any text box you can write exit to terminate the program, undo to go to the last text box and rules to see the rules.\n”;

goto n1;}

n2:

cout << “What’s your name player 2/0?” << endl;

cin >> p2;

cout << “\033[2J\033[1;1H”;
if (p2==”exit”)

return 0;
if (p2 == “undo”)

{

cout << “Rewinding….” << endl;

goto n1;

}
if (p2==”rules”)

{

cout << “Rules: you need to choose a box from the tic tac toe play space. \nThis is the space: \n”;

cout << ”   a   b   c”<< endl;

cout << “1    |   |   ” << endl;

cout << ”  ———–” << endl;

cout << “2    |   |   ” << endl;

cout << ”  ———–” << endl;

cout << “3    |   |   ” << endl;

cout << “If, for example you want to choose this box: \n”;

cout << ”   a   b   c”<< endl;

cout << “1    |   |   ” << endl;

cout << ”  ———–” << endl;

cout << “2    | X |   ” << endl;

cout << ”  ———–” << endl;

cout << “3    |   |   ” << endl;

cout << “You first type in b for the column and you type 2 for the line. \nYou should type b2. \nAlso in any text box you can write exit to terminate the program, undo to go to the last text box and rules to see the rules.\n”;

goto n2;

}
p1t1_:

cout << “Score” << endl << p1 << ” ” << p1sc << ” – ” << p2 << ” ” << p2sc << endl;

cout << ”   a   b   c”<< endl;

cout << “1    |   |   ” << endl;

cout << ”  ———–” << endl;

cout << “2    |   |   ” << endl;

cout << ”  ———–” << endl;

cout << “3    |   |   ” << endl;

cout <<p1<<“‘s turn!” << endl;

cin >> p1t1;
cout << “\033[2J\033[1;1H”;
if (p1t1==”rules”)

{

cout << “Rules: you need to choose a box from the tic tac toe play space. \nThis is the space: \n”;

cout << ”   a   b   c”<< endl;

cout << “1    |   |   ” << endl;

cout << ”  ———–” << endl;

cout << “2    |   |   ” << endl;

cout << ”  ———–” << endl;

cout << “3    |   |   ” << endl;

cout << “If, for example you want to choose this box: \n”;

cout << ”   a   b   c”<< endl;

cout << “1    |   |   ” << endl;

cout << ”  ———–” << endl;

cout << “2    | X |   ” << endl;

cout << ”  ———–” << endl;

cout << “3    |   |   ” << endl;

cout << “You first type in b for the column and you type 2 for the line. \nYou should type b2. \nAlso in any text box you can write exit to terminate the program, undo to go to the last text box and rules to see the rules.\n”;

goto p1t1_;

}
if (p1t1 == “undo”)

{

cout << “Rewinding….” << endl;

goto n2;

}
if (p1t1==”exit”)

return 0;
if (p1t1==”a1″)

a1=”X”;

if (p1t1==”a2″)

a2=”X”;

if (p1t1==”a3″)

a3=”X”;

if (p1t1==”b1″)

b1=”X”;

if (p1t1==”b2″)

b2=”X”;

if (p1t1==”b3″)

b3=”X”;

if (p1t1==”c1″)

c1=”X”;

if (p1t1==”c2″)

c2=”X”;

if (p1t1==”c3″)

c3=”X”;
if (p1t1!=”a1″&&p1t1!=”a2″&&p1t1!=”a3″&&p1t1!=”b1″&&p1t1!=”b2″&&p1t1!=”b3″&&p1t1!=”c1″&&p1t1!=”c2″&&p1t1!=”c3″)

{

cout << “That box is not valid!” << endl;

goto p1t1_;

}
p2t1_:

cout << “Score” << endl << p1 << ” ” << p1sc << ” – ” << p2 << ” ” << p2sc << endl;

cout << ”   a   b   c”<< endl;

cout << “1  ” <<a1<<” | “<<b1<<” | “<<c1 << endl;

cout << ”  ———–” << endl;

cout << “2  “<< a2<<” | “<<b2<<” | “<<c2 << endl;

cout << ”  ———–” << endl;

cout << “3  “<< a3<<” | “<<b3<<” | “<<c3 << endl;
cout <<p2<<“‘s turn!” << endl;

cin >> p2t1;
cout << “\033[2J\033[1;1H”;
if (p2t1==p1t1)

{

cout << p2 << ” that box is already in use!”<< endl;

goto p2t1_;

}
if (p2t1==”rules”)

{

cout << “Rules: you need to choose a box from the tic tac toe play space. \nThis is the space: \n”;

cout << ”   a   b   c”<< endl;

cout << “1    |   |   ” << endl;

cout << ”  ———–” << endl;

cout << “2    |   |   ” << endl;

cout << ”  ———–” << endl;

cout << “3    |   |   ” << endl;

cout << “If, for example you want to choose this box: \n”;

cout << ”   a   b   c”<< endl;

cout << “1    |   |   ” << endl;

cout << ”  ———–” << endl;

cout << “2    | X |   ” << endl;

cout << ”  ———–” << endl;

cout << “3    |   |   ” << endl;

cout << “You first type in b for the column and you type 2 for the line. \nYou should type b2. \nAlso in any text box you can write exit to terminate the program, undo to go to the last text box and rules to see the rules.\n”;

goto p2t1_;

}
if (p2t1==”exit”)

return 0;
if (p2t1 == “undo”)

{

cout << “Rewinding….” << endl;

if (p1t1==”a1″)

a1=” “;

if (p1t1==”a2″)

a2=” “;

if (p1t1==”a3″)

a3=” “;

if (p1t1==”b1″)

b1=” “;

if (p1t1==”b2″)

b2=” “;

if (p1t1==”b3″)

b3=” “;

if (p1t1==”c1″)

c1=” “;

if (p1t1==”c2″)

c2=” “;

if (p1t1==”c3″)

c3=” “;

goto p1t1_;

}
if (p2t1==”a1″)

a1=”0″;

if (p2t1==”a2″)

a2=”0″;

if (p2t1==”a3″)

a3=”0″;

if (p2t1==”b1″)

b1=”0″;

if (p2t1==”b2″)

b2=”0″;

if (p2t1==”b3″)

b3=”0″;

if (p2t1==”c1″)

c1=”0″;

if (p2t1==”c2″)

c2=”0″;

if (p2t1==”c3″)

c3=”0″;
if (p2t1!=”a1″&&p2t1!=”a2″&&p2t1!=”a3″&&p2t1!=”b1″&&p2t1!=”b2″&&p2t1!=”b3″&&p2t1!=”c1″&&p2t1!=”c2″&&p2t1!=”c3”)

{

cout << “That box is not valid!” << endl;

goto p2t1_;

}
p1t2_:

cout << “Score” << endl << p1 << ” ” << p1sc << ” – ” << p2 << ” ” << p2sc << endl;

cout << ”   a   b   c”<< endl;

cout << “1  ” <<a1<<” | “<<b1<<” | “<<c1 << endl;

cout << ”  ———–” << endl;

cout << “2  “<< a2<<” | “<<b2<<” | “<<c2 << endl;

cout << ”  ———–” << endl;

cout << “3  “<< a3<<” | “<<b3<<” | “<<c3 << endl;
cout <<p1<<“‘s turn!” << endl;

cin >> p1t2;
cout << “\033[2J\033[1;1H”;
if (p1t2 == p1t1 || p1t2 == p2t1)

{

cout << p1 << ” that box is already in use!”<< endl;

goto p1t2_;

}
if (p1t2==”exit”)

return 0;
if (p1t2==”rules”)

{

cout << “Rules: you need to choose a box from the tic tac toe play space. \nThis is the space: \n”;

cout << ”   a   b   c”<< endl;

cout << “1    |   |   ” << endl;

cout << ”  ———–” << endl;

cout << “2    |   |   ” << endl;

cout << ”  ———–” << endl;

cout << “3    |   |   ” << endl;

cout << “If, for example you want to choose this box: \n”;

cout << ”   a   b   c”<< endl;

cout << “1    |   |   ” << endl;

cout << ”  ———–” << endl;

cout << “2    | X |   ” << endl;

cout << ”  ———–” << endl;

cout << “3    |   |   ” << endl;

cout << “You first type in b for the column and you type 2 for the line. \nYou should type b2. \nAlso in any text box you can write exit to terminate the program, undo to go to the last text box and rules to see the rules.\n”;

goto p1t2_;

}
if (p1t2 == “undo”)

{

cout << “Rewinding….” << endl;

if (p2t1==”a1″)

a1=” “;

if (p2t1==”a2″)

a2=” “;

if (p2t1==”a3″)

a3=” “;

if (p2t1==”b1″)

b1=” “;

if (p2t1==”b2″)

b2=” “;

if (p2t1==”b3″)

b3=” “;

if (p2t1==”c1″)

c1=” “;

if (p2t1==”c2″)

c2=” “;

if (p2t1==”c3″)

c3=” “;

goto p2t1_;

}
if (p1t2==”a1″)

a1=”X”;

if (p1t2==”a2″)

a2=”X”;

if (p1t2==”a3″)

a3=”X”;

if (p1t2==”b1″)

b1=”X”;

if (p1t2==”b2″)

b2=”X”;

if (p1t2==”b3″)

b3=”X”;

if (p1t2==”c1″)

c1=”X”;

if (p1t2==”c2″)

c2=”X”;

if (p1t2==”c3″)

c3=”X”;
if (p1t2!=”a1″&&p1t2!=”a2″&&p1t2!=”a3″&&p1t2!=”b1″&&p1t2!=”b2″&&p1t2!=”b3″&&p1t2!=”c1″&&p1t2!=”c2″&&p1t2!=”c3″)

{

cout << “That box is not valid!” << endl;

goto p1t2_;

}
p2t2_:

cout << “Score” << endl << p1 << ” ” << p1sc << ” – ” << p2 << ” ” << p2sc << endl;

cout << ”   a   b   c”<< endl;

cout << “1  ” <<a1<<” | “<<b1<<” | “<<c1 << endl;

cout << ”  ———–” << endl;

cout << “2  “<< a2<<” | “<<b2<<” | “<<c2 << endl;

cout << ”  ———–” << endl;

cout << “3  “<< a3<<” | “<<b3<<” | “<<c3 << endl;
cout <<p2<<“‘s turn!” << endl;

cin >> p2t2;
cout << “\033[2J\033[1;1H”;
if (p2t2==”exit”)

return 0;

if (p2t2==”rules”)

{

cout << “Rules: you need to choose a box from the tic tac toe play space. \nThis is the space: \n”;

cout << ”   a   b   c”<< endl;

cout << “1    |   |   ” << endl;

cout << ”  ———–” << endl;

cout << “2    |   |   ” << endl;

cout << ”  ———–” << endl;

cout << “3    |   |   ” << endl;

cout << “If, for example you want to choose this box: \n”;

cout << ”   a   b   c”<< endl;

cout << “1    |   |   ” << endl;

cout << ”  ———–” << endl;

cout << “2    | X |   ” << endl;

cout << ”  ———–” << endl;

cout << “3    |   |   ” << endl;

cout << “You first type in b for the column and you type 2 for the line. \nYou should type b2. \nAlso in any text box you can write exit to terminate the program, undo to go to the last text box and rules to see the rules.\n”;

goto p2t2_;

}
if (p2t2 == “undo”)

{

cout << “Rewinding….” << endl;

if (p1t2==”a1″)

a1=” “;

if (p1t2==”a2″)

a2=” “;

if (p1t2==”a3″)

a3=” “;

if (p1t2==”b1″)

b1=” “;

if (p1t2==”b2″)

b2=” “;

if (p1t2==”b3″)

b3=” “;

if (p1t2==”c1″)

c1=” “;

if (p1t2==”c2″)

c2=” “;

if (p1t2==”c3″)

c3=” “;

goto p1t2_;

}
if (p2t2 == p1t1 || p2t2 == p2t1 || p2t2 == p1t2)

{

cout << p2 << ” that box is already in use!”<< endl;

goto p2t2_;

}
if (p2t2==”a1″)

a1=”0″;

if (p2t2==”a2″)

a2=”0″;

if (p2t2==”a3″)

a3=”0″;

if (p2t2==”b1″)

b1=”0″;

if (p2t2==”b2″)

b2=”0″;

if (p2t2==”b3″)

b3=”0″;

if (p2t2==”c1″)

c1=”0″;

if (p2t2==”c2″)

c2=”0″;

if (p2t2==”c3″)

c3=”0″;
if (p2t2!=”a1″&&p2t2!=”a2″&&p2t2!=”a3″&&p2t2!=”b1″&&p2t2!=”b2″&&p2t2!=”b3″&&p2t2!=”c1″&&p2t2!=”c2″&&p2t2!=”c3″)

{

cout << “That box is not valid!” << endl;

goto p2t2_;

}
p1t3_:

cout << “Score” << endl << p1 << ” ” << p1sc << ” – ” << p2 << ” ” << p2sc << endl;

cout << ”   a   b   c”<< endl;

cout << “1  ” <<a1<<” | “<<b1<<” | “<<c1 << endl;

cout << ”  ———–” << endl;

cout << “2  “<< a2<<” | “<<b2<<” | “<<c2 << endl;

cout << ”  ———–” << endl;

cout << “3  “<< a3<<” | “<<b3<<” | “<<c3 << endl;
cout <<p1<<“‘s turn!” << endl;

cin >> p1t3;
cout << “\033[2J\033[1;1H”;
if (p1t3==”exit”)

return 0;
if (p1t3==”rules”)

{

cout << “Rules: you need to choose a box from the tic tac toe play space. \nThis is the space: \n”;

cout << ”   a   b   c”<< endl;

cout << “1    |   |   ” << endl;

cout << ”  ———–” << endl;

cout << “2    |   |   ” << endl;

cout << ”  ———–” << endl;

cout << “3    |   |   ” << endl;

cout << “If, for example you want to choose this box: \n”;

cout << ”   a   b   c”<< endl;

cout << “1    |   |   ” << endl;

cout << ”  ———–” << endl;

cout << “2    | X |   ” << endl;

cout << ”  ———–” << endl;

cout << “3    |   |   ” << endl;

cout << “You first type in b for the column and you type 2 for the line. \nYou should type b2. \nAlso in any text box you can write exit to terminate the program, undo to go to the last text box and rules to see the rules.\n”;

goto p1t3_;

}
if (p1t3 == “undo”)

{

cout << “Rewinding….” << endl;

if (p2t2==”a1″)

a1=” “;

if (p2t2==”a2″)

a2=” “;

if (p2t2==”a3″)

a3=” “;

if (p2t2==”b1″)

b1=” “;

if (p2t2==”b2″)

b2=” “;

if (p2t2==”b3″)

b3=” “;

if (p2t2==”c1″)

c1=” “;

if (p2t2==”c2″)

c2=” “;

if (p2t2==”c3″)

c3=” “;

goto p2t2_;

}
if (p1t3 == p1t1 || p1t3 == p2t1 || p1t3 == p1t2 || p1t3 == p2t2)

{

cout << p1 << ” that box is already in use!”<< endl;

goto p1t3_;

}

if (p1t3==”a1″)

a1=”X”;

if (p1t3==”a2″)

a2=”X”;

if (p1t3==”a3″)

a3=”X”;

if (p1t3==”b1″)

b1=”X”;

if (p1t3==”b2″)

b2=”X”;

if (p1t3==”b3″)

b3=”X”;

if (p1t3==”c1″)

c1=”X”;

if (p1t3==”c2″)

c2=”X”;

if (p1t3==”c3″)

c3=”X”;
if (p1t3!=”a1″&&p1t3!=”a2″&&p1t3!=”a3″&&p1t3!=”b1″&&p1t3!=”b2″&&p1t3!=”b3″&&p1t3!=”c1″&&p1t3!=”c2″&&p1t3!=”c3″)

{

cout << “That box is not valid!” << endl;

goto p1t3_;

}

if (a1==”X” && a2==”X” && a3==”X”||b1==”X”&&b2==”X”&&b3==”X”||c1==”X”&&c2==”X”&&c3==”X”||a1==”X”&&b1==”X”&&c1==”X”||a2==”X”&&b2==”X”&&c2==”X”||a3==”X”&&b3==”X”&&c3==”X”||a1==”X”&&b2==”X”&&c3==”X”||a3==”X”&&b2==”X”&&c1==”X”)

{

cout << ”   a   b   c”<< endl;

cout << “1  ” <<a1<<” | “<<b1<<” | “<<c1 << endl;

cout << ”  ———–” << endl;

cout << “2  “<< a2<<” | “<<b2<<” | “<<c2 << endl;

cout << ”  ———–” << endl;

cout << “3  “<< a3<<” | “<<b3<<” | “<<c3 << endl;

cout<< p1 << ” is the winner!”<<endl;

p1sc ++;

cout <<“Do you want to play again? (yes/no)” << endl;

cin >> yn;

if (yn == “yes”)

{

cout << “Starting new game…” << endl;

a1 = ” “;

a2 = ” “;

a3 = ” “;

b1 = ” “;

b2 = ” “;

b3 = ” “;

c1 = ” “;

c2 = ” “;

c3 = ” “;

goto p1t1_;

}

if (yn == “no”)

return 0;

}
p2t3_:

cout << “Score” << endl << p1 << ” ” << p1sc << ” – ” << p2 << ” ” << p2sc << endl;

cout << ”   a   b   c”<< endl;

cout << “1  ” <<a1<<” | “<<b1<<” | “<<c1 << endl;

cout << ”  ———–” << endl;

cout << “2  “<< a2<<” | “<<b2<<” | “<<c2 << endl;

cout << ”  ———–” << endl;

cout << “3  “<< a3<<” | “<<b3<<” | “<<c3 << endl;
cout <<p2<<“‘s turn!” << endl;

cin >> p2t3;
cout << “\033[2J\033[1;1H”;
if (p2t3 == p1t1 || p2t3 == p2t1 || p2t3 == p1t2 || p2t3 == p2t2 || p2t3==p1t3)

{

cout << p2 << ” that box is already in use!”<< endl;

goto p2t3_;

}
if (p2t3==”exit”)

return 0;
if (p2t3==”rules”){

cout << “Rules: you need to choose a box from the tic tac toe play space. \nThis is the space: \n”;

cout << ”   a   b   c”<< endl;

cout << “1    |   |   ” << endl;

cout << ”  ———–” << endl;

cout << “2    |   |   ” << endl;

cout << ”  ———–” << endl;

cout << “3    |   |   ” << endl;

cout << “If, for example you want to choose this box: \n”;

cout << ”   a   b   c”<< endl;

cout << “1    |   |   ” << endl;

cout << ”  ———–” << endl;

cout << “2    | X |   ” << endl;

cout << ”  ———–” << endl;

cout << “3    |   |   ” << endl;

cout << “You first type in b for the column and you type 2 for the line. \nYou should type b2. \nAlso in any text box you can write exit to terminate the program, undo to go to the last text box and rules to see the rules.\n”;

goto p2t3_;

}
if (p2t3 == “undo”)

{

cout << “Rewinding….” << endl;

if (p1t3==”a1″)

a1=” “;

if (p1t3==”a2″)

a2=” “;

if (p1t3==”a3″)

a3=” “;

if (p1t3==”b1″)

b1=” “;

if (p1t3==”b2″)

b2=” “;

if (p1t3==”b3″)

b3=” “;

if (p1t3==”c1″)

c1=” “;

if (p1t3==”c2″)

c2=” “;

if (p1t3==”c3″)

c3=” “;

goto p1t3_;

}
if (p2t3==”a1″)

a1=”0″;

if (p2t3==”a2″)

a2=”0″;

if (p2t3==”a3″)

a3=”0″;

if (p2t3==”b1″)

b1=”0″;

if (p2t3==”b2″)

b2=”0″;

if (p2t3==”b3″)

b3=”0″;

if (p2t3==”c1″)

c1=”0″;

if (p2t3==”c2″)

c2=”0″;

if (p2t3==”c3″)

c3=”0″;
if (p2t3!=”a1″&&p2t3!=”a2″&&p2t3!=”a3″&&p2t3!=”b1″&&p2t3!=”b2″&&p2t3!=”b3″&&p2t3!=”c1″&&p2t3!=”c2″&&p2t3!=”c3”)

{

cout << “That box is not valid!” << endl;

goto p2t3_;

}

if (a1==”0″ && a2==”0″ && a3==”0″||b1==”0″&&b2==”0″&&b3==”0″||c1==”0″&&c2==”0″&&c3==”0″||a1==”0″&&b1==”0″&&c1==”0″||a2==”0″&&b2==”0″&&c2==”0″||a3==”0″&&b3==”0″&&c3==”0″||a1==”0″&&b2==”0″&&c3==”0″||a3==”0″&&b2==”0″&&c1==”0″)

{

cout << ”   a   b   c”<< endl;

cout << “1  ” <<a1<<” | “<<b1<<” | “<<c1 << endl;

cout << ”  ———–” << endl;

cout << “2  “<< a2<<” | “<<b2<<” | “<<c2 << endl;

cout << ”  ———–” << endl;

cout << “3  “<< a3<<” | “<<b3<<” | “<<c3 << endl;

cout<< p2 << ” is the winner!”<<endl;

p2sc ++;

cout <<“Do you want to play again? (yes/no)” << endl;

cin >> yn;

if (yn == “yes”)

{

cout << “Starting new game…” << endl;

a1 = ” “;

a2 = ” “;

a3 = ” “;

b1 = ” “;

b2 = ” “;

b3 = ” “;

c1 = ” “;

c2 = ” “;

c3 = ” “;

goto p1t1_;

}

if (yn == “no”)

return 0;

}
p1t4_:

cout << “Score” << endl << p1 << ” ” << p1sc << ” – ” << p2 << ” ” << p2sc << endl;

cout << ”   a   b   c”<< endl;

cout << “1  ” <<a1<<” | “<<b1<<” | “<<c1 << endl;

cout << ”  ———–” << endl;

cout << “2  “<< a2<<” | “<<b2<<” | “<<c2 << endl;

cout << ”  ———–” << endl;

cout << “3  “<< a3<<” | “<<b3<<” | “<<c3 << endl;
cout <<p1<<“‘s turn!” << endl;

cin >> p1t4;
cout << “\033[2J\033[1;1H”;
if (p1t4 == p1t1 || p1t4 == p2t1 || p1t4 == p1t2 || p1t4 == p2t2 || p1t4 == p1t3 || p1t4 == p2t3)

{

cout << p1 << ” that box is already in use!”<< endl;

goto p1t4_;

}

if (p1t4==”exit”)

return 0;
if (p1t4==”rules”)

{

cout << “Rules: you need to choose a box from the tic tac toe play space. \nThis is the space: \n”;

cout << ”   a   b   c”<< endl;

cout << “1    |   |   ” << endl;

cout << ”  ———–” << endl;

cout << “2    |   |   ” << endl;

cout << ”  ———–” << endl;

cout << “3    |   |   ” << endl;

cout << “If, for example you want to choose this box: \n”;

cout << ”   a   b   c”<< endl;

cout << “1    |   |   ” << endl;

cout << ”  ———–” << endl;

cout << “2    | X |   ” << endl;

cout << ”  ———–” << endl;

cout << “3    |   |   ” << endl;

cout << “You first type in b for the column and you type 2 for the line. \nYou should type b2. \nAlso in any text box you can write exit to terminate the program, undo to go to the last text box and rules to see the rules.\n”;

goto p1t4_;

}
if (p1t4 == “undo”)

{

cout << “Rewinding….” << endl;

if (p2t3==”a1″)

a1=” “;

if (p2t3==”a2″)

a2=” “;

if (p2t3==”a3″)

a3=” “;

if (p2t3==”b1″)

b1=” “;

if (p2t3==”b2″)

b2=” “;

if (p2t3==”b3″)

b3=” “;

if (p2t3==”c1″)

c1=” “;

if (p2t3==”c2″)

c2=” “;

if (p2t3==”c3″)

c3=” “;

goto p2t3_;

}
if (p1t4==”a1″)

a1=”X”;

if (p1t4==”a2″)

a2=”X”;

if (p1t4==”a3″)

a3=”X”;

if (p1t4==”b1″)

b1=”X”;

if (p1t4==”b2″)

b2=”X”;

if (p1t4==”b3″)

b3=”X”;

if (p1t4==”c1″)

c1=”X”;

if (p1t4==”c2″)

c2=”X”;

if (p1t4==”c3″)

c3=”X”;
if (p1t4!=”a1″&&p1t4!=”a2″&&p1t4!=”a3″&&p1t4!=”b1″&&p1t4!=”b2″&&p1t4!=”b3″&&p1t4!=”c1″&&p1t4!=”c2″&&p1t4!=”c3″)

{

cout << “That box is not valid!” << endl;

goto p1t4_;

}
if (a1==”X”&&a2==”X”&&a3==”X”||b1==”X”&&b2==”X”&&b3==”X”||c1==”X”&&c2==”X”&&c3==”X”||a1==”X”&&b1==”X”&&c1==”X”||a2==”X”&&b2==”X”&&c2==”X”||a3==”X”&&b3==”X”&&c3==”X”||a1==”X”&&b2==”X”&&c3==”X”||a3==”X”&&b2==”X”&&c1==”X”)

{

cout<< p1 << ” is the winner!”<<endl;

cout << ”   a   b   c”<< endl;

cout << “1  ” <<a1<<” | “<<b1<<” | “<<c1 << endl;

cout << ”  ———–” << endl;

cout << “2  “<< a2<<” | “<<b2<<” | “<<c2 << endl;

cout << ”  ———–” << endl;

cout << “3  “<< a3<<” | “<<b3<<” | “<<c3 << endl;

p1sc ++;

cout <<“Do you want to play again? (yes/no)” << endl;

cin >> yn;

if (yn == “yes”)

{

cout << “Starting new game…” << endl;

a1 = ” “;

a2 = ” “;

a3 = ” “;

b1 = ” “;

b2 = ” “;

b3 = ” “;

c1 = ” “;

c2 = ” “;

c3 = ” “;

goto p1t1_;

}

if (yn == “no”)

return 0;

}
p2t4_:

cout << “Score” << endl << p1 << ” ” << p1sc << ” – ” << p2 << ” ” << p2sc << endl;

cout << ”   a   b   c”<< endl;

cout << “1  ” <<a1<<” | “<<b1<<” | “<<c1 << endl;

cout << ”  ———–” << endl;

cout << “2  “<< a2<<” | “<<b2<<” | “<<c2 << endl;

cout << ”  ———–” << endl;

cout << “3  “<< a3<<” | “<<b3<<” | “<<c3 << endl;

cout <<p2<<“‘s turn!” << endl;

cin >> p2t4;
cout << “\033[2J\033[1;1H”;
if (p2t4 == p1t1 || p2t4 == p2t1 || p2t4 == p1t2 || p2t4 == p2t2 || p2t4 == p1t3 || p2t4 == p2t3 || p2t4 == p1t3)

{

cout << p1 << ” that box is already in use!”<< endl;

goto p2t4_;

}

if (p2t4==”exit”)

return 0;

if (p2t4==”rules”)

{

cout << “Rules: you need to choose a box from the tic tac toe play space. \nThis is the space: \n”;

cout << ”   a   b   c”<< endl;

cout << “1    |   |   ” << endl;

cout << ”  ———–” << endl;

cout << “2    |   |   ” << endl;

cout << ”  ———–” << endl;

cout << “3    |   |   ” << endl;

cout << “If, for example you want to choose this box: \n”;

cout << ”   a   b   c”<< endl;

cout << “1    |   |   ” << endl;

cout << ”  ———–” << endl;

cout << “2    | X |   ” << endl;

cout << ”  ———–” << endl;

cout << “3    |   |   ” << endl;

cout << “You first type in b for the column and you type 2 for the line. \nYou should type b2. \nAlso in any text box you can write exit to terminate the program, undo to go to the last text box and rules to see the rules.\n”;

goto p2t4_;

}
if (p2t4 == “undo”)

{

cout << “Rewinding….” << endl;

if (p1t4==”a1″)

a1=” “;

if (p1t4==”a2″)

a2=” “;

if (p1t4==”a3″)

a3=” “;

if (p1t4==”b1″)

b1=” “;

if (p1t4==”b2″)

b2=” “;

if (p1t4==”b3″)

b3=” “;

if (p1t4==”c1″)

c1=” “;

if (p1t4==”c2″)

c2=” “;

if (p1t4==”c3″)

c3=” “;

goto p1t4_;

}
if (p2t4==”a1″)

a1=”0″;

if (p2t4==”a2″)

a2=”0″;

if (p2t4==”a3″)

a3=”0″;

if (p2t4==”b1″)

b1=”0″;

if (p2t4==”b2″)

b2=”0″;

if (p2t4==”b3″)

b3=”0″;

if (p2t4==”c1″)

c1=”0″;

if (p2t4==”c2″)

c2=”0″;

if (p2t4==”c3″)

c3=”0″;
if (p2t4!=”a1″&&p2t4!=”a2″&&p2t4!=”a3″&&p2t4!=”b1″&&p2t4!=”b2″&&p2t4!=”b3″&&p2t4!=”c1″&&p2t4!=”c2″&&p2t4!=”c3”)

{

cout << “That box is not valid!” << endl;

goto p2t4_;

}
if (a1==”0″ && a2==”0″ && a3==”0″||b1==”0″&&b2==”0″&&b3==”0″||c1==”0″&&c2==”0″&&c3==”0″||a1==”0″&&b1==”0″&&c1==”0″||a2==”0″&&b2==”0″&&c2==”0″||a3==”0″&&b3==”0″&&c3==”0″||a1==”0″&&b2==”0″&&c3==”0″||a3==”0″&&b2==”0″&&c1==”0″)

{

cout<< p2 << ” is the winner!”<<endl;

cout << ”   a   b   c”<< endl;

cout << “1  ” <<a1<<” | “<<b1<<” | “<<c1 << endl;

cout << ”  ———–” << endl;

cout << “2  “<< a2<<” | “<<b2<<” | “<<c2 << endl;

cout << ”  ———–” << endl;

cout << “3  “<< a3<<” | “<<b3<<” | “<<c3 << endl;

p2sc ++;

cout <<“Do you want to play again? (yes/no)” << endl;

cin >> yn;

if (yn == “yes”)

{

cout << “Starting new game…” << endl;

a1 = ” “;

a2 = ” “;

a3 = ” “;

b1 = ” “;

b2 = ” “;

b3 = ” “;

c1 = ” “;

c2 = ” “;

c3 = ” “;

goto p1t1_;

}

if (yn == “no”)

return 0;

}
p1t5_:

cout << “Score” << endl << p1 << ” ” << p1sc << ” – ” << p2 << ” ” << p2sc << endl;

cout << ”   a   b   c”<< endl;

cout << “1  ” <<a1<<” | “<<b1<<” | “<<c1 << endl;

cout << ”  ———–” << endl;

cout << “2  “<< a2<<” | “<<b2<<” | “<<c2 << endl;

cout << ”  ———–” << endl;

cout << “3  “<< a3<<” | “<<b3<<” | “<<c3 << endl;

cout <<p1<<“‘s turn!” << endl;

cin >> p1t5;
cout << “\033[2J\033[1;1H”;
if (p1t5 == p1t1 || p1t5 == p2t1 || p1t5 == p1t2 || p1t5 == p2t2 || p1t5 == p1t3 || p1t5 == p2t3 || p1t5 == p1t3 || p1t5 == p2t3 || p1t5 == p2t4)

{

cout << p1 << ” that box is already in use!”<< endl;

goto p1t5_;

}
if (p1t5 ==”exit”)

return 0;
if (p1t5==”rules”)

{

cout << “Rules: you need to choose a box from the tic tac toe play space. \nThis is the space: \n”;

cout << ”   a   b   c”<< endl;

cout << “1    |   |   ” << endl;

cout << ”  ———–” << endl;

cout << “2    |   |   ” << endl;

cout << ”  ———–” << endl;

cout << “3    |   |   ” << endl;

cout << “If, for example you want to choose this box: \n”;

cout << ”   a   b   c”<< endl;

cout << “1    |   |   ” << endl;

cout << ”  ———–” << endl;

cout << “2    | X |   ” << endl;

cout << ”  ———–” << endl;

cout << “3    |   |   ” << endl;

cout << “You first type in b for the column and you type 2 for the line. \nYou should type b2. \nAlso in any text box you can write exit to terminate the program, undo to go to the last text box and rules to see the rules.\n”;

goto p1t5_;

}
if (p1t5 == “undo”)

{

cout << “Rewinding….” << endl;

if (p2t4==”a1″)

a1=” “;

if (p2t4==”a2″)

a2=” “;

if (p2t4==”a3″)

a3=” “;

if (p2t4==”b1″)

b1=” “;

if (p2t4==”b2″)

b2=” “;

if (p2t4==”b3″)

b3=” “;

if (p2t4==”c1″)

c1=” “;

if (p2t4==”c2″)

c2=” “;

if (p2t4==”c3″)

c3=” “;

goto p2t4_;

}
if (p1t5==”a1″)

a1=”X”;

if (p1t5==”a2″)

a2=”X”;

if (p1t5==”a3″)

a3=”X”;

if (p1t5==”b1″)

b1=”X”;

if (p1t5==”b2″)

b2=”X”;

if (p1t5==”b3″)

b3=”X”;

if (p1t5==”c1″)

c1=”X”;

if (p1t5==”c2″)

c2=”X”;

if (p1t5==”c3″)

c3=”X”;
if (p1t5!=”a1″&&p1t5!=”a2″&&p1t5!=”a3″&&p1t5!=”b1″&&p1t5!=”b2″&&p1t5!=”b3″&&p1t5!=”c1″&&p1t5!=”c2″&&p1t5!=”c3″)

{

cout << “That box is not valid!” << endl;

goto p1t5_;

}
if (a1==”X”&&a2==”X”&&a3==”X”||b1==”X”&&b2==”X”&&b3==”X”||c1==”X”&&c2==”X”&&c3==”X”||a1==”X”&&b1==”X”&&c1==”X”||a2==”X”&&b2==”X”&&c2==”X”||a3==”X”&&b3==”X”&&c3==”X”||a1==”X”&&b2==”X”&&c3==”X”||a3==”X”&&b2==”X”&&c1==”X”)

{
cout << ”   a   b   c”<< endl;

cout << “1  ” <<a1<<” | “<<b1<<” | “<<c1 << endl;

cout << ”  ———–” << endl;

cout << “2  “<< a2<<” | “<<b2<<” | “<<c2 << endl;

cout << ”  ———–” << endl;

cout << “3  “<< a3<<” | “<<b3<<” | “<<c3 << endl;

cout<< p1 << ” is the winner!”<<endl;

p1sc ++;

}
else{

cout << “It’s a tie!”<<endl;

cout << ”   a   b   c”<< endl;

cout << “1  ” <<a1<<” | “<<b1<<” | “<<c1 << endl;

cout << ”  ———–” << endl;

cout << “2  “<< a2<<” | “<<b2<<” | “<<c2 << endl;

cout << ”  ———–” << endl;

cout << “3  “<< a3<<” | “<<b3<<” | “<<c3 << endl;

}

cout <<“Do you want to play again? (yes/no)” << endl;

cin >> yn;

if (yn == “yes”)

{

cout << “Starting new game…” << endl;

a1 = ” “;

a2 = ” “;

a3 = ” “;

b1 = ” “;

b2 = ” “;

b3 = ” “;

c1 = ” “;

c2 = ” “;

c3 = ” “;

goto p1t1_;

}

if (yn == “no”)

return 0;

}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s