Skip to main content
minor grammatical issus
Source Link
dreamcrash
  • 1.1k
  • 1
  • 12
  • 24

To me the easy human way it is to start from the square that you want to go to (backtracking approach), lets call it 'A' and exclude from the path calculation the direct linked paths from 'A' that you can't go to because they are attack or there is a piece on it.

For example, you want to go to the square c4, so the directed linked paths will be from by a5, a3, b2, d2, e3, e5, d6 and b6, but if only the square a5 and b6 are available you can reduce your calculation to only to 2 paths now. Furthermore, if you use this "technique" you can check if the target square is reachable at all (if have at least 1 directed linked path not being occupied or attacked).

After doing that, you go to the position where you knight stands and you check which are the squares that you can go to. Using this two phase approach you reduce you tree of calculation immensely.

You should also know beforehand how many moves you need to go from one square to another with your knight, in order to avoid that you calculatethe calculation of larger paths than the ones really need it. I din't check online to find any heuristic for this but I can give you some inside tips about thisit:

  • The Knight on a black square can only go to a white square and vise-versa;versa, in the next move;
  • Every square on the diagonal of the actual square of the Knight can be reach in only two moves. Square (x,y) to the squares (x-1,y+1), (x+1,y+1), (x+1,y-1) and (x-1,y-1) takes 2 moves;
  • The squares up, above, right and left of the actual square takes 3 moves;
  • Every square on the diagonal of the actual square with a one square between them (e.g actual square = c4, target square a6), takes 4 moves.
  • Every square on the diagonal of the actual square with a 2 squares between them (e.g actual square = c4, target square f7), takes only 2 moves.

Finally, if you are in a given color square you will take a odd number of moves to reach the opposite color square. If the target square have the same color as the square that you are in now it will take a even number of moves.

To me the easy human way it is to start from the square that you want to go to (backtracking approach), lets call it 'A' and exclude from the path calculation the direct linked paths from 'A' that you can't go to because they are attack or there is a piece on it.

For example, you want to go to the square c4, so the directed linked paths will be from a5, a3, b2, d2, e3, e5, d6 and b6, but if only the square a5 and b6 are available you can reduce your calculation to only to paths now. Furthermore, if you use this "technique" you can check if the target square is reachable at all (if have at least 1 directed linked path not being occupied or attacked).

After doing that, you go to the position where you knight stands and you check which are the squares that you can go to. Using this two phase approach you reduce you tree of calculation immensely.

You should also know beforehand how many moves you need to go from one square to another with your knight, to avoid that you calculate larger paths than the ones really need it. I din't check online to find any heuristic for this but I can give you some inside tips about this:

  • The Knight on a black square can only go to a white square and vise-versa;
  • Every square on the diagonal of the actual square of the Knight can be reach in only two moves. Square (x,y) to the squares (x-1,y+1), (x+1,y+1), (x+1,y-1) and (x-1,y-1) takes 2 moves;
  • The squares up, above, right and left of the actual square takes 3 moves;
  • Every square on the diagonal of the actual square with a one square between them (e.g actual square = c4, target square a6), takes 4 moves.
  • Every square on the diagonal of the actual square with a 2 squares between them (e.g actual square = c4, target square f7), takes only 2 moves.

Finally, if you are in a given color square you will take a odd number of moves to reach the opposite color square. If the target square have the same color as the square that you are in now it will take a even number of moves.

To me the easy human way it is to start from the square that you want to go to (backtracking approach), lets call it 'A' and exclude from the path calculation the direct linked paths from 'A' that you can't go to because they are attack or there is a piece on it.

For example, you want to go to the square c4, so the directed linked paths will be from by a5, a3, b2, d2, e3, e5, d6 and b6, but if only the square a5 and b6 are available you can reduce your calculation to only to 2 paths now. Furthermore, if you use this "technique" you can check if the target square is reachable at all (if have at least 1 directed linked path not being occupied or attacked).

After doing that, you go to the position where you knight stands and you check which are the squares that you can go to. Using this two phase approach you reduce you tree of calculation immensely.

