Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Distance_to_king

Author: Steve Coladonato

Date: 12:28:10 01/28/00

Go up one level in this thread


On January 28, 2000 at 14:57:26, Georg v. Zimmermann wrote:

>My board is set up so that a8 is 0 and h1 is 63. I know where my king is, for
>example whiteKing=60. I want to fill an array[64] with the distance to the king.
>
>Result should be:
>e8 : 7 (squares away = king takes 7 moves to go there)
>h1 : 3
>h8 : 7
>c3 : 2
>
>Do you have a formula to calculate this ?
>
>Thanks,
>
>Georg v. Zimmermann

dist = greatest(abs(trunc(x/8)-trunc(y/8)),abs(mod(x,8)-mod(y,8)))

where x is from square (0-63) and y is to square (0-63)

Steve



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.