jankeifer 0 Newbie Poster

can anyone please help me in to creating a client-server using this game?

#include <iostream>

#include <iomanip>

#include <map>

#include <time.h>

#include <cstdlib>

using namespace std;



//displays the instruction of the game

void displayInst(){

    for ( int b = 0; b < 28; b++ )

    cout << "* ";



    cout << "\n* Game Title: NUM-BERS                                 *";

    cout << "\n*                                                      *";

    cout << "\n* Players : 2                                          *";

    cout << "\n*                                                      *";

    cout << "\n* How-to-play: The game is basically                   *";

    cout << "\n*              based on \"tic-tac-toe\" but with a       *";

    cout << "\n*              twist. Instead of Using X's and O's     *";

    cout << "\n*              the player is going to use numbers,     *";

    cout << "\n*              ODD for PLAYER 1 and EVEN for PLAYER 2. *";

    cout << "\n*              The goal is to make a \"in a row\";       *";

    cout << "\n*              (diagonally, vertically,horizontally)   *";

    cout << "\n*              but the catch is, the total of the row  *";

    cout << "\n*              will be equal to the \"goal total\"       *";

    cout << "\n*              generated by the program.               *\n";

    for ( int b = 0; b < 28; b++ )

        cout << "* ";

}//end displayInst





int main(){

    

   char choice;     

   

   do{

        

        map<char,char> box;

        box['a'] = 'a';

        box['b'] = 'b';

        box['c'] = 'c';

        box['d'] = 'd';

        box['e'] = 'e';

        box['f'] = 'f';

        box['g'] = 'g';

        box['h'] = 'h';

        box['i'] = 'i';



        char letter,value;   

        int goalTotal;

        bool win = false;

       	int a[8];

       	int player1[5] = {1,3,5,7,9};

       	int player2[5] = {2,4,6,8,10};

        

        //generates a random number …
jankeifer 0 Newbie Poster

Sorry, that was my mistake - I failed to close the two open brackets. It should go as follows:

for (int i = 0; i < 8; i++) {
                      if (a[i] == goalTotal) {
                          cout << endl << "Player Wins" << endl;
                          win = true;
                          break;
                      }
                  }

master Schoil-R-LEA,
how can i make it into 2 players..
i mean, how can i display on who's turn is it to play?

if it's not much of a burden.. can you help me? :)

jankeifer 0 Newbie Poster

thank you so much.. gonna try it now.. :))

jankeifer 0 Newbie Poster

Since you are already testing for wins, we can use that to simplify the loop exit. First we'll add a Boolean variable named win and initialize it to false:

bool win = false;

Then we'll simplify the test for winning:

