Author: Andrew Dados
Date: 12:11:14 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 = max(abs(krank-sqrank),abs(kfile-sqfile)) where kfile,krank is file and rank of king (kingsquare and 7; kingsquare div 8, respectively) and sqrank and sqfile is same for given square. you may want to optimize above for speed; in my 0x88 representation I have dist array precalculated. Andrew
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.