Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
80
Task/Nim-game/FTCBASIC/nim-game.basic
Normal file
80
Task/Nim-game/FTCBASIC/nim-game.basic
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue