Rock-paper-scissors: Difference between revisions

Content added Content deleted
No edit summary
Line 4,137: Line 4,137:
# Email : <calmosoft@gmail.com>
# Email : <calmosoft@gmail.com>


see "
see "welcome to the game of rock-paper-scissors." + nl
welcome to the game of rock-paper-scissors.
see "each player guesses one of these three, and reveals it at the same time." + nl
each player guesses one of these three, and reveals it at the same time.
see "rock blunts scissors, which cut paper, which wraps stone." + nl
rock blunts scissors, which cut paper, which wraps stone.
see "if both players choose the same, it is a draw!" + nl
if both players choose the same, it is a draw!
see "when you've had enough, choose q." + nl
when you've had enough, choose q.
g = list(3)
"
g = ["rock","paper","scissors"]
g = ["rock","paper","scissors"]
total=0
total=0 draw=0
pwin=0 cwin=0
draw=0
pwin=0
cwin=0
see "what is your move (press r, p, or s)?"
see "what is your move (press r, p, or s)?"
while true
while true
Line 4,159: Line 4,158:
total = total + 1
total = total + 1
see"you chose " + g[gs] + " and i chose " + g[c] + nl
see"you chose " + g[gs] + " and i chose " + g[c] + nl
if (gs-c) = 0
temp = gs-c
if temp = 0
see ". it's a draw"
see ". it's a draw"
draw = draw + 1
draw = draw + 1
ok
ok
if (gs-c) = 1 or (gs-c) = -2
if temp = 1 or temp = -2
see ". you win!"
see ". you win!"
pwin = pwin + 1
pwin = pwin + 1
ok
ok
if (gs-c) = (-1) or (gs-c) = 2
if temp = (-1) or temp = 2
see ". i win!"
see ". i win!"
cwin = cwin + 1
cwin = cwin + 1
ok
ok
end
end

func summarise()
see "you won " + pwin + ", and i won " + cwin + ". there were " + draw + " draws" + nl
see "thanks for playing!" + nl
</lang>
</lang>
Output:
Output: