whether or not a piece has moved and how many times

Discussion of chess software programming and technical issues.

Moderators: hgm, Harvey Williamson, bob

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
nionita
Posts: 153
Joined: Fri Oct 22, 2010 7:47 pm
Location: Austria

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

Post by nionita » Tue Jun 12, 2018 7:25 pm

Evert wrote:
Tue Jun 12, 2018 5:16 pm
smcracraft wrote:
Tue Jun 12, 2018 4: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: 746
Joined: Thu Jul 16, 2009 8:47 am
Location: Almere, The Netherlands

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

Post by Joost Buijs » Wed Jun 13, 2018 8:07 am

nionita wrote:
Tue Jun 12, 2018 7:25 pm
Evert wrote:
Tue Jun 12, 2018 5:16 pm
smcracraft wrote:
Tue Jun 12, 2018 4: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.

Post Reply