Rock-paper-scissors: Difference between revisions
Content added Content deleted
m (→extended, 5 choices: added/changed whitespace and comments.) |
m (→extended, 5 choices: added whitespace.) |
||
Line 4,465: | Line 4,465: | ||
!= '────────'; err=! "***error***"; @.=0 /*some constants for this REXX program.*/ |
!= '────────'; err=! "***error***"; @.=0 /*some constants for this REXX program.*/ |
||
prompt=! 'Please enter one of: Rock Paper SCissors Lizard SPock (Vulcan) (or Quit)' |
prompt=! 'Please enter one of: Rock Paper SCissors Lizard SPock (Vulcan) (or Quit)' |
||
$.p='paper' ; $.s="scissors" ; $.r= |
$.p='paper' ; $.s="scissors" ; $.r='rock' ; $.L="lizard" ; $.v='Spock' /*names of the thingys*/ |
||
t.p= $.r $.v ; t.s= $.p $.L ; t.r= $.s $.L ; t.L= $.p $.v ; t.v= $.r $.s /*thingys beats stuff.*/ |
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.*/ |
w.p= $.L $.s ; w.s= $.v $.r ; w.r= $.v $.p ; w.L= $.r $.s ; w.v= $.L $.p /*stuff beats thingys.*/ |
||
Line 4,472: | Line 4,472: | ||
do forever; say; say prompt; say /*prompt CBLF; then get a response. */ |
do forever; say; say prompt; say /*prompt CBLF; then get a response. */ |
||
c=word($.p $.s $.r $.L $.v, random(1, 5) ) |
c= word($.p $.s $.r $.L $.v, random(1, 5) ) /*the computer's first choice/pick. */ |
||
m=max(@.r, @.p, @.s, @.L, @.v) |
m= max(@.r, @.p, @.s, @.L, @.v) /*used in examining CBLF's history. */ |
||
if @.p==m then c= word(w.p, random(1, 2) ) /*emulate JC's The Amazing Karnac. */ |
if @.p==m then c= word(w.p, random(1, 2) ) /*emulate JC's The Amazing Karnac. */ |
||
if @.s==m then c= word(w.s, random(1, 2) ) /* " " " " " */ |
if @.s==m then c= word(w.s, random(1, 2) ) /* " " " " " */ |