how to remake random numbers in C++
I am trying to make a game of Rock Paper Scissors that after complied will be replayable but the random numbers I use for the starting game to pick the A.I.'s choice are reused for every following game. Can someone please explain why and how to fix it. my code: #include <iostream> #include <cstdlib> //used for rand() #include <ctime> //used for srand(time()) using namespace std; /* How to play 1.) hit run 2.) type rock, paper, or scissors 3.) hit sumbit 4.) read the output for the result WARNING!!! do NOT capitalize rock, paper, or scissors */ int main() { srand(time(0)); //uses systems time to make random number string player; char playing ='y'; int comp = 1 + (rand() % 3); //picks a randome number between 0 and 2 based off srand and adds 1 while (playing == 'y') { cout << "Rock...Paper...Scissors...1...2...3...Shoot" << endl; cin >> player; //players choice if (player == "rock") { if (comp == 1) { cout << "Rock! It's a tie" <<endl; } else if (comp == 2) { cout << "paper! I win!" <<endl; } else { cout << "Scissors! You win!" <<endl; } } else if (player == "paper") { if (comp == 1) { cout << "Rock! You win!" <<endl; } else if (comp == 2) { cout << "paper! It's a tie!" <<endl; } else { cout << "Scissors! I win!" <<endl; } } else if (player == "scissors") { if (comp == 1) { cout << "Rock! I win" <<endl; } else if (comp == 2) { cout << "paper! You win!" <<endl; } else { cout << "Scissors! It's a tie!" <<endl; } } else { cout << "invalid choice";