You should also know beforehand how many moves you need to go from one square to another with your knight, in order to avoid the calculation of larger paths than the ones really need it. I din't check online to find any heuristic for this but I can give you some inside tips about it:

  • The Knight on a black square can only go to a white square and vise-versa, in the next move;
  • Every square on the diagonal of the actual square of the Knight can be reach in only two moves. Square (x,y) to the squares (x-1,y+1), (x+1,y+1), (x+1,y-1) and (x-1,y-1) takes 2 moves;
  • The squares up, above, right and left of the actual square takes 3 moves;
  • Every square on the diagonal of the actual square with a one square between them (e.g actual square = c4, target square a6), takes 4 moves.
  • Every square on the diagonal of the actual square with a 2 squares between them (e.g actual square = c4, target square f7), takes only 2 moves.

Finally, if you are in a given color square you will take a odd number of moves to reach the opposite color square. If the target square have the same color as the square that you are in now it will take a even number of moves.

added 94 characters in body
Source Link
dreamcrash
  • 1.1k
  • 1
  • 12
  • 24

To me the easy human way it is to start from the square that you want to go to (backtracking approach), lets call it 'A', because you can and exclude from the path calculation the direct linked paths from 'A' that you can't go to because they are attack or there is a piece on it. 

For example, you want to go to the square c4square c4, so the directed linked paths will be from a5a5, a3a3, b2b2, d2d2, e3e3, e5e5, d6d6 and b6b6, but if only the square a5a5 and b6b6 are not attackavailable you can reduce your calculation to only to paths now. Furthermore, if you use this "technique" you can check if the target square is reachable at all (if have at least 1 directed linked path not being occupied or attacked).

After doing that, you go to the position where you knight stands and you check which are the squares that you can go to without being attack. Using this two phase approach you reduce you tree of calculation immensely.

You should also know beforehand how many moves you need to go from one square to another with your knight, to avoid that you calculate larger paths than the ones really need it. I din't check online to find any heuristic for this but I can give you some inside tips about this:

-> The Knight on a black square can only go to a white square and vise-versa; -> Every square on the diagonal of the actual square of the Knight can be reach in two only moves. Square (x,y) to the squares (x-1,y+1), (x+1,y+1), (x+1,y-1) and (x-1,y-1) takes 2 moves; -> The squares up, above, right and left of the actual square takes 3 moves; -> Every square on the diagonal of the actual square with a one square between them (e.g actual square = c4, target square a6), takes 4 moves. -> Every square on the diagonal of the actual square with a 2 squares between them (e.g actual square = c4, target square f7), takes only 2 moves.

  • The Knight on a black square can only go to a white square and vise-versa;
  • Every square on the diagonal of the actual square of the Knight can be reach in only two moves. Square (x,y) to the squares (x-1,y+1), (x+1,y+1), (x+1,y-1) and (x-1,y-1) takes 2 moves;
  • The squares up, above, right and left of the actual square takes 3 moves;
  • Every square on the diagonal of the actual square with a one square between them (e.g actual square = c4, target square a6), takes 4 moves.
  • Every square on the diagonal of the actual square with a 2 squares between them (e.g actual square = c4, target square f7), takes only 2 moves.

Finally, if you are thein a given color square you will take a odd number of movesodd number of moves to reach the opposite coloropposite color square. If the target square have the same color as the square that you are in now it will take a even number of moveseven number of moves.

To me the easy human way it is to start from the square that you want to go to (backtracking approach), lets call it 'A', because you can exclude from the path calculation the direct linked paths from 'A' that you can't go to because they are attack. For example, you want to go to the square c4, so the directed linked paths will be from a5, a3, b2, d2, e3, e5, d6 and b6, if only the square a5 and b6 are not attack you reduce your calculation to only to paths now. Furthermore, if you use this "technique" you can check if the square is reachable at all (if have at least 1 directed linked path not attacked).

After doing that, you go to the position where you knight stands and you check which are the squares that you can go to without being attack. Using this two phase approach you reduce you tree of calculation immensely.

You should also know beforehand how many moves you need to go from one square to another with your knight, to avoid that you calculate larger paths than the ones really need it. I din't check online to find any heuristic for this but I can give you some tips about this:

-> The Knight on a black square can only go to a white square and vise-versa; -> Every square on the diagonal of the actual square of the Knight can be reach in two only moves. Square (x,y) to the squares (x-1,y+1), (x+1,y+1), (x+1,y-1) and (x-1,y-1) takes 2 moves; -> The squares up, above, right and left of the actual square takes 3 moves; -> Every square on the diagonal of the actual square with a one square between them (e.g actual square = c4, target square a6), takes 4 moves. -> Every square on the diagonal of the actual square with a 2 squares between them (e.g actual square = c4, target square f7), takes only 2 moves.

Finally, if you are the a given color square you will take a odd number of moves to reach the opposite color square. If the target square have the same color as the square that you are in now it will take a even number of moves.

To me the easy human way it is to start from the square that you want to go to (backtracking approach), lets call it 'A' and exclude from the path calculation the direct linked paths from 'A' that you can't go to because they are attack or there is a piece on it. 

For example, you want to go to the square c4, so the directed linked paths will be from a5, a3, b2, d2, e3, e5, d6 and b6, but if only the square a5 and b6 are available you can reduce your calculation to only to paths now. Furthermore, if you use this "technique" you can check if the target square is reachable at all (if have at least 1 directed linked path not being occupied or attacked).

After doing that, you go to the position where you knight stands and you check which are the squares that you can go to. Using this two phase approach you reduce you tree of calculation immensely.

You should also know beforehand how many moves you need to go from one square to another with your knight, to avoid that you calculate larger paths than the ones really need it. I din't check online to find any heuristic for this but I can give you some inside tips about this:

  • The Knight on a black square can only go to a white square and vise-versa;
  • Every square on the diagonal of the actual square of the Knight can be reach in only two moves. Square (x,y) to the squares (x-1,y+1), (x+1,y+1), (x+1,y-1) and (x-1,y-1) takes 2 moves;
  • The squares up, above, right and left of the actual square takes 3 moves;
  • Every square on the diagonal of the actual square with a one square between them (e.g actual square = c4, target square a6), takes 4 moves.
  • Every square on the diagonal of the actual square with a 2 squares between them (e.g actual square = c4, target square f7), takes only 2 moves.

Finally, if you are in a given color square you will take a odd number of moves to reach the opposite color square. If the target square have the same color as the square that you are in now it will take a even number of moves.

Source Link
dreamcrash
  • 1.1k
  • 1
  • 12
  • 24

To me the easy human way it is to start from the square that you want to go to (backtracking approach), lets call it 'A', because you can exclude from the path calculation the direct linked paths from 'A' that you can't go to because they are attack. For example, you want to go to the square c4, so the directed linked paths will be from a5, a3, b2, d2, e3, e5, d6 and b6, if only the square a5 and b6 are not attack you reduce your calculation to only to paths now. Furthermore, if you use this "technique" you can check if the square is reachable at all (if have at least 1 directed linked path not attacked).

After doing that, you go to the position where you knight stands and you check which are the squares that you can go to without being attack. Using this two phase approach you reduce you tree of calculation immensely.

You should also know beforehand how many moves you need to go from one square to another with your knight, to avoid that you calculate larger paths than the ones really need it. I din't check online to find any heuristic for this but I can give you some tips about this:

-> The Knight on a black square can only go to a white square and vise-versa; -> Every square on the diagonal of the actual square of the Knight can be reach in two only moves. Square (x,y) to the squares (x-1,y+1), (x+1,y+1), (x+1,y-1) and (x-1,y-1) takes 2 moves; -> The squares up, above, right and left of the actual square takes 3 moves; -> Every square on the diagonal of the actual square with a one square between them (e.g actual square = c4, target square a6), takes 4 moves. -> Every square on the diagonal of the actual square with a 2 squares between them (e.g actual square = c4, target square f7), takes only 2 moves.

Finally, if you are the a given color square you will take a odd number of moves to reach the opposite color square. If the target square have the same color as the square that you are in now it will take a even number of moves.