# How do I make a rock, paper, scissors, program?

+1 vote
answered Nov 16, 2022 by (160 points)
you can use the rand function with time so that every second it generates a random number and then use if else or switch case to determine when it should be rock paper and scissors make sure that the probability of getting any of them is equal for example you can use if the number is divisible by 3 to stone not divisible by 3 to paper divisible by 5 for scissors.
answered Nov 16, 2022 by (66,630 points)

First, you get the logic right:

• There are two players (either two human, or one human, one machine -- or even two machine)
• Both make a random pick of three possible choices: rock, paper, scissors. You can also think of these as numbers: 0, 1, 2
• When the choices are made, comparisons are done:
• If both picked the same, it's a tie
• rock beats scissors
• paper beats rock
• scissors beat paper
• Based on the comparison, a winner is selected

Then you chose a programming language and start implementing the logic. Use input and output functions and conditions to branch your code in the right path.

Here's some pseudo-code for you:

```Choices: { rock, paper, scissors }
print("Rock/Paper/Scissor?")
computerInput = random(Choice)
if (userInput == computerInput)
print("It's a tie!")
else if (userInput > computerInput)
print("You win!")
else
print("Computer win!")```

I hope this helps.

Do your implementation then post any specific questions if you're stuck. Good luck! :)

commented Dec 16, 2022 by (100 points)
it didnt work somthing in line 5 is wrong
commented Dec 17, 2022 by (66,630 points)
It's pseudocode, no programming language would be able to run it. It just gives you a general idea of what needs to be done.

You have to do your own implementation with the desired programming language.