Anonymous user
Rock-paper-scissors: Difference between revisions
m
→traditional, 3 choices: added/changed comments and whitespace.
m (→traditional, 3 choices: added/changed comments and whitespace.) |
|||
Line 4,383:
::* uses better "English"/grammer, i.e.: ''rock breaks scissors'', and ''paper covers rock''.
<lang rexx>/*REXX program plays rock─paper─scissors with a human; tracks what human tends to use. */
!= '────────';
prompt= !
$.p= 'paper' ;
t.p= $.r ;
w.p= $.s ;
b.p= 'covers';
do forever; say; say prompt; say
c= word($.p $.s $.r, random(1, 3) )
m= max(@.r, @.p, @.s); c= w.r
if @.p==m then c= w.p
if @.s==m then c= w.s
c1= left(c, 1)
parse pull u; a= strip(u)
upper a c1 ; a1= left(a, 1)
ok=
select /*process/verify the CBLF's choice. */
when words(u)==0 then say err 'nothing entered'
when words(u)>1 then say err 'too many choices: ' u
when abbrev('QUIT', a) then do; say !
when abbrev('ROCK', a) |,
abbrev('PAPER', a) |,
Line 4,410:
if \ok then iterate /*answer ¬OK? Then get another choice.*/
@.a1= @.a1 +
say ! 'computer chose: ' c
if a1== c1 then do; say ! 'draw.'; iterate; end
|