The computer always gives the same input.
For example :example or example2
As in the example, I always choose the rock and the computer always chooses the paper. What should I do to make the computer give a different result?
Probably there is something wrong with the last function but I couldn't find it. Can someone help me please?
enum Move {ROCK = 1, PAPER, SCISSORS}input;
int input, computerInput = 0;
int rock = 1;
int paper = 2;
int scissors = 3;
int computerPoint = 0, userPoint = 0;
printf(" ###### Welcome to Rock-Paper-Scissors Game ###### \n");
printf(" ### Rules: \n ### Press 1 for Rock \n ### Press 2 for Paper \n ### Press 3 for Scissors \n ### First one to reach 3 points will win. \n");
printf("Input your move : ");
scanf("%d", &input);
while(input < 1 || input > 3)
{
printf("Your input must be 1, 2 or 3 \n");
printf("Input your move : ");
scanf("%d",&input);
}
while(input == computerInput)
{
printf("It's draw. \n");
printf("Your Point is %d and Computer's point is %d \n",userPoint, computerPoint);
printf("Input your move : ");
scanf("%d",&input);
}
while(input != computerInput && userPoint < 3 && computerPoint < 3){
switch (input)
{
case ROCK:
if(computerInput == 2){
printf("You picked Rock. Computer picked Paper. Computer got 1 point(s). \n");
computerPoint++;
}
else if(computerInput == 3){
printf("You picked Rock. Computer picked Scissors. You got 1 point(s). \n");
userPoint++;
}
break;
case PAPER:
if(computerInput == 1){
printf("You picked Paper. Computer picked Rock. You got 1 point(s). \n");
userPoint++;
}else if(computerInput == 3){
printf("You picked Paper. Computer picked Scissors. Computer got 1 point(s). \n");
computerPoint++;
}
break;
case SCISSORS:
if(computerInput == 1){
printf("You picked Scissors. Computer picked Rock. Computer got 1 point(s). \n");
computerPoint++;
}else if(computerInput == 2){
printf("You picked Scissors. Computer picked Paper. You got 1 point(s). \n");
userPoint++;
}
break;
return 0;
}
if(computerPoint == 3){
printf("Your Point is %d and Computer's point is %d \n",userPoint, computerPoint);
printf("\n!!Computer won the game!!");
return 0;
}
if(userPoint == 3){
printf("Your Point is %d and Computer's point is %d \n",userPoint, computerPoint);
printf("\n!!You won the game!!");
return 0;
}
printf("Your Point is %d and Computer's point is %d \n",userPoint, computerPoint);
printf("Input your move : ");
scanf("%d",&input);
}
return 0;
enum Move getRandomMove(){
int computerInput;
srand(time(NULL));
computerInput = 1 + rand() %3;
return computerInput;
}