whether or not a piece has moved and how many times

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

nionita
Posts: 175
Joined: Fri Oct 22, 2010 9:47 pm
Location: Austria

Re: whether or not a piece has moved and how many times

Post by nionita »

Evert wrote: Tue Jun 12, 2018 7:16 pm
smcracraft wrote: Tue Jun 12, 2018 6:08 am Curious about how others have implemented calculation of how many times each piece has moved since the beginning of the game.

The concern is when a piece has been captured in a make move and then uncaptured and updating the array.

How did you solve this?
I'd do it the same way I handle the 50-move counter, or castling rights.
Question remains, why do you want this information? If it's for something evaluation or move ordering related, you're probably on the wrong track.
I must confess, I tried something similar (but simpler) for move ordering. (Moves with last moving piece were scored a bit less.) The rejection of the idea was cheap :-)
Joost Buijs
Posts: 1563
Joined: Thu Jul 16, 2009 10:47 am
Location: Almere, The Netherlands

Re: whether or not a piece has moved and how many times

Post by Joost Buijs »

nionita wrote: Tue Jun 12, 2018 9:25 pm
Evert wrote: Tue Jun 12, 2018 7:16 pm
smcracraft wrote: Tue Jun 12, 2018 6:08 am Curious about how others have implemented calculation of how many times each piece has moved since the beginning of the game.

The concern is when a piece has been captured in a make move and then uncaptured and updating the array.

How did you solve this?
I'd do it the same way I handle the 50-move counter, or castling rights.
Question remains, why do you want this information? If it's for something evaluation or move ordering related, you're probably on the wrong track.
I must confess, I tried something similar (but simpler) for move ordering. (Moves with last moving piece were scored a bit less.) The rejection of the idea was cheap :-)
I guess we all tried something like this in the beginning. 40 years ago when I wrote my first engine in assembler each piece contained a flag signalling whether it had moved or not, and during the opening phase I gave preference to move with pieces that had not moved before. However, I soon found out that it helped nothing at all and that it was only redundant code slowing things down. At that time speed was very important, as I recall my first engine did 700 n/s on a 2 MHz. Intel 8080.