Nim game: Difference between revisions

2,320 bytes added ,  1 month ago
Added various BASIC dialects (Chipmunk Basic, Minimal BASIC, MSX Basic and Quite BASIC)
m (→‎{{header|Wren}}: Changed to Wren S/H)
(Added various BASIC dialects (Chipmunk Basic, Minimal BASIC, MSX Basic and Quite BASIC))
(One intermediate revision by one other user not shown)
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}}===
Line 1,139 ⟶ 1,244:
210 PRINT "I got the last token. I win. Better luck next time."
220 END</syntaxhighlight>
 
==={{header|Tiny Craft Basic}}===
<syntaxhighlight lang="basic">5 cls
10 print "NIM"
20 let h = 12
30 print "There are ", h ," tokens remaining."
40 input "How many would you like to take? ", t
50 if t > 3 then 140
60 if t < 1 then 140
70 let h = h - t
80 if h = 0 then 160
90 let t = 4 - t
100 print "I will take ", t ," tokens."
110 let h = h - t
120 if h = 0 then 180
130 goto 30
140 print "You must take between 1 to 3 tokens."
150 goto 40
160 print "Congratulations. You got the last token."
170 goto 190
180 print "I got the last token. I win. Better luck next time."
190 shell "pause"</syntaxhighlight>
 
==={{header|True BASIC}}===
2,122

edits