Nim game: Difference between revisions
Added Quackery.
(→{{header|Vlang}}: Rename "Vlang" in "V (Vlang)") |
(Added Quackery.) |
||
Line 2,340:
Computer wins!
</pre>
=={{header|Quackery}}==
<syntaxhighlight lang="Quackery"> [ $ "Take how many tokens? (1-3) "
input
trim reverse
trim reverse
$->n
not iff drop again
dup 1 4 within
not iff drop again ] is getmove ( --> n )
[ 12
[ say "There are "
dup echo
say " tokens." cr cr
getmove tuck -
4 rot - dup
cr say "Computer takes "
echo
say "." cr cr
-
dup 0 = until ]
drop
say "Computer wins." cr ] is play ( --> )</syntaxhighlight>
{{out}}
As a dialogue in the Quackery shell.
<pre>/O> play
...
There are 12 tokens.
Take how many tokens? (1-3) 1
Computer takes 3.
There are 8 tokens.
Take how many tokens? (1-3) 2
Computer takes 2.
There are 4 tokens.
Take how many tokens? (1-3) 3
Computer takes 1.
Computer wins.
Stack empty.
</pre>
|