Nim game: Difference between revisions
→{{header|FreeBASIC}}
Basicgames (talk | contribs) |
Basicgames (talk | contribs) |
||
Line 1,337:
print "I got the last token. I win! Better luck next time."</syntaxhighlight>
=={{header|FTCBASIC}}==
<syntaxhighlight lang="basic">define tokens = 12, take = 0
gosub intro
do
print "There are " \
print tokens \
print " tokens remaining."
crlf
print "How many would you like to take? " \
input take
if take > 3 or take < 1 then
print "You must take between 1 to 3 tokens."
endif
if tokens - take < 0 then
print "You cannot take that many."
endif
if take <= 3 and take >= 1 and tokens - take >= 0 then
let tokens = tokens - take
if tokens = 0 then
bell
print "Congratulations. You got the last token."
pause
end
endif
let take = 4 - take
if tokens >= 15 then
let take = 3
endif
if tokens <= 3 then
let take = tokens
endif
print "I will take " \
print take \
print " of the tokens."
let tokens = tokens - take
if tokens = 0 then
print "I got the last token. I win. Better luck next time."
pause
end
endif
endif
loop
sub intro
cls
print "NIM game"
crlf
print "Press any key to play..."
cls
return</syntaxhighlight>
=={{header|Go}}==
|