Rock-paper-scissors: Difference between revisions

no edit summary
m (→‎traditional, 3 choices: changed wording in the REXX section header.)
No edit summary
Line 4,129:
end /*forever*/ /*stick a fork in it, we're all done. */</lang>
{{out|output|text=&nbsp; is similar to the 1<sup>st</sup> REXX version.}} <br><br>
 
=={{header|Ring}}==
<lang ring>
# Project : Rock-paper-scissors
# Date : 2018/03/25
# Author : Gal Zsolt [~ CalmoSoft ~]
# Email : <calmosoft@gmail.com>
 
see "welcome to the game of rock-paper-scissors." + nl
see "each player guesses one of these three, and reveals it at the same time." + nl
see "rock blunts scissors, which cut paper, which wraps stone." + nl
see "if both players choose the same, it is a draw!" + nl
see "when you've had enough, choose q." + nl
g = list(3)
g = ["rock","paper","scissors"]
total=0
draw=0
pwin=0
cwin=0
see "what is your move (press r, p, or s)?"
while true
c=random(2)+1
give q
gs = floor((substr("rpsq",lower(q))))
if gs>3 or gs<1
summarise()
exit
ok
total = total + 1
see"you chose " + g[gs] + " and i chose " + g[c] + nl
if (gs-c) = 0
see ". it's a draw"
draw = draw + 1
ok
if (gs-c) = 1 or (gs-c) = -2
see ". you win!"
pwin = pwin + 1
ok
if (gs-c) = (-1) or (gs-c) = 2
see ". i win!"
cwin = cwin + 1
ok
end
 
func summarise()
see "you won " + pwin + ", and i won " + cwin + ". there were " + draw + " draws" + nl
see "thanks for playing!" + nl
</lang>
Output:
<pre>
welcome to the game of rock-paper-scissors.
each player guesses one of these three, and reveals it at the same time.
rock blunts scissors, which cut paper, which wraps stone.
if both players choose the same, it is a draw!
when you've had enough, choose q.
 
what is your move (press r, p, or s)?
r
you chose rock and i chose rock
. it's a draw
p
you chose paper and i chose paper
. it's a draw
s
you chose scissors and i chose rock
. i win!
R
you chose rock and i chose paper
. i win!
P
you chose paper and i chose paper
. it's a draw
S
you chose scissors and i chose paper
. you win!
q
you won 1, and i won 2. there were 3 draws
thanks for playing!
</pre>
 
=={{header|Ruby}}==
2,468

edits