Generate Chess960 starting position: Difference between revisions
Generate Chess960 starting position (view source)
Revision as of 02:15, 6 October 2021
, 2 years ago→{{header|Commodore BASIC}}: Normalize input instead of erroring on >= 960; work without BEGIN/BEND
(→Header: BASIC: Consolidate BASIC entries) |
(→{{header|Commodore BASIC}}: Normalize input instead of erroring on >= 960; work without BEGIN/BEND) |
||
Line 81:
=={{header|BASIC}}==
==={{header|Commodore BASIC}}===
{{works with|Commodore BASIC|3.5,7.0}}
Uses structured DO/LOOP introduced in Commodore BASIC 3.5 on the C-16 and
<lang basic>100 REM CHESS 960
Line 90:
140 IF SP<0 THEN SP=INT(RND(.)*960):PRINT SP
150 PRINT
160
170 AR$="--------"
180 P=SP
Line 102:
260 FOR N1=0 TO 3
270 : FOR N2=N1+1 TO 4
280 : IF N
290 : P$="N":N=N1:GOSUB 420
300 : P$="N":N=N2-1:GOSUB 420
310 : N1=3
320 : N2=4
340 : N=N-1
350 : NEXT N2
Line 114 ⟶ 113:
380 P$="K":N=0:GOSUB 420
390 P$="R":N=0:GOSUB 420
400 PRINT STR$(SP);":";AR$
410 END
420 FOR I=1 TO LEN(AR$)
430 : IF MID$(AR$,I,1)
440 :
450 :
460 :
470 : GOTO
480 :
510 NEXT I
520 RETURN
</lang>
{{Out}}
Line 133 ⟶ 131:
RUN
SPID (-1 FOR RANDOM):518
518:RNBQKBNR
READY.
RUN
SPID (-1 FOR RANDOM):-
926:RKRQNBBN▼
▲RKRQNBBN
READY.</pre>
|