[Graphical display of shortest knight paths]
If you would repeat this for a board 50 squares on a side, I believe some interesting patterns might show up.
Step 0 to 15 on a 50x50 board:
-
[Graphical display of shortest knight paths]
If you would repeat this for a board 50 squares on a side, I believe some interesting patterns might show up.
Step 0 to 15 on a 50x50 board:
-
I did it in a pretty inelegant brute force way... the program iterates through every square on the grid and check if that square has a "neighbor" with a value (a neighbor is a square one knight move away). In the beginning the only square with a value is the starting square (value zero) so only 8 squares have "neighbors."
If a square has a neighbor it's assigned a value one higher than the value of its lowest neighbor.
After that, the program iterates through every square again. It stops when all squares have been given a value.
This isn't nearly as useful as a function because, for example, something as "small" as a 1000x1000 board is already one million values.
And obviously you programmed it for no repetition of positions.
I guess mapping it for e.g. 3 moves and fewer creates some unique patterns too.
Once again, after a few steps of expanding, the pattern is pretty boring.
-
-
Once again, after a few steps of expanding, the pattern is pretty boring.
The boring patterns might become quite interesting if the squares could be color-coded for path length as in #61.
Once again, after a few steps of expanding, the pattern is pretty boring.
The boring patterns might become quite interesting if the squares could be color-coded for path length as in #61.
-
Maybe a bit easier to see? I don't want to spend a long time messing with colors.
It looks good, and you beat me to it. For what it's worth, here's a program you can run on QuiteBASIC that will plot the knight shortest path lengths by color for a 73 by 73 board. Before running it, in the Canvas window resize to Big 75x75.
1 print "Shortest knight trips by color on a 73 X 73 board"
2 print " "
3 print "0 black, 1 white, 2 magenta, 3 green, 4 yellow,"
4 print "5 cyan, 6 red, 7 blue, 8 orange, 9 white"
5 print " "
6 print "Colors repeat in same order from 10 up"
10 ARRAY P
20 LET P[0] = "black"
25 LET P[1] = "white"
30 LET P[2] = "magenta"
40 LET P[3] = "green"
50 LET P[4] = "yellow"
60 LET P[5] = "cyan"
70 LET P[6] = "red"
80 LET P[7] = "blue"
90 LET P[8] = "orange"
91 LET P[9] = "white"
92 for x=0 to 36
94 for y=0 to x
100 if x=1 and y=0 then goto 500
110 if x=2 and y=2 then goto 600
120 if 2*y>x then goto 700
130 let m=x-y-2*floor((x-2*y)/4)
140 goto 800
500 let m=3
510 goto 800
600 let m=4
610 goto 800
700 let m=x-y+2*floor((2*y-x+2)/3)
800 let m=m-10*floor(m/10)
805 plot 36+x, 36+y, P(m)
810 plot 36-x, 36+y, P(m)
820 plot 36+x, 36-y, P(m)
830 plot 36-x, 36-y, P(m)
840 plot 36+y, 36+x, P(m)
850 plot 36-y, 36+x, P(m)
860 plot 36+y, 36-x, P(m)
870 plot 36-y, 36-x, P(m)
900 next y
910 next x
920 end
It looks good, and you beat me to it. For what it's worth, here's a program you can run on QuiteBASIC that will plot the knight shortest path lengths by color for a 73 by 73 board. Before running it, in the Canvas window resize to Big 75x75.
1 print "Shortest knight trips by color on a 73 X 73 board"
2 print " "
3 print "0 black, 1 white, 2 magenta, 3 green, 4 yellow,"
4 print "5 cyan, 6 red, 7 blue, 8 orange, 9 white"
5 print " "
6 print "Colors repeat in same order from 10 up"
10 ARRAY P
20 LET P[0] = "black"
25 LET P[1] = "white"
30 LET P[2] = "magenta"
40 LET P[3] = "green"
50 LET P[4] = "yellow"
60 LET P[5] = "cyan"
70 LET P[6] = "red"
80 LET P[7] = "blue"
90 LET P[8] = "orange"
91 LET P[9] = "white"
92 for x=0 to 36
94 for y=0 to x
100 if x=1 and y=0 then goto 500
110 if x=2 and y=2 then goto 600
120 if 2*y>x then goto 700
130 let m=x-y-2*floor((x-2*y)/4)
140 goto 800
500 let m=3
510 goto 800
600 let m=4
610 goto 800
700 let m=x-y+2*floor((2*y-x+2)/3)
800 let m=m-10*floor(m/10)
805 plot 36+x, 36+y, P(m)
810 plot 36-x, 36+y, P(m)
820 plot 36+x, 36-y, P(m)
830 plot 36-x, 36-y, P(m)
840 plot 36+y, 36+x, P(m)
850 plot 36-y, 36+x, P(m)
860 plot 36+y, 36-x, P(m)
870 plot 36-y, 36-x, P(m)
900 next y
910 next x
920 end
Nice. I like that there's more contrast to your image.
I've never done anything in BASIC, but it looks neat. I guess it's a high level language, but it's reminiscent of really old school stuff with what looks like addresses at the front and e.g. 'goto' commands.
Yes, BASIC is really old, first released in 1964, and was a precursor to many more modern languages that have replaced it. I'm using it because I came across that handy online interpreter for it. I don't think it's great for beginners because its lack of structure could teach some bad programming habits.
Since your present location is somewhere, and exists as a subset of "anywhere" you could also say it takes zero moves.
One move.
This is the correct answer to the question "How many moves does a knight need to get somewhere?". It only takes one move to get anywhere.
This is just wrong. As llama 47 pointed out, the knight is already somewhere, so it takes no moves to get there.
You remind me of @thee_ghostess_lola you like to have fun and are maybe a bit trolly.
Does that not remind you of somebody else?
hopefully my thesis is right
Your thesis seems totally sound to me.