Rock-paper-scissors: Difference between revisions

Content added Content deleted
(Added R.)
(Added 11l)
Line 25: Line 25:
Support additional choices   [[wp:Rock-paper-scissors#Additional_weapons|additional weapons]].
Support additional choices   [[wp:Rock-paper-scissors#Additional_weapons|additional weapons]].
<br><br>
<br><br>

=={{header|11l}}==
{{trans|Python}}

<lang 11l>V rules = [‘rock’ = ‘paper’, ‘scissors’ = ‘rock’, ‘paper’ = ‘scissors’]
V previous = [‘rock’, ‘paper’, ‘scissors’]

L
V human = input("\nchoose your weapon: ")
V computer = rules[random:choice(previous)]

I human C (‘quit’, ‘exit’)
L.break

E I human C rules
previous.append(human)
print(‘the computer played ’computer, end' ‘; ’)

I rules[computer] == human
print(‘yay you win!’)
E I rules[human] == computer
print(‘the computer beat you... :(’)
E
print(‘it's a tie!’)

E
print(‘that's not a valid choice’)</lang>

{{out}}
<pre>

choose your weapon: rock
the computer played paper; the computer beat you... :(

choose your weapon: rock
the computer played scissors; yay you win!

choose your weapon: rock
the computer played paper; the computer beat you... :(

choose your weapon: rock
the computer played paper; the computer beat you... :(

choose your weapon: rock
the computer played rock; it's a tie!
</pre>


=={{header|Ada}}==
=={{header|Ada}}==