How to resolve the algorithm Rock-paper-scissors step by step in the Run BASIC programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Rock-paper-scissors step by step in the Run BASIC programming language

Table of Contents

Problem Statement

Implement the classic children's game Rock-paper-scissors, as well as a simple predictive   AI   (artificial intelligence)   player. Rock Paper Scissors is a two player game. Each player chooses one of rock, paper or scissors, without knowing the other player's choice. The winner is decided by a set of rules:

If both players choose the same thing, there is no winner for that round. For this task, the computer will be one of the players. The operator will select Rock, Paper or Scissors and the computer will keep a record of the choice frequency, and use that information to make a weighted random choice in an attempt to defeat its opponent.

Support additional choices   additional weapons.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Rock-paper-scissors step by step in the Run BASIC programming language

Source code in the run programming language

pri$ = "RSPR" 
rps$ = "Rock,Paper,Sissors"
[loop]
button #r, "Rock",    [r]
button #p, "Paper",   [p]
button #s, "Scissors",[s]
button #q, "Quit",    [q]
wait
[r] y = 1 :goto [me]
[p] y = 2 :goto [me]
[s] y = 3
[me]
cls
y$ = word$(rps$,y,",")
m  = int((rnd(0) * 2) + 1)
m$ = word$(rps$,m,",")
print chr$(10);"You Chose:";y$;" I chose:";m$
yp = instr(pri$,left$(y$,1))
mp = instr(pri$,left$(m$,1))
if yp = 1 and mp = 3 then mp = 0
if mp = 1 and yp = 3 then yp = 0
if yp < mp then print "You win"
if yp = mp then print "Tie"
if yp > mp then print "I win"
goto [loop]
wait

[q] cls
print "Good Bye! I enjoyed the game"
end

  

You may also check:How to resolve the algorithm Diversity prediction theorem step by step in the zkl programming language
You may also check:How to resolve the algorithm String concatenation step by step in the Scheme programming language
You may also check:How to resolve the algorithm Best shuffle step by step in the Ring programming language
You may also check:How to resolve the algorithm Evolutionary algorithm step by step in the Oz programming language
You may also check:How to resolve the algorithm Amb step by step in the Common Lisp programming language