Jump to content

Nim game: Difference between revisions

686 bytes added ,  1 month ago
Added XBasic
(The standard Waduzitdo NIM game published in BYTE Magazine and copied on Github)
(Added XBasic)
Line 1,267:
PRINT "Obtuve la última ficha. ¡Gané! Mejor suerte la próxima vez."
END</syntaxhighlight>
 
==={{header|XBasic}}===
{{works with|Windows XBasic}}
{{trans|FreeBASIC}}
<syntaxhighlight lang="qbasic">PROGRAM "nim-game"
VERSION "0.0000"
 
DECLARE FUNCTION Entry ()
 
FUNCTION Entry ()
 
monton = 12
 
DO WHILE monton > 0
PRINT "There are "; monton; " tokens remaining. How many would you like to take? ";
llevar = UBYTE(INLINE$(""))
DO WHILE (llevar <= 0) OR (llevar > 3)
llevar = UBYTE(INLINE$("You must take 1, 2, or 3 tokens. How many would you like to take"))
LOOP
 
PRINT "On my turn I will take"; 4 - llevar; " token(s)."
monton = monton - 4
LOOP
 
PRINT "\nI got the last token. I win! Better luck next time."
 
END FUNCTION
END PROGRAM</syntaxhighlight>
 
==={{header|Yabasic}}===
2,139

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.