Anonymous user
Rock-paper-scissors: Difference between revisions
m
→extended, 5 choices: added/changed whitespace and comments.
m (→traditional, 3 choices: added/changed comments and whitespace.) |
m (→extended, 5 choices: added/changed whitespace and comments.) |
||
Line 4,463:
This REXX version supports more choices: <big> rock paper scissors lizard Spock </big>
<lang rexx>/*REXX pgm plays rock─paper─scissors─lizard─Spock with human; tracks human usage trend. */
!= '────────'; err=!
prompt=! 'Please enter one of: Rock Paper SCissors Lizard SPock (Vulcan) (or Quit)'
$.p='paper' ; $.s=
t.p= $.r $.v ; t.s= $.p $.L ; t.r= $.s $.L ; t.L= $.p $.v ; t.v= $.r $.s /*thingys beats stuff.*/
w.p= $.L $.s ; w.s= $.v $.r ; w.r= $.v $.p ; w.L= $.r $.s ; w.v= $.L $.p /*stuff beats thingys.*/
b.p='covers disproves'; b.s="cuts decapitates"; b.r='breaks crushes'; b.L="eats poisons"; b.v='vaporizes smashes' /*how the choice wins.*/
whom.1= ! 'the computer wins. ' !; whom.2= ! "you win! " !; win= words(t. p)
do forever; say; say prompt;
c=word($.p $.s $.r $.L $.v, random(1, 5) ) /*the computer's first choice/pick. */
m=max(@.r, @.p, @.s, @.L, @.v)
if @.p==m then c= word(w.p, random(1, 2) )
if @.s==m then c= word(w.s, random(1, 2) )
if @.r==m then c= word(w.r, random(1, 2) )
if @.L==m then c= word(w.L, random(1, 2) )
if @.v==m then c= word(w.v, random(1, 2) )
c1= left(c, 1)
parse pull u; a= strip(u)
upper a c1 ; a1= left(a, 1)
ok=0 /*indicate answer isn't OK (so far). */
select /* [↓] process the CBLF's choice/pick.*/
|