Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,40 @@
tokens = 12
print "Nim Game"
print "Starting with " + tokens + " tokens."
print
printRemaining = function()
print tokens + " tokens remaining."
print
end function
playerTurn = function(take)
take = floor(val(take))
if take < 1 or take > 3 then
print "Take must be between 1 and 3."
return false
end if
globals.tokens = tokens - take
print "Player takes " + take + " tokens."
printRemaining
return true
end function
computerTurn = function()
take = tokens % 4
globals.tokens = tokens - take
print "Computer takes " + take + " tokens."
printRemaining
end function
while tokens > 0
if playerTurn(input("How many tokens would you like to take? ")) then
computerTurn
end if
end while
print "Computer wins."