Skip to content

Knights Tour – My First Entry into the 2026 BASIC10 Competition

For more than a decade, Gunnar Kannold has been hosting the BASIC10 Liner Competition

http://basic10liner.com/

The idea is simple, using BASIC on 8-Bit Home Computers from the early days, write a game, utility, or something interesting using up-to 10 Lines of code. There are several categories challenging people to write code with a maximum of 80, 120, 256 characters per line of code.

Final Submission date was 22nd March 2026 and the results are expected to be announced in April once the judging is complete.

This is my first entry to the competition.

Last year I wrote about the Knights Tour, solving a centuries old puzzle using Python Code.

The idea is simple… Using a Chess Knight and picking any starting point on the board, can you visit each and every square once in 63 moves.

One of the most elegant solutions is Warnsdorff’s Rule, a heuristic dating back to 1823. If you’re interested in the detail, I covered it fully in that earlier post.

The code for the Python Solution took around 230 lines of code to animate and display a board and solve the puzzle.

The question was… could the Warnsdorff’s Rule heuristic be implemented in 10 lines or less of BASIC code and… draw the knight chess piece on the board to each square visited showing the solution in realtime that you can follow on your chess board at home…

Introducing… Knights Tour in BASIC

This was the real challenge, and to achieve this I had to use up to the maximum 256 characters per line as permitted in the Schau Category of the competition.

I’d forgotten how powerful Locomotive BASIC is, and the solution was created, including a centre of board tie-break in just a few lines. I had some spare. I thought why not make it visually interesting and draw a chess board on screen, and whether I could draw a chess piece on screen as the knight moved.

I spent longer on this than the algorithm. I searched the internet for an SVG file of the Knight Chess Piece… and then set about converting and approximating it to DRAW commands. I could have done this on graph paper and be done in an hour, instead I spent the evening writing a Python program to convert the SVG into old school DRAW statements. This is a work in progress and will be released when I’m happier with it.

Amstrad CPC screen showing a completed Knight’s Tour solution with numbered moves from 1 to 64 across an 8×8 chessboard, using coloured knight sprites to display the traversal.
Live output from my Knight’s Tour BASIC 10-Liner on the Amstrad CPC, showing a complete 64-move solution rendered in real time using Warnsdorff’s heuristic.

You can find more details of the design in the information supplied at

https://bunsen.itch.io/knights-tour-amstrad-cpc-by-muckypaws

The Solution

The user is asked to enter the start co-ordinates of the Knight, the program quickly creates the solution.

Surprisingly by the time the code was written, it was completed in just 8 lines, which included drawing the knights on screens. I added two REM Statements to take it up to 10.

Play it Yourself

You can try the solution on your favourite Amstrad CPC Emulator, Type-It in or run on real hardware, by downloading it the entry here:

https://bunsen.itch.io/knights-tour-amstrad-cpc-by-muckypaws

I use JavaCPC : https://sourceforge.net/projects/javacpc/ though this will work on real hardware, or other Amstrad CPC Emulators.

Here’s the program in action.

I also asked AI to generate a 1980s style cassette cover too… Now… I know AI artwork gets a bit of stick (and sometimes rightly so), but it was interesting to experiment.

One thing I found amusing — no matter how I tweaked the prompts, it consistently failed to correctly number the chessboard. Duplicate numbers, missing values…

Retro-style cassette cover artwork for a Knight’s Tour program on the Amstrad CPC, showing a numbered chessboard, a knight piece, and a glowing path representing the solution across all 64 squares.
A retro-style cassette cover for my BASIC10 2026 entry on the Amstrad CPC. This program solves the classic Knight’s Tour puzzle using Warnsdorff’s heuristic — all in just 8 lines of Locomotive BASIC.

Want to see the code? And yes… it really is just 10 lines:

1 ' Knights Tour - Jason Brooks - BASIC10 - Schau Entry 18th March 2026

2 ' Find me at www.muckypaws.com

3 MODE 1:BORDER 0:PAPER 0:INK 0,0:INK 1,26:INK 2,6:INK 3,18:PEN 1:CLS:DEFINT a-z:DIM b(8,8),dx(8),dy(8):FOR i=1 TO 8:READ dx(i),dy(i
):NEXT:xo=124:yo=4:s=49:h=392:p=3:DATA 2,1,1,2,-1,2,-2,1,-2,-1,-1,-2,1,-2,2,-1

4 INPUT"START X,Y (1-8)";x,y:IF x<1 OR x>8 OR y<1 OR y>8 THEN 4 ELSE CLS:FOR i=0 TO 8:MOVE xo+i*s,yo,1,0:DRAW xo+i*s,yo+h:MOVE xo,yo
+i*s:DRAW xo+h,yo+i*s:NEXT:cx=(xo+(x-1)*s+24) AND 1022:cy=(yo+(y-1)*s+24) AND 510:TAG

5 GOSUB 9:MOVE cx,cy:FILL 2:FOR m=1 TO 64:b(x,y)=m:bt=99:bx=x:by=y:FOR k=1 TO 8:nx=x+dx(k):ny=y+dy(k):IF nx<1 OR nx>8 OR ny<1 OR ny>
8 THEN 8 ELSE IF b(nx,ny)<>0 THEN 8

6 d=0:FOR j=1 TO 8:tx=nx+dx(j):ty=ny+dy(j):IF tx<1 OR tx>8 OR ty<1 OR ty>8 THEN 7 ELSE IF b(tx,ty)=0 THEN d=d+1

7 NEXT j:IF d<bt OR (d=bt AND ABS(nx-4.5)+ABS(ny-4.5)<c) THEN bt=d:c=ABS(nx-4.5)+ABS(ny-4.5):bx=nx:by=ny

8 NEXT k:IF m=64 THEN LOCATE 1,1:PEN 1:TAGOFF:PRINT"DONE":END ELSE IF bt=99 THEN LOCATE 1,1:PEN 2:TAGOFF:PRINT "STUCK AT ";m:END ELS
E x=bx:y=by:nx=xo+(x-1)*s+24:ny=yo+(y-1)*s+24:cx=nx AND 1022:cy=ny AND 510:MOVE cx,cy:GOSUB 9:NEXT m:END

9 RESTORE 10:MOVE cx+4,cy+16:PEN p:READ a,b:WHILE a<>999:DRAWR a,b,p,0:READ a,b:WEND:MOVE cx-36,cy-4:p=m MOD(2)+1:GRAPHICS PEN 3,1:P
RINT m+1;:RETURN

10 DATA 1,-1,2,2,2,1,1,0,1,0,1,0,-2,-5,4,-2,0,-4,7,-11,-4,-3,-2,3,-2,2,-2,1,-4,0,-7,8,-1,-1,4,-4,-1,-3,0,-3,1,-2,2,-2,2,-2,2,-2,0,-2
,2,0,0,-6,-31,0,0,6,2,2,2,14,4,8,5,5,5,2,4,0,2,0,999,999

This was a really enjoyable challenge.

It’s a great reminder of just how capable these older systems and languages were, and how much you can achieve with tight constraints.

Win or lose, this one was fun to build.

And if nothing else, it proves:

Limitations don’t restrict creativity… they force it.

If you want to learn more about the design of the code, all artefacts are available from https://bunsen.itch.io/pavement-panic-amstrad-cpc-by-muckypaws

Let’s see how it does in April.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.