Nim game: Difference between revisions

2,931 bytes added ,  1 month ago
Added various BASIC dialects (Chipmunk Basic, Minimal BASIC, MSX Basic and Quite BASIC)
(Added various BASIC dialects (Chipmunk Basic, Minimal BASIC, MSX Basic and Quite BASIC))
Line 742:
print "I got the last token. I win! Better luck next time."
end</syntaxhighlight>
 
==={{header|Chipmunk Basic}}===
{{trans|FreeBASIC}}
{{works with|Chipmunk Basic|3.6.4}}
<syntaxhighlight lang="vbnet">100 cls
110 monton = 12
120 llevar = 0
130 do while monton > 0
140 print using "There are ## tokens remaining. How many would you like to take";monton;
150 input llevar
160 do while llevar = 0 or llevar > 3
170 input "You must take 1, 2, or 3 tokens. How many would you like to take";llevar
180 loop
190 print "On my turn I will take";4-llevar;" token(s)."
200 monton = monton-4
210 loop
220 print
230 print "I got the last token. I win! Better luck next time."
240 end</syntaxhighlight>
 
==={{header|Craft Basic}}===
Line 943 ⟶ 962:
320 PRINT "You win!"
330 END IF</syntaxhighlight>
 
==={{header|Minimal BASIC}}===
{{trans|Tiny BASIC}}
{{works with|BASICA}}
{{works with|Chipmunk Basic}}
{{works with|GW-BASIC}}
{{works with|MSX BASIC}}
{{works with|PC-BASIC|any}}
{{works with|QBasic}}
<syntaxhighlight lang="qbasic">10 LET H = 12
20 PRINT "There are"
30 PRINT H
40 PRINT "tokens remaining. How many would you like to take?"
50 INPUT T
60 IF T > 3 THEN 170
70 IF T < 1 THEN 170
80 LET H = H - T
90 IF H = 0 THEN 190
100 LET T = 4 - T
110 PRINT "I will take"
120 PRINT T
130 PRINT "tokens."
140 LET H = H - T
150 IF H = 0 THEN 210
160 GOTO 20
170 PRINT "You must take 1, 2, or 3 tokens."
180 GOTO 50
190 PRINT "Congratulations. You got the last token."
200 GOTO 220
210 PRINT "I got the last token. I win. Better luck next time."
220 END</syntaxhighlight>
 
==={{header|MSX Basic}}===
{{works with|MSX BASIC|any}}
{{works with|Applesoft BASIC}}
{{works with|BASICA}}
{{works with|Chipmunk Basic}}
{{works with|GW-BASIC}}
{{works with|PC-BASIC|any}}
{{works with|QBasic}}
<syntaxhighlight lang="qbasic">100 CLS : rem 100 HOME for Applesoft BASIC
110 LET M = 12
120 LET L = 0
130 IF M <= 0 THEN GOTO 220
140 PRINT "There are "; M; " tokens remaining. How many would you like to take";
150 INPUT L
160 IF L <> 0 AND L <= 3 THEN GOTO 190
170 PRINT "You must take 1, 2, or 3 tokens. How many would you like to take";
180 GOTO 150
190 PRINT "On my turn I will take "; 4 - L; " token(s)."
200 LET M = M - 4
210 GOTO 130
220 PRINT
230 PRINT "I got the last token. I win! Better luck next time."
240 END</syntaxhighlight>
 
==={{header|PureBasic}}===
Line 985 ⟶ 1,059:
PRINT "I got the last token. I win! Better luck next time."
END</syntaxhighlight>
 
==={{header|Quite BASIC}}===
{{trans|Minimal BASIC}}
{{works with|BASICA}}
{{works with|Chipmunk Basic}}
{{works with|GW-BASIC}}
{{works with|MSX BASIC}}
{{works with|PC-BASIC|any}}
{{works with|QBasic}}
<syntaxhighlight lang="qbasic">10 LET H = 12
20 PRINT "There are"
30 PRINT H
40 PRINT "tokens remaining. How many would you like to take?"
50 INPUT ""; T
60 IF T > 3 THEN 170
70 IF T < 1 THEN 170
80 LET H = H - T
90 IF H = 0 THEN 190
100 LET T = 4 - T
110 PRINT "I will take"
120 PRINT T
130 PRINT "tokens."
140 LET H = H - T
150 IF H = 0 THEN 210
160 GOTO 20
170 PRINT "You must take 1, 2, or 3 tokens."
180 GOTO 50
190 PRINT "Congratulations. You got the last token."
200 GOTO 220
210 PRINT "I got the last token. I win. Better luck next time."
220 END</syntaxhighlight>
 
==={{header|Run BASIC}}===
2,122

edits