Guest User

Untitled

a guest
Jun 20th, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. #include <iostream>
  2. #include <cctype>
  3. using namespace std;
  4. // function prototypes
  5. void update_score( char p1_move, char p2_move, int &p1_score, int &p2_score );
  6. char all_d();
  7. char all_c();
  8. char tit_for_tat( char opponentsLastMove );
  9.  
  10.  
  11. int main()
  12. {
  13. int score = 0;
  14. int p1_score, p2_score;
  15. char userinput, computermove;
  16.  
  17. bool more = true;
  18.  
  19.  
  20. while ( more ) {
  21.  
  22. cout << "enter C to cooperate, D to defect, Q to quit\n";
  23. cin >> userinput;
  24. cout << "Your move = " << userinput << " Computer move = " << computermove <<endl;
  25. cout << "Your score = " << userinput << " Computer move = " << computermove <<endl;
  26. computermove = all_d();
  27.  
  28. //if (userinput == 'q') {more = true;}
  29. //else if (more = false);
  30. if ( userinput == 'q' ) {
  31. more = false;
  32. };
  33. //more = true;;
  34.  
  35. //update_score( userinput);
  36. int p1;
  37. else if (userinput=='c') { p1 = 0;};
  38. else if ( userinput=='d') {p1 = 1;};
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45. } // end of while()
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53. cout << "game over!\n";
  54. } // end of main()
  55.  
  56. char all_d() {
  57. return 'D';
  58. }
  59. char all_c() {
  60. return 'C';
  61. }
  62.  
  63. //char tit_for_tat( char opponentsLastMove) {
  64.  
  65.  
  66.  
  67. //while ( more ) {
  68.  
  69. // cout << "enter C to cooperate, D to defect, Q to quit\n";
  70. //cin >> userinput;
  71. //cout << "Your move = " << userinput << " Computer move = " << computermove <<endl;
  72. //cout << " Your score " << update_score() << " Computer move = " << computermove << endl;
  73.  
  74. //computermove = opponentsLastMove;
  75. //opponentsLastMove = '';
  76.  
  77. //if (userinput = 'q') {more = true;}
  78. //else (more = false);
  79.  
  80. //more = true;;
  81.  
  82. //update_score( userinput);
  83. // if (p1_move = 'c') { &p1_score = 0};
  84. // else if (p2_move = 'd') {&p1_score = 1};
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91. //}
  92.  
  93. //}
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100. //}
Add Comment
Please, Sign In to add comment