for (int i = 0; i < 8; i++) {
                      if (a[i] == goalTotal) {
                          cout << endl << "Player Wins" << endl;
                          win = true;

Finally, we change the conditional of the do/while() loop:

while(!win);

Try that and see if it works.

is this correct?

#include <iostream>
#include <iomanip>
#include <map>
#include <time.h>
#include <cstdlib>
using namespace std;

//displays the instruction of the game
void displayInst(){
    for ( int b = 0; b < 28; b++ )
    cout << "* ";

    cout << "\n* Game Title: NUM-BERS                                 *";
    cout << "\n*                                                      *";
    cout << "\n* Players : 2                                          *";
    cout << "\n*                                                      *";
    cout << "\n* How-to-play: The game is basically                   *";
    cout << "\n*              based on \"tic-tac-toe\" but with a       *";
    cout << "\n*              twist. Instead of Using X's and O's     *";
    cout << "\n*              the player is going to use numbers,     *";
    cout << "\n*              ODD for PLAYER 1 and EVEN for PLAYER 2. *";
    cout << "\n*              The goal is to make a \"in a row\";       *";
    cout << "\n*              (diagonally, vertically,horizontally)   *";
    cout << "\n*              but the catch is, the total of the row  *";
    cout << "\n*              will be equal to the \"goal total\"       *";
    cout << "\n*              generated by the program.               *\n";
    for ( int …
jankeifer 0 Newbie Poster
#include <iostream>
#include <iomanip>
#include <map>
#include <time.h>
#include <cstdlib>
using namespace std;

//displays the instruction of the game
void displayInst(){
    for ( int b = 0; b < 28; b++ )
    cout << "* ";

    cout << "\n* Game Title: NUM-BERS                                 *";
    cout << "\n*                                                      *";
    cout << "\n* Players : 2                                          *";
    cout << "\n*                                                      *";
    cout << "\n* How-to-play: The game is basically                   *";
    cout << "\n*              based on \"tic-tac-toe\" but with a       *";
    cout << "\n*              twist. Instead of Using X's and O's     *";
    cout << "\n*              the player is going to use numbers,     *";
    cout << "\n*              ODD for PLAYER 1 and EVEN for PLAYER 2. *";
    cout << "\n*              The goal is to make a \"in a row\";       *";
    cout << "\n*              (diagonally, vertically,horizontally)   *";
    cout << "\n*              but the catch is, the total of the row  *";
    cout << "\n*              will be equal to the \"goal total\"       *";
    cout << "\n*              generated by the program.               *\n";
    for ( int b = 0; b < 28; b++ )
        cout << "* ";
}//end displayInst


int main(){
    
   char choice;     
   
   do{
        
        map<char,char> box;
        box['a'] = 'a';
        box['b'] = 'b';
        box['c'] = 'c';
        box['d'] = 'd';
        box['e'] = 'e';
        box['f'] = 'f';
        box['g'] = 'g';
        box['h'] = 'h';
        box['i'] = 'i';

        char letter,value;   
        int goalTotal;
    
        //generates a random number for the total goal
        srand( time(NULL) );
        goalTotal = (5 + rand() % 15);
      	int a[8];
      	
      	
        do{
		
            displayInst();//displays the instructions
        
            //display's the main board
            cout << endl …
jankeifer 0 Newbie Poster
#include <iostream>
#include <iomanip>
#include <map>
#include <time.h>
#include <cstdlib>
using namespace std;

//displays the instruction of the game
void displayInst(){
    for ( int b = 0; b < 28; b++ )
    cout << "* ";

    cout << "\n* Game Title: NUM-BERS                                 *";
    cout << "\n*                                                      *";
    cout << "\n* Players : 2                                          *";
    cout << "\n*                                                      *";
    cout << "\n* How-to-play: The game is basically                   *";
    cout << "\n*              based on \"tic-tac-toe\" but with a       *";
    cout << "\n*              twist. Instead of Using X's and O's     *";
    cout << "\n*              the player is going to use numbers,     *";
    cout << "\n*              ODD for PLAYER 1 and EVEN for PLAYER 2. *";
    cout << "\n*              The goal is to make a \"in a row\";       *";
    cout << "\n*              (diagonally, vertically,horizontally)   *";
    cout << "\n*              but the catch is, the total of the row  *";
    cout << "\n*              will be equal to the \"goal total\"       *";
    cout << "\n*              generated by the program.               *\n";
    for ( int b = 0; b < 28; b++ )
        cout << "* ";
}//end displayInst


int main(){
    
   char choice;     
   
   do{
        
        map<char,char> box;
        box['a'] = 'a';
        box['b'] = 'b';
        box['c'] = 'c';
        box['d'] = 'd';
        box['e'] = 'e';
        box['f'] = 'f';
        box['g'] = 'g';
        box['h'] = 'h';
        box['i'] = 'i';

        char letter,value;   
        int goalTotal;
    
        //generates a random number for the total goal
        srand( time(NULL) );
        goalTotal = (5 + rand() % 15);
      	int a[8];
      	
      	
        do{
		
            displayInst();//displays the instructions
        
            //display's the main board
            cout << endl …
jankeifer 0 Newbie Poster

i'm just having a hard time in my algorithm.. i'm getting confused. @.@

jankeifer 0 Newbie Poster

here's my code so far.

#include <iostream>
#include <map>
using namespace std;

int main(){

map<char,char> box;

box['a'] = 'a';
box['b'] = 'b';
box['c'] = 'c';
box['d'] = 'd';
box['e'] = 'e';
box['f'] = 'f';
box['g'] = 'g';
box['h'] = 'h';
box['i'] = 'i';

char letter,value;

cout << endl << box['a']<<" | "<<box['b']<<" | "<<box['c'];
cout << "\n---------\n";
cout << box['d']<<" | "<<box['e']<<" | "<<box['f'];
cout << "\n---------\n";
cout << box['g']<<" | "<<box['h']<<" | "<<box['i'];

cout<<endl<<"\nEnter a letter: ";
cin>>letter;
cout<<endl<<"Enter a value: ";
cin>>value;
box[letter] = value;
cout << endl << box['a']<<" | "<<box['b']<<" | "<<box['c'];
cout << "\n---------\n";
cout << box['d']<<" | "<<box['e']<<" | "<<box['f'];
cout << "\n---------\n";
cout << box['g']<<" | "<<box['h']<<" | "<<box['i']<< endl;



system ("pause");
}
jankeifer 0 Newbie Poster

Yes we can. Problem is we're not all psychic so
1) we can't help you fix the code we can not see, nor
2) we can't answer questions that were not asked.

uhm.. can you please give me an idea on how the main code will be coded?

jankeifer 0 Newbie Poster

can anybody help me making this program?
i've based my game from this site. http://www.education.com/activity/article/Tick_tack_toe_Added/

hope that someone can help me..

i've been stuck coding that for almost 6hrs but still no progress.

thank you!

jankeifer 0 Newbie Poster

i want something other than tic tac toe. :)

jankeifer 0 Newbie Poster

guys, can you please suggest a 2 player game? any 2 player game as long as the difficulty of coding is at an intermediate level. thanks! :D
hope for some replies soon.