#include<iostream>
using namespace std;
int main() {
char options[3] = {'r', 'p', 's'};
cout << "enter your choise from r, p, s or ! to stop play: ";
char humanChoise;
cin >> humanChoise;
int humanPoints = 0, computerPoints = 0;
while (humanChoise != '!') {
if (humanChoise != 'p' && humanChoise != 's' && humanChoise != 'r' && humanChoise != '!') {
cout << "your choise is wrong try again" << endl;
} else {
char computerChoise;
//for random numbers
srand (time(NULL));
int indx = rand() % 3;
computerChoise = options[indx];
if (humanChoise == computerChoise) {
cout << "tie" << endl;
} else if (humanChoise == 'p') {
if (computerChoise == 'r') {
humanPoints++;
cout << "you win" << endl;
}
if (computerPoints == 's') {
computerPoints++;
cout << "you lose" << endl;
}
} else if (humanChoise == 'r') {
if (computerChoise == 's') {
humanPoints++;
cout << "you win" << endl;
}
if (computerPoints == 'p') {
computerPoints++;
cout << "you lose" << endl;
}
} else if (humanChoise == 's') {
if (computerChoise == 'p') {
humanPoints++;
cout << "you win" << endl;
}
if (computerPoints == 'r') {
computerPoints++;
cout << "you lose" << endl;
}
}
}
cout << "Your points: " << humanPoints << endl;
cout << "Computer points: " << computerPoints << endl;
cout << "enter your choise from r, p, s or ! to stop play: ";
cin >> humanChoise;
}
if (humanPoints >= computerPoints) {
cout << "You win game!!!" << endl;
} else if (humanPoints == computerPoints) {
cout << "tie!!!" << endl;
} else {
cout << "You lose game!!!" << endl;
}
return 0;
}