Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cctype>
- using namespace std;
- // function prototypes
- void update_score( char p1_move, char p2_move, int &p1_score, int &p2_score );
- char all_d();
- char all_c();
- char tit_for_tat( char opponentsLastMove );
- int main()
- {
- int score = 0;
- int p1_score, p2_score;
- char userinput, computermove;
- bool more = true;
- while ( more ) {
- cout << "enter C to cooperate, D to defect, Q to quit\n";
- cin >> userinput;
- cout << "Your move = " << userinput << " Computer move = " << computermove <<endl;
- cout << "Your score = " << userinput << " Computer move = " << computermove <<endl;
- computermove = all_d();
- //if (userinput == 'q') {more = true;}
- //else if (more = false);
- if ( userinput == 'q' ) {
- more = false;
- };
- //more = true;;
- //update_score( userinput);
- int p1;
- else if (userinput=='c') { p1 = 0;};
- else if ( userinput=='d') {p1 = 1;};
- } // end of while()
- cout << "game over!\n";
- } // end of main()
- char all_d() {
- return 'D';
- }
- char all_c() {
- return 'C';
- }
- //char tit_for_tat( char opponentsLastMove) {
- //while ( more ) {
- // cout << "enter C to cooperate, D to defect, Q to quit\n";
- //cin >> userinput;
- //cout << "Your move = " << userinput << " Computer move = " << computermove <<endl;
- //cout << " Your score " << update_score() << " Computer move = " << computermove << endl;
- //computermove = opponentsLastMove;
- //opponentsLastMove = '';
- //if (userinput = 'q') {more = true;}
- //else (more = false);
- //more = true;;
- //update_score( userinput);
- // if (p1_move = 'c') { &p1_score = 0};
- // else if (p2_move = 'd') {&p1_score = 1};
- //}
- //}
- //}
Add Comment
Please, Sign In to add comment