RosettaCodeData/Task/Nim-game/FutureBasic/nim-game.basic

31 lines
516 B
Plaintext

void local fn NimGame
window 1, @"Nim game"
int tokens = 12
while ( tokens != 0 )
print @"Tokens remaining: ";tokens
CFStringRef num = inkey @"Take 1 to 3 tokens", @"123"
if ( !num ) then end
int n = intval(num)
print @"You took ";n; @" token";
if ( n > 1 ) then print @"s" else print
tokens -= n
int c = 4-n
print @"I took ";c;@" token";
if ( c > 1 ) then print @"s" else print
tokens -= c
print
wend
print @"I win!"
end fn
fn NimGame
HandleEvents