elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: (TUTORIAL) Aprende a emular Sentinel Dongle By Yapis


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación C/C++ (Moderadores: Eternal Idol, Littlehorse, K-YreX)
| | |-+  Juego Gato Inteligente.
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Juego Gato Inteligente.  (Leído 7,563 veces)
xcoverdalex

Desconectado Desconectado

Mensajes: 4


Coverdale


Ver Perfil
Juego Gato Inteligente.
« en: 1 Septiembre 2010, 16:02 pm »

hola quiero ver si alguien me puede ayudar..
eh casi terminado con mi juego de gato pero el profesor me pido que guarde el score de victorias y/o perdidas, eh logrado que cree el archivo pero no escribe sobre el..
alguien puede ayudarme u orientarme a termianar el codigo porfavor...
de esto depende mi calificacion:S




Código
  1. #include <iostream>
  2. #include <string>
  3. #include <cctype>
  4. #include<fstream>
  5. #include<time.h>
  6. #include <stdlib.h>
  7. #include <windows.h>
  8. using namespace std;
  9. using std::tolower;
  10.  
  11.  
  12. class tttboard
  13. {
  14. private:
  15.    char board[3][3];
  16. public:
  17.    static const char NOBODY = ' ', PLAYER1 = 'X', PLAYER2 = 'O';
  18.  
  19.    tttboard();
  20.    void init_board();
  21.    void display();
  22.    void set(int x, int y, char c);
  23.    char get(int x, int y) const;
  24.  
  25.  
  26. };
  27.  
  28. tttboard::tttboard()
  29.                     {
  30.                        init_board();
  31.                     }
  32.  
  33.  
  34.  
  35. void tttboard::init_board()
  36. {
  37.    for(int x = 0; x < 3; x ++)
  38.                                {
  39.                                for(int y = 0; y < 3; y ++)
  40.                                                 {
  41.                                                  board[x][y] = NOBODY;
  42.                                                 }      
  43.                                 }
  44. }
  45.  
  46. void tttboard::display()
  47. {
  48.     system("cls");
  49.    cout << endl;
  50.  
  51.    for(int y = 0; y < 3; y ++)
  52.  
  53.    {
  54.  
  55.                     for(int x = 0; x < 3; x ++)
  56.                             {
  57.  
  58.                                 cout << board[x][y];
  59.                                 if(x < 2) cout << '|';
  60.                             }
  61.  
  62.        cout << endl;
  63.        if(y < 2) cout << "-+-+-\n";
  64.    }
  65. }
  66.  
  67. void tttboard::set(int x, int y, char c)
  68.     {
  69.  
  70.    board[x][y] = c;
  71.  
  72.    }
  73.  
  74.  
  75. char tttboard::get(int x, int y) const
  76. {
  77.  
  78.    return board[x][y];
  79.  
  80. }
  81.  
  82.  
  83. class opponent
  84. {
  85.  
  86. //private:  
  87. //      
  88. //       string name;
  89.  
  90. protected:
  91.  
  92.    char c;
  93.    void set_name(string name, char c);
  94. public:
  95.     string name;  
  96.    virtual void move(const tttboard &board, int &xpos, int &ypos) = 0;
  97.    string get_name()
  98.    {
  99.            return name;
  100.    }
  101. };
  102.  
  103.  
  104. void opponent::set_name(string name, char c)
  105. {
  106.    this->name = name + " (" + c + ")";
  107.    this->c = c;
  108. }
  109.  
  110. class aiopponent : public opponent
  111. {
  112. private:
  113.    int two(char c, char x, char y, char z);
  114. public:
  115.    aiopponent(string name, char c);
  116.    void move(const tttboard &board, int &xpos, int &ypos);
  117. };
  118.  
  119. aiopponent::aiopponent(string name, char c)
  120. {
  121.    set_name(name, c);
  122. }
  123.  
  124.  
  125. int aiopponent::two(char c, char x, char y, char z)
  126. {
  127.    if(x == c && y == c && z == tttboard::NOBODY) return 3;
  128.    if(x == c && y == tttboard::NOBODY && z == c) return 2;
  129.    if(x == tttboard::NOBODY && y == c && z == c) return 1;
  130.  
  131.    return 0;
  132. }
  133.  
  134. void aiopponent::move(const tttboard &board, int &xpos, int &ypos)
  135. {
  136.    int r;
  137.    char ic; // = (c == tttboard::PLAYER1 ? tttboard::PLAYER2 : tttboard::PLAYER1);
  138.  
  139.    if(c == tttboard::PLAYER1) ic = tttboard::PLAYER2;
  140.    else ic = tttboard::PLAYER1;
  141.  
  142.    /* Busca lugares para ganar */
  143.    for(int x = 0; x < 3; x ++)
  144.    {
  145.        if((r = two(c, board.get(0, x), board.get(1, x), board.get(2, x))))
  146.        {
  147.            ypos = x, xpos = r-1;
  148.            return;
  149.        }
  150.  
  151.        if((r = two(c, board.get(x, 0), board.get(x, 1), board.get(x, 2))))
  152.        {
  153.            xpos = x, ypos = r-1;
  154.            return;
  155.        }
  156.    }
  157.  
  158.    if((r = two(c, board.get(0, 0), board.get(1, 1), board.get(2, 2))))
  159.    {
  160.        xpos = r-1, ypos = r-1;
  161.        return;
  162.    }
  163.  
  164.    if((r = two(c, board.get(2, 0), board.get(1, 1), board.get(0, 2))))
  165.    {
  166.        xpos = 3-r, ypos = r-1;
  167.        return;
  168.    }
  169.  
  170.    /* Blokea lugares perdidos */
  171.    for(int x = 0; x < 3; x ++)
  172.    {
  173.        if((r = two(ic, board.get(0, x), board.get(1, x), board.get(2, x))))
  174.        {
  175.            ypos = x, xpos = r-1;
  176.            return;
  177.        }
  178.  
  179.    if((r = two(ic, board.get(x, 0), board.get(x, 1), board.get(x, 2))))
  180.        {
  181.            xpos = x, ypos = r-1;
  182.            return;
  183.        }
  184.    }
  185.  
  186.    if((r = two(ic, board.get(0, 0), board.get(1, 1), board.get(2, 2))))
  187.    {
  188.        xpos = r-1, ypos = r-1;
  189.        return;
  190.    }
  191.  
  192.    if((r = two(ic, board.get(2, 0), board.get(1, 1), board.get(0, 2))))
  193.    {
  194.        xpos = 3-r, ypos = r-1;
  195.        return;
  196.    }
  197.  
  198.    /*Pone la ficha en el centro si esta disponible*/                                        
  199.  
  200.  
  201.   if(board.get(1, 1) == tttboard::NOBODY)
  202.    {
  203.        xpos = 1, ypos = 1;
  204.        return;
  205.    }
  206.  
  207.  
  208.    /* Toma la esquina si esta no esta ocupada aun */
  209.  
  210.    if(board.get(0, 0) != c && board.get(2, 0) != c
  211.        && board.get(0, 2) != c && board.get(2, 2) != c)
  212.        {
  213.  
  214.  
  215.        if(board.get(0, 0) == tttboard::NOBODY)
  216.  
  217.        {
  218.            xpos = 0, ypos = 0;
  219.            return;
  220.        }
  221.  
  222.    if(board.get(2, 0) == tttboard::NOBODY)
  223.        {
  224.            xpos = 2, ypos = 0;
  225.            return;
  226.        }
  227.        if(board.get(0, 2) == tttboard::NOBODY)
  228.        {
  229.            xpos = 0, ypos = 2;
  230.            return;
  231.        }
  232.        if(board.get(2, 2) == tttboard::NOBODY)
  233.        {
  234.            xpos = 2, ypos = 2;
  235.            return;
  236.        }
  237.       }
  238.  
  239.  
  240.    for(int x = 0; x < 3; x ++) {
  241.        for(int y = 0; y < 3; y ++) {
  242.            if(board.get(x, y) == tttboard::NOBODY) {
  243.                xpos = x, ypos = y;
  244.                return;
  245.            }
  246.        }
  247.    }
  248. }
  249.  
  250.  
  251. class humanopponent : public opponent
  252. {
  253.  
  254. public:
  255.    int v,p,e;  
  256.    humanopponent(char c);
  257.    void move(const tttboard &board, int &xpos, int &ypos);
  258.    void victory()
  259.    {
  260.         v+=1;
  261.    }
  262.    void lost()
  263.    {
  264.         p+=1;
  265.    }
  266.    void tie()
  267.    {
  268.         e+=1;
  269.    }
  270.  
  271.    int getvictory()
  272.    {
  273.        return v;
  274.    }
  275.    int getlost()
  276.    {
  277.        return p;
  278.    }
  279.    int gettie()
  280.    {
  281.        return e;
  282.    }
  283.    void print()
  284.    {
  285.         cout<<"Victorias "<<v<<endl;
  286.         cout<<"Perdidas "<<p<<endl;
  287.         cout<<"Empates "<<e<<endl;
  288.    }
  289.    void get()
  290.    {
  291.         cout<<name;
  292.         cout<<"Victorias "<<getvictory<<endl;
  293.         cout<<"Perdidas "<<getlost<<endl;
  294.         cout<<"Empates "<<gettie;
  295.    }
  296.  
  297. };
  298.  
  299.  
  300. humanopponent::humanopponent(char c)
  301. {                              
  302.    cout << "\nIngresa Tu Nombre: ";
  303.    string name;
  304.    cin >> name;
  305.    set_name(name, c);
  306.    v=0;
  307.    p=0;
  308.    e=0;
  309.  
  310. }
  311.  
  312. void humanopponent::move(const tttboard &board, int &xpos, int &ypos)
  313. {
  314.  
  315.    for(;;)
  316.  
  317.   {
  318.        cout << "Ingresa Numero De Columna (1-3): ";
  319.        while(!(cin >> xpos) || xpos <= 0 || xpos > 3)
  320.        {
  321.            // !!!
  322.            cin.clear();
  323.            cout << ": ";
  324.        }
  325.  
  326.        cout << "Ingresa Numero De Fila (1-3): ";
  327.        while(!(cin >> ypos) || ypos <= 0 || ypos > 3)
  328.  
  329.        {
  330.            cin.clear();
  331.            cout << ": ";
  332.        }
  333.  
  334.        xpos --, ypos --;
  335.  
  336.        if(board.get(xpos, ypos) != tttboard::NOBODY)
  337.  
  338.        {
  339.            cout << "Ya Esta Ocupado \n";
  340.            continue;
  341.        }
  342.  
  343.        break;
  344.    }
  345. }
  346.  
  347. class ttt : public opponent
  348.  
  349. {
  350.  
  351. private:
  352.  
  353.    tttboard board;
  354.    opponent *player[2];
  355.  
  356.    int turn;
  357.  
  358. public:
  359.  
  360.    ttt();
  361.    ~ttt();
  362.    bool new_game();
  363.    void play_game();
  364.    int game_done();
  365.    void move(const tttboard &board, int &xpos, int &ypos)
  366.    {
  367.    }
  368. };
  369.  
  370.  
  371. ttt::ttt() : turn(0)
  372. {
  373.    player[0] = player[1] = NULL;
  374. }
  375.  
  376. ttt::~ttt()
  377. {
  378.    for(int x = 0; x < 2; x ++)
  379.    {
  380.        if(player[x]) delete player[x];
  381.    }
  382. }
  383.  
  384. bool ttt::new_game()
  385. {
  386.    cout << "\nJuego Nuevo\nJugador  #1 ([A]I/[H]uman/[Q]uit): ";
  387.  
  388.    char one;
  389.    for(;;)
  390.    {
  391.        if(!(cin >> one))
  392.        {
  393.            cin.clear();
  394.            continue;
  395.        }
  396.  
  397.        one = tolower(one);
  398.        if(one == 'q') return false;
  399.        if(one == 'a' || one == 'h') break;
  400.    }
  401.  
  402.    cout << "Jugador #2 ([A]I/[H]uman/[Q]uit): ";
  403.  
  404.    char two;
  405.    for(;;)
  406.    {
  407.        if(!(cin >> two))
  408.        {
  409.            cin.clear();
  410.            continue;
  411.        }
  412.  
  413.        two = tolower(two);
  414.        if(two == 'q') return false;
  415.        if(two == 'a' || two == 'h') break;
  416.    }
  417.  
  418.    if(one == 'h') player[0] = new humanopponent(tttboard::PLAYER1);
  419.    else
  420.    {
  421.        player[0] = new aiopponent("AI for player #1", tttboard::PLAYER1);
  422.    }
  423.  
  424.    if(two == 'h') player[1] = new humanopponent(tttboard::PLAYER2);
  425.    else
  426.    {
  427.        player[1] = new aiopponent("AI for player #2", tttboard::PLAYER2);
  428.    }
  429.  
  430.    turn = 0;
  431.    play_game();
  432.  
  433.    return true;
  434. }
  435.  
  436. void ttt::play_game()
  437. {
  438.    int v,p,e;
  439.    int x, y, won;
  440.    char again;
  441.  
  442.    do
  443.     {
  444.        board.init_board();
  445.  
  446.        while(!(won = game_done()))
  447.        {
  448.            board.display();
  449.            cout << player[turn]->get_name() << endl;
  450.            player[turn]->move(board, x, y);
  451.            cout << player[turn]->get_name() << " picked position "
  452.                << x+1 << ", " << y+1 << endl;
  453.            board.set(x, y, turn ? tttboard::PLAYER2 : tttboard::PLAYER1);
  454.            turn = !turn;
  455.        }
  456.  
  457.        board.display();
  458.        cout << "Perdiste,La Primicia Es Mia..";
  459.  
  460.        switch(won) // aqui tengo el problema, para mandar llamar las variables.//
  461.        {
  462.        case -1: cout << "Bueno Fue Empate quieres la revancha?.";break;
  463.        case 1: cout << player[0]->get_name() << "Felicidades Tienes la Primicia!"; break;
  464.        case 2: cout << player[1]->get_name() << "Felicidades Tienes la Primicia!"; break;
  465.  
  466.        }
  467.  
  468.        cout << endl;
  469.        cout << "tic tac toe by Alberto Coverdale\n"<<endl;
  470.        cout << "Quieres jugar de nuevo??";
  471.        ofstream rankFileOut("rank.dat", ios::app);
  472.        rankFileOut<<opponent::get_name();
  473.        rankFileOut.close();  
  474.        cin >> again;
  475.    }
  476.  
  477.     while(tolower(again) == 'y');
  478. }
  479.  
  480. int ttt::game_done()
  481. {
  482.    int n, flag = 0;
  483.  
  484.    for(int x = 0; x < 3 && !flag; x ++)
  485.    {
  486.        for(int y = 0; y < 3 && !flag; y ++)
  487.        {
  488.            if(board.get(x, y) == tttboard::NOBODY) flag = 1;
  489.        }
  490.    }
  491.  
  492.    if(!flag) return -1;
  493.  
  494.    for(int x = 0; x < 3; x ++)
  495.    {
  496.        if((n = board.get(x, 0)) != tttboard::NOBODY)
  497.        {
  498.            if(n == board.get(x, 1) && n == board.get(x, 2))
  499.            {
  500.                return n == tttboard::PLAYER1 ? 1 : 2;
  501.            }
  502.        }
  503.    }
  504.  
  505.    for(int y = 0; y < 3; y ++)
  506.    {
  507.        if((n = board.get(0, y)) != tttboard::NOBODY)
  508.        {
  509.            if(n == board.get(1, y) && n == board.get(2, y))
  510.            {
  511.                return n == tttboard::PLAYER1 ? 1 : 2;
  512.            }
  513.        }
  514.    }
  515.  
  516.    if((n = board.get(0, 0)) != tttboard::NOBODY)
  517.    {
  518.        if(n == board.get(1, 1) && n == board.get(2, 2))
  519.        {
  520.            return n == tttboard::PLAYER1 ? 1 : 2;
  521.        }
  522.    }
  523.  
  524.    if((n = board.get(2, 0)) != tttboard::NOBODY)
  525.    {
  526.        if(n == board.get(1, 1) && n == board.get(0, 2))
  527.        {
  528.            return n == tttboard::PLAYER1 ? 1 : 2;
  529.        }
  530.    }
  531.  
  532.    return 0;
  533. }
  534.  
  535.  
  536.  
  537.  
  538.  
  539. int main()
  540. {      
  541.    int trn=1;  
  542.     int i=1;
  543.     char ch='y';    
  544.     int winner=1;    
  545.     int ctrl1,ctrl2;  
  546.     int ctr=0;
  547.     int check_for_tie;
  548.     char begin,Yeah, inst, jum, choice;
  549.     int dec;    
  550.  
  551.  
  552.  
  553.  
  554.  
  555.     cout<<"Este Juego fue creado por Alberto Coverdale"<<endl;
  556.     cout<<"Desea Comenzar el juego??"<<endl;
  557.     cout<<"[Y][N]"<<endl;
  558.     cin>>Yeah;
  559.     if (Yeah=='Y' ||Yeah=='y')
  560.     {
  561.         cout<<"\n\n\n\n\n";
  562.  
  563.         cout<<"\n**     **  ********  *******";
  564.         cout<<"\n**     **  ********  ********";
  565.         cout<<"\n**     **  **    **  **    **";
  566.         cout<<"\n**  *  **  ********  *******";
  567.         cout<<"\n** *** **  ********  *******";
  568.         cout<<"\n***   ***  **    **  **    **";
  569.         cout<<"\n**     **  **    **  **    **";
  570.         cout<<"\n\n\n";
  571.         for(ctrl1 = 0; ctrl1 < 2000; ctrl1++)
  572.         {
  573.          for(ctrl2 = 0; ctrl2 < 20000; ctrl2++)
  574.           {
  575.           }
  576.         }        
  577.         cout<<"\n\t\t********  ********";
  578.         cout<<"\n\t\t********  ********";
  579.         cout<<"\n\t\t**    **  **";
  580.         cout<<"\n\t\t**    **  *****";
  581.         cout<<"\n\t\t**    **  *****";
  582.         cout<<"\n\t\t********  **";
  583.         cout<<"\n\t\t********  **";
  584.         cout<<"\n\n\n";
  585.         for(ctrl1 = 0; ctrl1 < 2000; ctrl1++)
  586.         {
  587.          for(ctrl2 = 0; ctrl2 < 20000; ctrl2++)
  588.           {
  589.           }
  590.         }
  591.         cout<<"\n\t\t\t********  **    **  ********";
  592.         cout<<"\n\t\t\t********  **    **  ********";
  593.         cout<<"\n\t\t\t   **     ********  **";
  594.         cout<<"\n\t\t\t   **     ********  *****";
  595.         cout<<"\n\t\t\t   **     **    **  **";
  596.         cout<<"\n\t\t\t   **     **    **  ********";
  597.         cout<<"\n\t\t\t   **     **    **  ********";
  598.         cout<<"\n\n\n";
  599.         for(ctrl1 = 0; ctrl1 < 2000; ctrl1++)
  600.         {
  601.          for(ctrl2 = 0; ctrl2 < 20000; ctrl2++)
  602.           {
  603.           }
  604.         }
  605.         cout<<"\n      **         ********    ****       ****   ********  ****          *******";
  606.         cout<<"\n      **         ********    ** **     ** **   ********  ****          ********";
  607.         cout<<"\n      **         **    **    **  **   **  **   **    **  ****          **";
  608.         cout<<"\n      **         ********    **   ** **   **   ********  ****             **";
  609.         cout<<"\n      **         ********    **    ***    **   ********  ****                **";
  610.         cout<<"\n *************   **    **    **           **   **    **  ************   ********";
  611.         cout<<"\n *************   **    **    **           **   **    **  ************   ********";
  612.  
  613.     }
  614.         else
  615.         {
  616.             return 0;
  617.         }                
  618.  
  619.  
  620.  
  621.  
  622. cout<<"\n\n\n\n\n\t\t La Guerra De Los Tamales.\n\n\t\t"<<endl;
  623. cout<<" Este juego es sobre un hombre que vende tamales para alimentar a su familia"<<endl;
  624. cout<<" Estas dispuesto a jugarte la vida por un tamal de chicharron?"<<endl;
  625. cout<<" Aceptaras el desafio por alimentar a tu familia?"<<endl;
  626. cout<<" Qieres Saber la historia de este juego? [Y/N]"<<endl;
  627. cin>>  inst;
  628.  
  629. if (inst=='Y' ||inst=='y')
  630. {
  631.               cout<<"Hace tiempo existio un hombre llamado Elias Diaz"<<endl;
  632.               cout<<"Apodado 'El Naco Diaz'"<<endl;
  633.               cout<<"El Naco tenia todo lo que un hombre podia decear..una bonita casa,una hermosa esposa y adorables hijos.."<<endl<<endl;
  634.               cout<<"Pero el destino le dio una mala jugada y perdio casi todo lo que tenia..."<<endl;
  635.               cout<<"El Naco no podia soportar que lo unico que le quedaba su familia muriera de hambre..."<<endl;
  636.               cout<<"Asi que se dispuso a vender el santo grial de la comida del barrio 'Tamales'"<<endl;
  637.               cout<<"Asi fue como El Naco, comenzo su negocio de tamales..pero no contaba con que tendria un rival.."<<endl;
  638.               cout<<"Era un taquero muy famoso en la colonia apodado Don Fito, que no queria que El Naco le robara la clientela"<<endl;
  639.               cout<<"Don Fito,declaro la guerra a El Naco...por la primicia de sus respectivos lugares en el barrio..."<<endl;
  640.               cout<<"Este juego trata sobre eso, el tablero es un mapa del barrio, y para ganar tienes que hacerte de una calle completa..."<<endl;
  641.               cout<<"La idea de este juego es crear una linea perpendicular o paralela para ganar el juego"<<endl;
  642.               cout<<"Las [x] corresponde Al Naco Diaz."<<endl;
  643.               cout<<"Las [O] corresponden Don Fito."<<endl;
  644.               cout<<"Es tu Desicion elegir el personaje que mas te guste para tratar de ganar.."<<endl;
  645.  
  646.     for(ctrl1 = 0; ctrl1 < 2000; ctrl1++)
  647.         {
  648.          for(ctrl2 = 0; ctrl2 < 20000; ctrl2++)
  649.           {
  650.           }
  651.         }
  652.     cout<<"Este tablero muestra la colonia donde estan ubicados nuestros hombres"<<endl<<endl<<endl;
  653.  
  654.     cout << "\n"<< 0 << " | " << 1 << " | " << 2 << endl;
  655.     cout<< " ---------" << endl;
  656.     cout<< 3 << " | " << 4 << " | " << 5 << endl;
  657.     cout<< " ---------" << endl;
  658.     cout<< 6 << " | " << 7 << " | " << 8 << endl;
  659.  
  660.     for(ctrl1 = 0; ctrl1 < 2000; ctrl1++)
  661.         {
  662.          for(ctrl2 = 0; ctrl2 < 20000; ctrl2++)
  663.           {
  664.           }
  665.         }
  666.  
  667.  
  668. cout<<" Este juego se juega de la siguiente manera"<<endl<<endl;
  669. cout<<" Primero elejimos el turno.. quien sera eL Naco y quien Don Fito."<<endl;
  670. cout<<" Puedes jugar como el personajes que elijas dando la opcion que quieres."<<endl;
  671. cout<<" Puedes jugar contra la maquina o contra persona, pero esa sera tu eleccion"<<endl<<endl;
  672. cout<<" El juego se juega por coordenadas..."<<endl;
  673. cout<<" 123.columna y 123.linea"<<endl;
  674. cout<<" Trata de ganar la primicia del barrio... Estas Listo??"<<endl;
  675. cout<<" Comenzar el juego??? [Y/N]";
  676. cin>> jum;
  677.  
  678. if (jum=='Y' ||jum=='y')
  679.  
  680.   {
  681.       ttt tictactoe;
  682.   while(tictactoe.new_game());  
  683.  
  684.   }
  685.  
  686.  
  687. }  
  688. return 0;    
  689.  
  690.  return 0;
  691. }
  692.  
  693.  
  694.  


