Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <windows.h>
- #include <fstream>
- #include <string>
- using namespace std;
- int main()
- {
- string answer;
- string name;
- float playerscore = 0;
- float AIscore = 0;
- int playerpick;
- int AIpick;
- cout << "Welcome to Rock Paper Scissors!" << endl;
- Sleep(2000);
- cout<< "I don't know your name yet. "<<endl;
- Sleep(1000);
- cout << "What's your name?" << endl;
- cin >> name;
- cout << "Hey, " << name << ". I'm Benjamin's AI." << endl;
- Sleep(2000);
- cout << "Do you want to play Rock Paper Scissors?" << endl << "1: Of course!" << endl << "0: Why would I want to play Rock Paper Scissors? It's a boring game." << endl;
- cin >> answer;
- if (answer == "1") {
- cout << "Great! I love Rock Paper Scissors. Let's play!" << endl;
- Sleep(2000);
- AIpick = 2;
- while (true) {
- cout << "Pick:" << endl << "1: Rock" << endl << "2: Paper" << endl << "3: Scissors" << endl << "So what'll it be?" << endl;
- cin >> playerpick;
- cout << endl;
- switch(playerpick) {
- case 1: if (AIpick == 1) {
- cout << "Tie! We both picked Rock!";
- playerscore += 0.5;
- AIscore += 0.5;
- } else if (AIpick == 2) {
- cout << "I won that time! I picked Paper!";
- AIscore++;
- } else {
- cout << "You got me! I picked Scissors!";
- playerscore++;
- }
- AIpick = 2;
- break;
- case 2: if (AIpick == 2) {
- cout << "Tie! We both picked Paper!";
- playerscore += 0.5;
- AIscore += 0.5;
- } else if (AIpick == 3) {
- cout << "Got you! My pick was Scissors.";
- AIscore++;
- } else {
- cout << "Great job! You won that round! I shouldn't have picked Rock...";
- playerscore++;
- }
- AIpick = 3;
- break;
- case 3: if (AIpick == 3) {
- cout << "Tie! We both picked Scissors!";
- playerscore += 0.5;
- AIscore += 0.5;
- } else if (AIpick == 2) {
- cout << "Whoops! I meant to pick Rock... Oh well, you won that time! I picked Paper.";
- playerscore++;
- } else {
- cout << "Better luck next time! I picked Rock!";
- AIscore++;
- }
- AIpick = 1;
- break;
- default:
- cout << "You didn't pick a valid choice. I assume you cheated, and therefore I got that point.";
- AIscore++;
- }
- cout << endl << "Score: " << endl << name << " " << playerscore << " - " << AIscore << " " << "Benjamin's AI" << endl;
- if (playerscore < AIscore) {
- cout << "I'm winning! You have your work cut out for you to catch up! Good luck!" << endl;
- } else if (AIscore < playerscore) {
- cout << "You're winning! Keep it up!" << endl;
- } else {
- cout << "Looks like we're tied! You could cut the tension with a butter knife!" << endl;
- }
- cout << "Want to keep playing?" << endl << "1: Yes" << endl << "0: No" << endl;
- cin >> answer;
- if (answer == "1") {
- cout << "Great!" << endl;
- } else {
- if (playerscore > AIscore) {
- cout << "You won! Great Job!" << endl;
- system("PAUSE");
- break;
- } else if (AIscore > playerscore) {
- cout << "I won! Better luck next time!" << endl;
- system("PAUSE");
- break;
- } else {
- cout << "It was a tie! Better keep practicing..." << endl;
- system("PAUSE");
- break;
- }
- }
- }
- } else if (answer == "0") {
- cout << "Oh well... Can we still be friends?"<< endl << "1: Of course!" << endl << "0: Why would I want to be friends with a computer? No." << endl;
- cin >> answer;
- if (answer == "1") {
- cout << "Thanks! Hopefully I'll see you again sometime soon!" << endl;
- system("PAUSE");
- } else {
- cout << "You're so mean. Bye." << endl;
- system("PAUSE");
- }
- } else {
- cout << "I couldn't understand you. I assume that you don't want to play. ";
- Sleep(1000);
- cout << "Bye!" << endl;
- system("PAUSE");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement