How to resolve the algorithm Rock-paper-scissors step by step in the Locomotive Basic programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Rock-paper-scissors step by step in the Locomotive 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 Locomotive Basic programming language
Source code in the locomotive programming language
10 mode 1:defint a-z:randomize time
20 rps$="rps"
30 msg$(1)="Rock breaks scissors"
40 msg$(2)="Paper covers rock"
50 msg$(3)="Scissors cut paper"
60 print "Rock Paper Scissors":print
70 print "Enter r, p, or s as your play."
80 print "Running score shown as :"
90 achoice=rnd*2.99+.5 ' get integer between 1 and 3 from real between .5 and <3.5
100 ' get key
110 pin$=inkey$
120 if pin$="" then 110
130 pchoice=instr(rps$,pin$)
140 if pchoice=0 then print "Sorry?":goto 110
150 pcf(pchoice)=pcf(pchoice)+1
160 plays=plays+1
170 print "My play: "mid$(rps$,achoice,1)
180 sw=(achoice-pchoice+3) mod 3
190 if sw=0 then print "Tie." else if sw=1 then print msg$(achoice);". My point.":ascore=ascore+1 else print msg$(pchoice);". Your point.":pscore=pscore+1
200 print pscore":"ascore
210 rn=rnd*plays
220 if rn
230 goto 110
You may also check:How to resolve the algorithm Roman numerals/Encode step by step in the Elena programming language
You may also check:How to resolve the algorithm IBAN step by step in the MATLAB programming language
You may also check:How to resolve the algorithm Quad-power prime seeds step by step in the RPL programming language
You may also check:How to resolve the algorithm K-d tree step by step in the J programming language
You may also check:How to resolve the algorithm Hash join step by step in the M2000 Interpreter programming language