// G. Hagopian--PPP4 exercise 10

/*
10. Write a program that plays the game “Rock, Paper, Scissors.” If you are
not familiar with the game do some research (e.g., on the web using Google). 
Research is a common task for programmers. Use a switch-statement to solve 
this exercise. Also, the machine should give random answers (i.e., select 
the next rock, paper, or scissors randomly). Real randomness is too hard 
to provide just now, so just build a vector with a sequence of values to 
be used as “the next value.” If you build the vector into the program, it 
will always play the same game, so maybe you should let the user enter 
some values. Try variations to make it less easy for the user to guess 
which move the machine will make next.
*/

#include <iostream>
#include <cstdlib>
#include <ctime>
#include <vector>
using namespace std;

int main() {
	srand(unsigned(time(0)));
	vector<int> rps(3);
	int player1{}, player2{};
	for (int i = 0; i < 1000000; ++i) {
		player1 = rand() % 3;
		player2 = rand() %3;
		switch(player1) {
		case 0: // rock
			//rps[0] += (player2 == 1);
			if (player2 == 1) ++rps[1];
			if (player2 == 2) ++rps[0];
			break;
		case 1: //paper
			if (player2 == 2) ++rps[2];
			if (player2 == 0) ++rps[1];
			break;
		case 2: //scissors
			if (player2 == 0) ++rps[0];
			if (player2 == 1) ++rps[2];
			break;
		}
	}
	cout << "rock won " << rps[0] << " times,\n"
		<< "paper won " << rps[1] << " times, and \n"
		<< "scissors won " << rps[2] << " times.";
}