Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Knight jumps

Author: Kolss

Date: 07:18:59 11/17/05

Go up one level in this thread


On November 17, 2005 at 09:29:39, Jarkko Pesonen wrote:

>Is there any simple algorithm to calculate
>how many jumps it takes for knight to get some specific square?
>
>Or any simple precalculated table structure.
>
>Thanks
>
>Jarkko Pesonen

Hi,

It depends a bit on your data structures. E.g., in 0x88, you can precalculate an
array 0..127 (119), and store the number of moves a knight needs to get from
square1 to square2 in array[Abs(square1 - square2)]. I.e., it takes the same
number of moves from a1 to d6 as it takes from b1 to e6 or from a2 to d7 or from
d6 to a1, you index by the (absolute value of the) difference in square numbers.
Of course, this does not take into account blocked squares (e.g. occupied by own
pawn or attacked by opponent pawn) on the way to the desired square.
If you are looking for a formula, I am not sure if you can find a really easy
one. Anyway, the first step would be to write out the array and try and see a
pattern...
I hope this helps!

Best regards - Munjong.



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.