RosettaCodeData/Task/Nim-game/Craft-Basic/nim-game.basic

58 lines
706 B
Plaintext

let h = 12
label loop
alert "There are ", h ," tokens remaining."
input "How many would you like to take? ", t
if t > 3 or t < 1 then
alert "You must take between 1 to 3 tokens."
endif
if h - t < 0 then
alert "You cannot take that many. There's only ", h ," left."
endif
if t <= 3 and t >= 1 and h - t >= 0 then
let h = h - t
if h = 0 then
alert "Congratulations. You got the last token."
end
endif
let t = 4 - t
if h >= 15 then
let t = 3
endif
if h <= 3 then
let t = h
endif
alert "I will take ", t ," tokens."
let h = h - t
if h = 0 then
alert "I got the last token. I win. Better luck next time."
end
endif
endif
goto loop