« Última modificación: 2 Septiembre 2010, 15:03 pm por xcoverdalex » En línea

Aprendiendo a Ser Bueno D:!
Dznp

Desconectado Desconectado

Mensajes: 119


Ver Perfil
Re: Juego Gato Inteligente.
« Respuesta #1 en: 1 Septiembre 2010, 16:14 pm »

Pone el codigo al menos dentro de las etiquetas CODE, o si no de las de C++

[*code=cpp]codigo.[*/code]
así se entiende mejor ;)


En línea

clodan

Desconectado Desconectado

Mensajes: 277



Ver Perfil
Re: Juego Gato Inteligente.
« Respuesta #2 en: 1 Septiembre 2010, 17:35 pm »

probando el code creo qe encontre un pequeño problema... en realidad no entiendo nada de C++ jajaja por eso te digo creo :P

cuando es empate, ya probe 2 veces y me dice:

"Perdiste, La Primicia Es Mia..Bueno Fue Empate quieres la revancha?.
tic tac toe by Alberto Coverdale

Quieres jugar de nuevo??"

Creo qe el perdiste al principio no deberia aparecer no?

salu2!!
En línea

xcoverdalex

Desconectado Desconectado

Mensajes: 4


Coverdale


Ver Perfil
Re: Juego Gato Inteligente.
« Respuesta #3 en: 1 Septiembre 2010, 20:09 pm »

probando el code creo qe encontre un pequeño problema... en realidad no entiendo nada de C++ jajaja por eso te digo creo :P

cuando es empate, ya probe 2 veces y me dice:

"Perdiste, La Primicia Es Mia..Bueno Fue Empate quieres la revancha?.
tic tac toe by Alberto Coverdale

Quieres jugar de nuevo??"

Creo qe el perdiste al principio no deberia aparecer no?

salu2!!

si lo siento! esos son errores mios,
y gracias por intentar ayudarme xD
En línea

Aprendiendo a Ser Bueno D:!
EvilGoblin


Desconectado Desconectado

Mensajes: 2.323


YO NO LA VOTE!


Ver Perfil
Re: Juego Gato Inteligente.
« Respuesta #4 en: 2 Septiembre 2010, 14:44 pm »

Simplemente podrias usar un .txt o .dat

Y crear una struct score {   };  donde guarde las ganas y perdidas y las guarde dentro del archivo.. y luego las recupere cuando quieras leerlas

poniendo una opcion Extra en la pantalla principal donde te muestre cuantas veces ganaste o perdiste

Hiciste todo el juego y no tienes idea de como hacer para guardar el puntaje? =/
En línea

Experimental Serial Lain [Linux User]
xcoverdalex

Desconectado Desconectado

Mensajes: 4


Coverdale


Ver Perfil
Re: Juego Gato Inteligente.
« Respuesta #5 en: 2 Septiembre 2010, 15:00 pm »

Simplemente podrias usar un .txt o .dat

Y crear una struct score {   };  donde guarde las ganas y perdidas y las guarde dentro del archivo.. y luego las recupere cuando quieras leerlas

poniendo una opcion Extra en la pantalla principal donde te muestre cuantas veces ganaste o perdiste

Hiciste todo el juego y no tienes idea de como hacer para guardar el puntaje? =/

eso lo se, aqui el problema esque crea un archivo .dat eh hice los metodos para ganancia, perdida y empate, pero el problema real esque todas las clases tienen herencia, entonces me complique un poco al momento de hacerlo, y ahora necesito orientacion porque estoy un poco perdido, dejame actualizar el codigo.. al que recien modifique.. que es el que crea el archivo ".dat" y comentare la parte donde tengo el problema.. dame un segundo para eso
En línea

Aprendiendo a Ser Bueno D:!
Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Juego Gato
Java
Lain0x 2 9,635 Último mensaje 22 Marzo 2011, 05:43 am
por sapito169
la curiosidad mato al gato, alguna vez fuiste tu el gato?
Foro Libre
flacc 1 2,281 Último mensaje 27 Enero 2012, 15:09 pm
por D4RIO
Juego del gato « 1 2 »
Programación C/C++
m@o_614 13 21,773 Último mensaje 30 Abril 2012, 03:41 am
por s00rk
juego del gato
Java
m@o_614 4 4,889 Último mensaje 8 Mayo 2012, 22:04 pm
por m@o_614
Ayuda con el juego del gato
Programación C/C++
Dieux Rablia 3 3,513 Último mensaje 20 Mayo 2012, 18:59 pm
por Dieux Rablia
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines