Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 10 GR : PR# 3: PRINT TAB( 34)"KNIGHT´S TOUR": PRINT TAB(25)"(C) PRZEMYSLAW KOBYLANSKI 2024"
- 20 Y = 0: FOR I = 0 TO 7: FOR K = 1 TO 4: FOR J = 0 TO 7:X = 3 * J:SUM = I + J:MOD = SUM - 2 * INT (SUM / 2): COLOR= 7 - 5 * MOD: HLIN X,X + 2 AT Y: NEXT J:Y = Y + 1: NEXT K: NEXT I
- 30 DIM B(7,7),C(7,7),DX(7),DY(7),S(64,8),Z(64,7):SP = 0:S$ = ""
- 40 FOR I = 0 TO 7: READ DX(I),DY(I): NEXT I
- 50 FOR Y = 0 TO 7: FOR X = 0 TO 7: READ C(X,Y): NEXT X: NEXT Y
- 70 N = 1:X = 0:Y = 0: GOTO 1000
- 80 PRINT S$;: PRINT TAB( 41);: INVERSE : PRINT "PRESS ENTER";: NORMAL : INPUT A$
- 90 TEXT : HOME : END
- 1000 S$ = S$ + CHR$ (65 + X) + CHR$ (56 - Y):B(X,Y) = N: COLOR = 1: VLIN 4 * Y + 1,4 * Y + 2 AT 3 * X + 1: IF N = 64 THEN 80
- 1010 S$ = S$ + " ":N = N + 1:D = - 1: GOSUB 2000: FOR I = 0 TO 7:X1 = X + DX(I):Y1 = Y + DY(I): IF X1 > - 1 THEN IF X1 < 8 THEN IF Y1 > - 1 THEN IF Y1 < 8 THEN S(SP,I) = C(X1,Y1): GOTO 1012
- 1011 S(SP,I) = 9999
- 1012 Z(SP,I) = I: NEXT I
- 1015 FOR I = 6 TO 0 STEP - 1: FOR J = 0 TO I: IF S(SP,J) > S(SP,J + 1) THEN TEMP = S(SP,J):S(SP,J) = S(SP,J + 1):S(SP,J + 1) = TEMP:TEMP = Z(SP,J):Z(SP,J) = Z(SP,J + 1):Z(SP,J + 1) = TEMP
- 1016 NEXT J: NEXT I:S(SP,8) = 0
- 1020 IF S(SP,S(SP,8)) > 8 THEN 1040
- 1021 X = X + DX(Z(SP,S(SP,8))):Y = Y + DY(Z(SP,S(SP,8))): IF B(X,Y) = 0 THEN SP = SP + 1: GOTO 1000
- 1030 X = X - DX(Z(SP,S(SP,8))):Y = Y - DY(Z(SP,S(SP,8))):S(SP,8) = S(SP,8) + 1: IF S(SP,8) < 8 THEN 1020
- 1040 S$ = LEFT$ (S$, LEN (S$) - 4):B(X,Y) = 0:SUM = X + Y:MOD = SUM - 2 * INT (SUM / 2): COLOR= 7 - 5 * MOD: VLIN 4 * Y + 1,4 * Y + 2 AT 3 * X + 1:D = 1: GOSUB 2000:N = N - 1:SP = SP - 1: IF SP = 0 THEN 80
- 1050 GOTO 1030
- 2000 FOR I = 0 TO 7:X1 = X + DX(I):Y1 = Y + DY(I): IF X1 > - 1 THEN IF X1 < 8 THEN IF Y1 > - 1 THEN IF Y1 < 8 THEN C(X1,Y1) = C(X1,Y1) + D
- 2010 NEXT I: RETURN
- 3000 DATA 1,-2,2,-1,2,1,1,2,-1,2,-2,1,-2,-1,-1,-2
- 4000 DATA 2,3,4,4,4,4,3,2
- 4010 DATA 3,4,6,6,6,6,4,3
- 4020 DATA 4,6,8,8,8,8,6,4
- 4030 DATA 4,6,8,8,8,8,6,4
- 4040 DATA 4,6,8,8,8,8,6,4
- 4050 DATA 4,6,8,8,8,8,6,4
- 4060 DATA 3,4,6,6,6,6,4,3
- 4070 DATA 2,3,4,4,4,4,3,2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement