Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
|
|
@ -5,36 +5,36 @@ print "Starting with " + tokens + " tokens."
|
|||
print
|
||||
|
||||
printRemaining = function()
|
||||
print tokens + " tokens remaining."
|
||||
print
|
||||
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
|
||||
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
|
||||
globals.tokens = tokens - take
|
||||
|
||||
print "Player takes " + take + " tokens."
|
||||
printRemaining
|
||||
return true
|
||||
print "Player takes " + take + " tokens."
|
||||
printRemaining
|
||||
return true
|
||||
end function
|
||||
|
||||
computerTurn = function()
|
||||
take = tokens % 4
|
||||
globals.tokens = tokens - take
|
||||
take = tokens % 4
|
||||
globals.tokens = tokens - take
|
||||
|
||||
print "Computer takes " + take + " tokens."
|
||||
printRemaining
|
||||
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
|
||||
if playerTurn(input("How many tokens would you like to take? ")) then
|
||||
computerTurn
|
||||
end if
|
||||
end while
|
||||
|
||||
print "Computer wins."
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue