Nim game: Difference between revisions
→{{header|Pascal}}
Basicgames (talk | contribs) |
Basicgames (talk | contribs) |
||
Line 2,252:
Thanks for playing!
</pre>
=={{header|Pebble}}==
<syntaxhighlight lang="basic">
;NIM game example program
;Compile with Pebble
program examples\nim
data
int tokens[12]
int take[0]
begin
call intro
label gameloop
echo "There are"
echo [tokens]
echo " tokens remaining."
crlf
echo "How many would you like to take? "
input [take]
if [take] > 3 | [take] < 1 then
echo "You must take between 1 to 3 tokens."
endif
if [take] <= 3 & [take] >= 1 then
[tokens] = [tokens] - [take]
if [tokens] = 0 then
bell
echo "Congratulations. You got the last token."
pause
kill
endif
[take] = 4 - [take]
echo "I will take"
echo [take]
echo " tokens.
[tokens] = [tokens] - [take]
if [tokens] = 0 then
echo "I got the last token. I win. Better luck next time."
pause
kill
endif
endif
goto gameloop
end
sub intro
cls
echo "NIM game"
crlf
ret
</syntaxhighlight>
=={{header|Perl}}==
|