C program:
Your task is to write a program which asks the user for a move (Rock, Paperor Scissors) and then, based on the user’s move, chooses a response (Rock, Paper or Scissors). This process continues until the user decides to exit the game.
If the program “knew” the rules of the game, is would be trivial to make the program choose Paper when the user plays Rock, and Scissors when the user plays Paper, etc. Instead, your program should play randomly at first, and change its play based on previous games, through reinforcement learning.
After every game, the program should output the user’s move, the computer’s move, the outcome (win / draw), and the probability of the computer’s move.
Main.c
#include <stdio.h>
#include <stdlib.h>
#define LENGTH 3
int randomization(double *ptr, int num)
{
double dbl = rand() / (RAND_MAX + 1.0);
int x;
for (x = 0; x < num - 1 && (dbl -= ptr[x]) >= 0; x++);
return x;
}
int main()
{
int u_input, comp_input;
int arr[] = {0, 0, 0};
const char *arr1[] = { "Rock", "Paper", "Scissors" };
char str[2];
const char *wins[] = { "We tied.", "AI wins.", "You win." };
double ptr[LENGTH] = { 1./3, 1./3, 1./3 };
while (1) {
comp_input = randomization(ptr,LENGTH);
printf("\nYour choice [1-3]:\n"
" 1. Rock\n 2. Paper\n 3. Scissors\n> ");
if (!scanf("%d", &u_input)) {
scanf("%1s", str);
if (*str == 'q') {
printf("Your choices [rock : %d , paper : %d , scissors %d] ",arr[0],arr[1], arr[2]);
return 0;
}
continue;
}
u_input --;
if (u_input > 2 || u_input < 0) {
printf("invalid choice; again\num");
continue;
}
printf("You choose %s; I choose %s. %s\n",
arr1[u_input], arr1[comp_input],
wins[(comp_input - u_input + 3) % 3]);
arr[u_input]++;
}
}
Output:

C program: Your task is to write a program which asks the user for a move...
(c++ only)Write a program that lets the user play the game of Rock, Paper, Scissors against the computer. The program should work as follows: When the program begins, the user enters his or her choice of “rock”, “paper”, or “scissors” at the keyboard using a menu in a function, userChoice, that returns a character. Next, there should be a function, computerChoice, that generates the computer’s play. A random number in the range of 1 through 3 is generated. If the...
IN JAVA. Write a program that lets the user play the game of Rock, Paper, Scissors against the computer. The program should work as follows. When the program begins, a random number in the range of 1 through 3 is generated. If the number is 1, then the computer has chosen rock. If the number is 2, then the computer has chosen paper. If the number is 3, then the computer has chosen scissors. Don’t display the computer’s choice yet....
(Java) Write a program that lets the user play the game of Rock, Paper, Scissors against the computer. The program should work as follows. When the program begins, a random number in the range of 1 through 3 is generated. If the number is 1, then the computer has chosen rock. If the number is 2, then the computer has chosen paper. If the number is 3, then the computer has chosen scissors. Don’t display the computer’s choice yet. The...
Write this program using C++ , (Rock, Paper, Scissors Game – Page 373) This programming assignment is from the textbook with some slight modifications and clarifications. Here is what I am going to except from you. Your program should include at least the following functions: getComputerGuess(): this function should return a random value generated by the computer using rand function (read more about random numbers in Chapter 3 pages 126 – 128). getUsersChoice(): this function will ask the user to...
C++ Part 2: Rock Paper Scissors Game Write a program that lets the user play this game against the computer. The program should work as follows: When the program begins, a random number between 1 and 3 is generated. If the number is 1, the computer has chosen rock. If the number is 2, the computer has chosen paper. If the number is 3, the computer has chosen scissors. Don't display the computer's choice yet. Use a menu to display...
In JAVA Chapter 5Assignment(Rock, Paper, Scissors)–20pointsYour goal is towrite a program that lets the user play the game of Rock, Paper, Scissors against the computer.Your program should have the following: •Make the name of the project RockPaperScissors•Write a method that generates a random number in the range of 1 through 3. The randomly generated number will determine if the computer chooses rock, paper, or scissors. If the number is 1, then the computer has chosen rock. If the number is...
Write a Python program (using python 3.7.2) that lets the user play the game of Rock, Paper, Scissors against the computer. The program should work as follows. 1. When the program begins, a random number in the range of 1 through 3 is generated. If the number is 1, then the computer has chosen rock. If the number is 2, then the computer has chosen paper. If the number is 3, then the computer has chosen scissors. (Don’t display the...
Write C++ program, program should include at least the following functions: getComputerGuess(): this function should return a random value generated by the computer using rand function ( read more about random numbers in Chapter 3 pages 126 – 128 ). getUsersChoice(): this function will ask the user to enter a choice using a menu. It then returns the user’s selected choice. Here is the menu: “1) Rock 2)Paper 3) Scissors 4) Quit” You should allow the game to...
java pls
Rock Paper Scissors Lizard Spock Rock Paper Scissors Lizard Spock is a variation of the common game Rock Paper Scissors that is often used to pass time (or sometimes to make decisions.) The rules of the game are outlined below: • • Scissors cuts Paper Paper covers Rock Rock crushes Lizard Lizard poisons Spock Spock smashes Scissors Scissors decapitates Lizard Lizard eats Paper Paper disproves Spock Spock vaporizes Rock Rock crushes Scissors Write a program that simulates the...
Write a C# program that allows one user to play Rock-Paper-Scissors with computer. The user will pick a move (Rock Paper Scissors) from 3 radio buttons and click the play button to play the game. The application will use random number generator to pick a move for the computer. Then, the application display the computer's move and also display whether you won or lost the game, or the game is tie if both moves are the same. The application must...