// Rock, paper scissors data "Rock", "Paper", "Scissors" dim name$ (3) for i = 0 to 2 cycle read name$ (i) repeat iWins = 0 pWins = 0 draws = 0 iCheat = TRUE print "Lets play Rock, Paper, Scissors." cycle choice = -1 print "Choose: Rock, Paper or Scissors: "; fist$ = get$ if fist$ = "r" or fist$ = "R" then choice = 0 endif if fist$ = "p" or fist$ = "P" then choice = 1 endif if fist$ = "s" or fist$ = "S" then choice = 2 endif if choice = -1 then // Invalid print "What? Please try again." continue endif print name$ (choice) iPick = rnd (3) // 0, 1 or 2 // Cheat? // Clightly. If I'm cheating and I lose, then I'll // secretly pick again - to give me a small advantage. if iCheat then switch (iPick) case 0 if choice = 1 then iPick = rnd (3) endcase case 1 if choice = 2 then iPick = rnd (3) endcase case 2 if choice = 0 then iPick = rnd (3) endcase endswitch endif print "I pick: "; name$ (iPick); ": "; // Work out who won // There is a better way to do this, but when it doubt, // use brute-force (aka copy&paste) // Player picked rock if choice = 0 then if iPick = 0 then // I picked rock print "We draw." draws = draws + 1 endif if iPick = 1 then // I picked paper print "You lose!" iWins = iWins + 1 endif if iPick = 2 then // I picked scissors print "I lose. Well done!" pWins = pWins + 1 endif endif // Player picked paper if choice = 1 then if iPick = 0 then // I picked rock print "I lose. Well done!" pWins = pWins + 1 endif if iPick = 1 then // I picked paper print "We draw" draws = draws + 1 endif if iPick = 2 then // I picked scissors print "I win!" iWins = iWins + 1 endif endif // Player picked scissors if choice = 2 then if iPick = 0 then // I picked rock print "I win!" iWins = iWins + 1 endif if iPick = 1 then // I picked paper print "I Lose" pWins = pWins + 1 endif if iPick = 2 then // I picked scissors print "We Draw!" draws = draws + 1 endif endif print print "Scores: You win: "; pWins; ", I won: "; iWins; ", Draws: "; draws print repeat end