C++ SOURCE CODE FOR SIRJON'S "MICRO" TIC TAC TOE GAME FOR LAPTOPS

 #include<iostream>    

using namespace std;

int main()

{

  string CDots[9] = {"*","*","*","*","*","*","*","*","*"};

  string *q;

  q = &CDots[0];

  

string CNum[9] = {"q","w","e","a","s","d","z","x","c",};

  string *p;

  p = &CNum[0];

  string cell;

  string cell1;

  string mem; 

  int a = 0;

  int b = 0;

  int N = 0;

  

  cout<<"\n";

   cout<<"\n";

   cout<<"\n";

   cout<<"                             SIRJON'S 'MICRO' TIC TAC TOE GAME FOR FUN!"<<"\n"; 

   cout<<"\n";            

   cout<<"                           Instruction: Use  KEYBOARD'S  LETTERS INDICATED BELOW "<<"\n";

   cout<<"\n";

   cout<<"                                           q w e | * * *"<<"\n";

   cout<<"                                           a s d | * * *"<<"\n";

   cout<<"                                           z x c | * * *"<<"\n";

   cout<<"\n";

   cout<<"\n";

   cout<<"\n";

  for(int i=0;i<9;i++)

   {*(q+i)="*";}

while(cell!="0")

  cout<<"                                              "<<*(q+0)<<" "<<*(q+1)<<" "<<*(q+2)<<"\n";

  cout<<"                                              "<<*(q+3)<<" "<<*(q+4)<<" "<<*(q+5)<<"\n";      

  cout<<"                                              "<<*(q+6)<<" "<<*(q+7)<<" "<<*(q+8)<<"\n";

  cout<<"                                            PLAYER A:";  cin>>cell1;

  cout<<"\n";

  

  mem = cell1;

  while(mem!="*")

   {for(int i=0;i<9;i++)

    {if (*(p+i)== cell1)

     {if(*(q+i)=="*")

       { *(q+i)="X";

        mem="*";

       }

      else{cout<<"                                   TRY OTHER CELL, PLAYER A:"; cin>>cell1;

          mem=cell1;}}

      }

    } 

  N++;

  // rows  

    if(*(q+0)=="X")

     {if(*(q+1)=="X")

      { if(*(q+2)=="X")

        { 

  cout<<"                                              "<<*(q+0)<<" "<<*(q+1)<<" "<<*(q+2)<<"\n";

  cout<<"                                              "<<*(q+3)<<" "<<*(q+4)<<" "<<*(q+5)<<"\n";      

  cout<<"                                              "<<*(q+6)<<" "<<*(q+7)<<" "<<*(q+8)<<"\n";

        

  cout<<"                                           PLAYER A WINS"<<"\n";

         a = a+1;

         N= 0;

  cout<<"                                    SCORE: Player A = "<<a<<" ; Player B = "<<b<<"\n";

 cout<<"\n";

        for(int i=0; i<9; i++)

         {*(q+i)="*";}

      }}}


    if(*(q+3)=="X")

     {if(*(q+4)=="X")

      { if(*(q+5)=="X")

       { 

  cout<<"                                              "<<*(q+0)<<" "<<*(q+1)<<" "<<*(q+2)<<"\n";

  cout<<"                                              "<<*(q+3)<<" "<<*(q+4)<<" "<<*(q+5)<<"\n";      

  cout<<"                                              "<<*(q+6)<<" "<<*(q+7)<<" "<<*(q+8)<<"\n";

        

  cout<<"                                           PLAYER A WINS"<<"\n";

         a = a+1;

         N = 0;

  cout<<"                                    SCORE: Player A = "<<a<<" ; Player B = "<<b<<"\n";

  cout<<"\n";

        for(int i=0; i<9; i++)

         {*(q+i)="*";}

      }}}

     

    if(*(q+6)=="X")

     {if(*(q+7)=="X")

      { if(*(q+8)=="X")

     { 

  cout<<"                                              "<<*(q+0)<<" "<<*(q+1)<<" "<<*(q+2)<<"\n";

  cout<<"                                              "<<*(q+3)<<" "<<*(q+4)<<" "<<*(q+5)<<"\n";      

  cout<<"                                              "<<*(q+6)<<" "<<*(q+7)<<" "<<*(q+8)<<"\n";

        

  cout<<"                                           PLAYER A WINS"<<"\n";

         a = a+1;

         N=0;

  cout<<"                                    SCORE: Player A = "<<a<<" ; Player B = "<<b<<"\n";

  cout<<"\n";

        for(int i=0; i<9; i++)

         {*(q+i)="*";}

      }}}


    //columns

    if(*(q+0)=="X")

     {if(*(q+3)=="X")

      { if(*(q+6)=="X")

       { 

  cout<<"                                              "<<*(q+0)<<" "<<*(q+1)<<" "<<*(q+2)<<"\n";

  cout<<"                                              "<<*(q+3)<<" "<<*(q+4)<<" "<<*(q+5)<<"\n";      

  cout<<"                                              "<<*(q+6)<<" "<<*(q+7)<<" "<<*(q+8)<<"\n";

        

  cout<<"                                           PLAYER A WINS"<<"\n";

         a = a+1;

         N=0;

  cout<<"                                    SCORE: Player A = "<<a<<" ; Player B = "<<b<<"\n";

  cout<<"\n";

        for(int i=0; i<9; i++)

         {*(q+i)="*";}

      }}}

      

    if(*(q+1)=="X")

     {if(*(q+4)=="X")

      { if(*(q+7)=="X")

       { 

  cout<<"                                              "<<*(q+0)<<" "<<*(q+1)<<" "<<*(q+2)<<"\n";

  cout<<"                                              "<<*(q+3)<<" "<<*(q+4)<<" "<<*(q+5)<<"\n";      

  cout<<"                                              "<<*(q+6)<<" "<<*(q+7)<<" "<<*(q+8)<<"\n";

        

  cout<<"                                           PLAYER A WINS"<<"\n";

         a = a+1;

         N=0;

  cout<<"                                    SCORE: Player A = "<<a<<" ; Player B = "<<b<<"\n";

  cout<<"\n";

        for(int i=0; i<9; i++)

         {*(q+i)="*";}

      }}}

     

    if(*(q+2)=="X")

     {if(*(q+5)=="X")

      { if(*(q+8)=="X")

       { 

  cout<<"                                              "<<*(q+0)<<" "<<*(q+1)<<" "<<*(q+2)<<"\n";

  cout<<"                                              "<<*(q+3)<<" "<<*(q+4)<<" "<<*(q+5)<<"\n";      

  cout<<"                                              "<<*(q+6)<<" "<<*(q+7)<<" "<<*(q+8)<<"\n";

        

  cout<<"                                           PLAYER A WINS"<<"\n";

         a = a+1;

         N=0;

  cout<<"                                    SCORE: Player A = "<<a<<" ; Player B = "<<b<<"\n";

  cout<<"\n";

        for(int i=0; i<9; i++)

         {*(q+i)="*";}

      }}}

    

     //diagonal 

    if(*(q+0)=="X")

        {if(*(q+4)=="X")

         { if(*(q+8)=="X")

         {

  cout<<"                                              "<<*(q+0)<<" "<<*(q+1)<<" "<<*(q+2)<<"\n";

  cout<<"                                              "<<*(q+3)<<" "<<*(q+4)<<" "<<*(q+5)<<"\n";      

  cout<<"                                              "<<*(q+6)<<" "<<*(q+7)<<" "<<*(q+8)<<"\n";

        

  cout<<"                                           PLAYER A WINS"<<"\n";

         a = a+1;

         N=0;

  cout<<"                                    SCORE: Player A = "<<a<<" ; Player B = "<<b<<"\n";

  cout<<"\n";

        for(int i=0; i<9; i++)

         {*(q+i)="*";}

      }}}

       

    if(*(q+2)=="X")

        {if(*(q+4)=="X")

        { if(*(q+6)=="X")

           { 

  cout<<"                                              "<<*(q+0)<<" "<<*(q+1)<<" "<<*(q+2)<<"\n";

  cout<<"                                              "<<*(q+3)<<" "<<*(q+4)<<" "<<*(q+5)<<"\n";      

  cout<<"                                              "<<*(q+6)<<" "<<*(q+7)<<" "<<*(q+8)<<"\n";

        

  cout<<"                                           PLAYER A WINS"<<"\n";

         a = a+1;

            N=0;

  cout<<"                                    SCORE: Player A = "<<a<<" ; Player B = "<<b<<"\n";

  cout<<"\n";

        for(int i=0; i<9; i++)

         {*(q+i)="*";}

      }}}

      

  if(N>=9)

     {if(a==(a+1))

  { N=0;       

  cout<<"                                              "<<*(q+0)<<" "<<*(q+1)<<" "<<*(q+2)<<"\n";

  cout<<"                                              "<<*(q+3)<<" "<<*(q+4)<<" "<<*(q+5)<<"\n";      

  cout<<"                                              "<<*(q+6)<<" "<<*(q+7)<<" "<<*(q+8)<<"\n"; 

  cout<<"                                   PLAYER A WINS"<<"\n";

  cout<<"                                         SCORE: Player A = "<<a<<" ; Player B = "<<b<<"\n";

     }

  else

  {

        N=0;

  cout<<"                                              "<<*(q+0)<<" "<<*(q+1)<<" "<<*(q+2)<<"\n";

  cout<<"                                              "<<*(q+3)<<" "<<*(q+4)<<" "<<*(q+5)<<"\n";      

  cout<<"                                              "<<*(q+6)<<" "<<*(q+7)<<" "<<*(q+8)<<"\n";

        

  cout<<"                                    GREAT PLAY - IT'S A DRAW!"<<"\n";

        

  cout<<"                               SCORE: Player A = "<<a<<" ; Player B = "<<b<<"\n";

  cout<<"\n";

        for(int i=0; i<9; i++)

         {*(q+i)="*";}}

 }

if(cell1=="0")

 {cell="0";}


 else

{

  

  cout<<"                                              "<<*(q+0)<<" "<<*(q+1)<<" "<<*(q+2)<<"\n";

  cout<<"                                              "<<*(q+3)<<" "<<*(q+4)<<" "<<*(q+5)<<"\n";      

  cout<<"                                              "<<*(q+6)<<" "<<*(q+7)<<" "<<*(q+8)<<"\n";

  cout<<"                                            PLAYER B:";  cin>>cell;

  cout<<"\n";

  mem = cell;

  while(mem!="*")

   {for(int i=0;i<9;i++)

    {if (*(p+i)== cell)

     {if(*(q+i)=="*")

       { *(q+i)="O";

        mem="*";

       }

      else{cout<<"                                   TRY OTHER CELL, PLAYER B:"; cin>>cell;

    

          mem=cell;}}

      }

        

   } 

        

    N++;

    // rows  

    if(*(q+0)=="O")

     {if(*(q+1)=="O")

      { if(*(q+2)=="O")

      { 

        

  cout<<"                                              "<<*(q+0)<<" "<<*(q+1)<<" "<<*(q+2)<<"\n";

  cout<<"                                              "<<*(q+3)<<" "<<*(q+4)<<" "<<*(q+5)<<"\n";      

  cout<<"                                              "<<*(q+6)<<" "<<*(q+7)<<" "<<*(q+8)<<"\n";

        

  cout<<"                                           PLAYER B WINS"<<"\n";

         b = b+1;

         N=0;

  cout<<"                                    SCORE: Player A = "<<a<<" ; Player B = "<<b<<"\n";

  cout<<"\n";

        for(int i=0; i<9; i++)

         {*(q+i)="*";}

      }}}


    if(*(q+3)=="O")

     {if(*(q+4)=="O")

      { if(*(q+5)=="O")

      { 

  cout<<"                                              "<<*(q+0)<<" "<<*(q+1)<<" "<<*(q+2)<<"\n";

  cout<<"                                              "<<*(q+3)<<" "<<*(q+4)<<" "<<*(q+5)<<"\n";      

  cout<<"                                              "<<*(q+6)<<" "<<*(q+7)<<" "<<*(q+8)<<"\n";

        

  cout<<"                                           PLAYER B WINS"<<"\n";

         b = b+1;

         N=0;

  cout<<"                                    SCORE: Player A = "<<a<<" ; Player B = "<<b<<"\n";

  cout<<"\n";

        for(int i=0; i<9; i++)

         {*(q+i)="*";}

      }}}


     

    if(*(q+6)=="O")

     {if(*(q+7)=="O")

      { if(*(q+8)=="O")

     { 

  cout<<"                                              "<<*(q+0)<<" "<<*(q+1)<<" "<<*(q+2)<<"\n";

  cout<<"                                              "<<*(q+3)<<" "<<*(q+4)<<" "<<*(q+5)<<"\n";      

  cout<<"                                              "<<*(q+6)<<" "<<*(q+7)<<" "<<*(q+8)<<"\n";

        

  cout<<"                                           PLAYER B WINS"<<"\n";

         b = b+1;

         N=0;

  cout<<"                                    SCORE: Player A = "<<a<<" ; Player B = "<<b<<"\n";

  cout<<"\n";

        for(int i=0; i<9; i++)

         {*(q+i)="*";}

      }}}



    //columns

    if(*(q+0)=="O")

     {if(*(q+3)=="O")

      { if(*(q+6)=="O")

       { 

  cout<<"                                              "<<*(q+0)<<" "<<*(q+1)<<" "<<*(q+2)<<"\n";

  cout<<"                                              "<<*(q+3)<<" "<<*(q+4)<<" "<<*(q+5)<<"\n";      

  cout<<"                                              "<<*(q+6)<<" "<<*(q+7)<<" "<<*(q+8)<<"\n";

        

  cout<<"                                           PLAYER B WINS"<<"\n";

         b = b+1;

         N=0;

  cout<<"                                    SCORE: Player A = "<<a<<" ; Player B = "<<b<<"\n";

  cout<<"\n";

        for(int i=0; i<9; i++)

         {*(q+i)="*";}

      }}}


    if(*(q+1)=="O")

     {if(*(q+4)=="O")

      { if(*(q+7)=="O")

       { 

  cout<<"                                              "<<*(q+0)<<" "<<*(q+1)<<" "<<*(q+2)<<"\n";

  cout<<"                                              "<<*(q+3)<<" "<<*(q+4)<<" "<<*(q+5)<<"\n";      

  cout<<"                                              "<<*(q+6)<<" "<<*(q+7)<<" "<<*(q+8)<<"\n";

        

  cout<<"                                           PLAYER B WINS"<<"\n";

         b = b+1;

         N=0;

  cout<<"                                    SCORE: Player A = "<<a<<" ; Player B = "<<b<<"\n";

  cout<<"\n";

        for(int i=0; i<9; i++)

         {*(q+i)="*";}

      }}}


  if(*(q+2)=="O")

     {if(*(q+5)=="O")

      { if(*(q+8)=="O")

       { 

  cout<<"                                              "<<*(q+0)<<" "<<*(q+1)<<" "<<*(q+2)<<"\n";

  cout<<"                                              "<<*(q+3)<<" "<<*(q+4)<<" "<<*(q+5)<<"\n";      

  cout<<"                                              "<<*(q+6)<<" "<<*(q+7)<<" "<<*(q+8)<<"\n";

        

  cout<<"                                           PLAYER B WINS"<<"\n";

         b = b+1;

         N=0;

  cout<<"                                   SCORE: Player A = "<<a<<" ; Player B = "<<b<<"\n";

  cout<<"\n";

        for(int i=0; i<9; i++)

         {*(q+i)="*";}

      }}}

 

     //diagonal 

    if(*(q+0)=="O")

        {if(*(q+4)=="O")

         { if(*(q+8)=="O")

          {

  cout<<"                                              "<<*(q+0)<<" "<<*(q+1)<<" "<<*(q+2)<<"\n";

  cout<<"                                              "<<*(q+3)<<" "<<*(q+4)<<" "<<*(q+5)<<"\n";      

  cout<<"                                              "<<*(q+6)<<" "<<*(q+7)<<" "<<*(q+8)<<"\n";

        

  cout<<"                                           PLAYER B WINS"<<"\n";

         b = b+1;

         N=0;

  cout<<"                                   SCORE: Player A = "<<a<<" ; Player B = "<<b<<"\n";

  cout<<"\n";

        for(int i=0; i<9; i++)

         {*(q+i)="*";}

      }}}


       

    if(*(q+2)=="O")

        {if(*(q+4)=="O")

        { if(*(q+6)=="O")

           { 

  cout<<"                                              "<<*(q+0)<<" "<<*(q+1)<<" "<<*(q+2)<<"\n";

  cout<<"                                              "<<*(q+3)<<" "<<*(q+4)<<" "<<*(q+5)<<"\n";      

  cout<<"                                              "<<*(q+6)<<" "<<*(q+7)<<" "<<*(q+8)<<"\n";

        

  cout<<"                                           PLAYER B WINS"<<"\n";

         b = b+1;

         N=0;

  cout<<"                                   SCORE: Player A = "<<a<<" ; Player B = "<<b<<"\n";

  cout<<"\n";

        for(int i=0; i<9; i++)

         {*(q+i)="*";}

      }}}


if(N>=9)

    {if(b==(b+1))

     {

   N=0;       

  cout<<"                                              "<<*(q+0)<<" "<<*(q+1)<<" "<<*(q+2)<<"\n";

  cout<<"                                              "<<*(q+3)<<" "<<*(q+4)<<" "<<*(q+5)<<"\n";      

  cout<<"                                              "<<*(q+6)<<" "<<*(q+7)<<" "<<*(q+8)<<"\n"; 

  cout<<"                                   PLAYER B WINS"<<"\n";

  cout<<"                                         SCORE: Player A = "<<a<<" ; Player B = "<<b<<"\n";

     }

    else

    {

  N=0;

  cout<<"\n";

  cout<<"                                              "<<*(q+0)<<" "<<*(q+1)<<" "<<*(q+2)<<"\n";

  cout<<"                                              "<<*(q+3)<<" "<<*(q+4)<<" "<<*(q+5)<<"\n";      

  cout<<"                                              "<<*(q+6)<<" "<<*(q+7)<<" "<<*(q+8)<<"\n";

        

  cout<<"                                        GREAT  PLAY - IT'S A DRAW"<<"\n";

        

  cout<<"                                   SCORE: Player A = "<<a<<" ; Player B = "<<b<<"\n";

  cout<<"\n";

        for(int i=0; i<9; i++)

         {*(q+i)="*";}


    }}

  

  }

}   

    return 0;

}

Comments

Popular posts from this blog

C++ SOURCE CODE FOR SIRJON'S "MICRO" TIC TAC TOE GAME FOR FUN!

ENTER CORRECT PASSWORD, THREE ATTEMPTS ONLY USING C++ WHILE-IF COMBINATION