lichess.org
Donate

Question regarding the Knight minimal moves pattern.

Here is the same program but with an extended move set:

https://imgur.com/uLTKTaP

Colors used:

https://imgur.com/d2kM6gE
@C4to man I wish I could see the board in those colors like your program. That would be really cool :D Like being Neo
@chessypiano Yeah, it would be cool! Next I would like to do something similar to this visual representation, except the colors would correspond to how much a square is defended. It might bring new insight into old games, maybe if we saw what each chess piece covered, it would look more obvious that certain pieces are positioned a certain way. I would guess it is not all that useful, but you never know!
@C4to it is useful! I did that myself without using a program by drawing it on a paper a certain way. I support your idea :) If you need any design help just pm me :)
@AcabaComigo It's probably easiest to use 64 tables (one table for each square/"house") which lists the number of moves required to reach other squares on the board.

If you looking for an actual formula or algorithm to determine the number of moves, I would be inclined to use graph theory - which views the problem as finding the shortest path in an unweighted graph. You could use a knight's graph (all possible knight moves) as a basis for exploring algorithms to solve the problem.

https://i.imgur.com/nnpPIuU.png

There might also be a way to determine the moves required to reach a target square based on euclidean distance. For example, if the shortest move of a rook is 1, then the move distance a king is either 1 or sqrt(2) while a knight moves a distance of sqrt(5). But the thought of determining a discrete number of moves given the euclidean distance of two squares gives me a headache, so I can't help you there.
A higher definition image on an 80 x 80 board:

https://imgur.com/faR9zuM

Same thing, but on a 96 x 96 board, but with a longer color list:

https://imgur.com/neVZAFj

Now, I think there is a way to find the number of moves for any distance, but it is a bit convoluted. Notice how the board seems to be divided in 8 lines, whose gradients are 2:1 (corresponding to how a Knight moves). Thus you could divide the board into 8 parts, but 4 of these parts (the diagonal and perpendicular segments) are rotationally 4 fold symmetrical. So you would then say, if the gradient is between 22.5 degrees and 67.5 degrees (or when 1/2 < ceiling( y/x ) < 2) then do something, and if the gradient is between 337.5 and 22.5 degrees (or when -1/2 < ceiling( y/x ) < 1/2) , then do something else. The edge cases would have to be studied in more detail.

The number of steps it takes to get to a certain point seems to grow linearly as you go out. Additionally, if you want a mathematical way to express checkered patterns, say you have a square with coordinates x and y, and take the modulus ( a fancy way of saying remainder ) of the sum of the two by 2, every square will have a value of 1 or 0, corresponding to a checker patter. TLDR: The remainder of (x+y) divided by 2 will return either a 1 or a 0 in a checkerboard pattern for all x and y.

I think with those elements you should have a way to mathematically how many moves a Knight is from a certain square. Do tell me if you flesh it out, because my program has been running brute force and it takes a couple of minutes to generate an image like this.

code:

pastebin.com/Vi3Nemqg

The color gradient functions I used are taken from this site:

bsou.io/posts/color-gradients-with-python

A pregenerated list for all the positions the Knight can go to in 44 moves or less:

pastebin.com/tZDizCip
Hmm... I did not expect people would be so supportive with my idea, so thank you pals.
@ClaireWerk I do not know about inequations...
@tpr Do you mean something like: AI to H1: The intersection would be H8; the distance between A1 to H1 is the same as A1 to H8 or H1 to H8? It seems a nice proposition. I am going to analyse it right after I respond people comments here.
@Skittle-Head My problem is not the Knight tour problem.
@C4to I have tried to make once a program for this in JavaScript, but it was full of exceptions and it was not working properly, so I passed to dedicate myself in trying to find a formula because I got cringed by the code. By the way, I have made a graph like that in Microsoft Paint, while I was trying to discover the formula.
imgur.com/a/OX6SKah
@clutchnutz Where did you take the idea of square root? By the way, the rook can reach any house in an empty board within at last two moves.
@C4to Each house will have a value of 1 or 0 in this case. So? I guess it would be more useful if the modulus was between the distance in row between the initial position row and the target position row PLUS the diference between the distance in column between the initial position column and the target position column.
@AcabaComigo I feel like my efforts have fallen on deaf ears.

Well its clear to see that if you continue travelling in the positive x direction, then the pattern is regular, but if you go up and down in the y axis, the value changes depending on whether y is odd or even. The color bands change every 2 units, so clearly, if we are just looking at x and y that are integer numbers such that |x|,|y| > 4 and -1/2 <|y|/|x| < 1/2, then the minimum number of moves it takes to get to a square with coordinates (x, y) is ceiling(|x|/2) + (|x|+|y|) mod 2 in the x direction, and ceiling(|y|/2) + (|x|+|y|) mod 2 in the y direction, and this formula actually correctly predicts the number of moves with the given limitations on x and y. You already have a formula for the diagonal case, so really you just have to look at the formula for when it's ambiguous.
@C4to I said "So" because what you said seemed to be rethorical, so I would like to know the further implications of what you said that could have substance, mathmatically speaking. By the way, what do you mean by "-1/2 <|y|/|x|" and what is the reasoning behind it?
@C4to Are you sure about -1/2 <|y|/|x| < 1/2? Id argue that even 0 <= |y|/|x|, sharpening your bound ;)

This topic has been archived and can no longer be replied to.