Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

How do you write a Rock, Paper, Scissors game using BASIC

weerezweerez Member Posts: 1
I need to figure how to write a BASIC program which can simulate a rock, paper, scissors game using the RND function.

Thanks!

Comments

  • zibadianzibadian Member Posts: 6,349
    : I need to figure how to write a BASIC program which can simulate a
    : rock, paper, scissors game using the RND function.
    :
    : Thanks!

    First you need to assign a number to each of the rock, paper, and scissor. For example:
    Rock = 1
    Paper = 2
    Scissor = 3
    Now you can use an if-then-else statement to check who wins (in pseudocode):
    [code]
    if Player1 = Player2+1 then // Handles Rock-Paper & Paper-Scissor
    Player2 Wins
    else if Player1 = 3 and Player2 = 1 then // Handles Rock-Scissor
    Player2 Wins
    else
    Player1 Wins
    [/code]
    Since these are all based on numbers, instead of descriptions, asking the use for his choice is as simple as asking him to enter 1, 2, or 3. Since the RND also outputs a number, you can use maths and a round function to rescale it to 1, 2, or 3.
Sign In or Register to comment.