Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: ways to do TSCP shorter

Author: Robert Hyatt

Date: 09:06:16 06/25/01

Go up one level in this thread


On June 24, 2001 at 11:51:46, Uri Blass wrote:

>1)I find this code in the latest version of TSCP in the takeback function in
>board.c:
>
>if (hist_dat[hply].capture == EMPTY) {
>  color[(int)m.to] = EMPTY;
>  piece[(int)m.to] = EMPTY;
> }
> else {
>  color[(int)m.to] = xside;
>  piece[(int)m.to] = hist_dat[hply].capture;
> }
>
>The following code is shorter
>
>piece[(int)m.to]=hist_dat[hply].capture;
> if (hist_dat[hply].capture==EMPTY)
>     color[(int)m.to]=EMPTY;
> else
>     color[(int)m.to]=xside;
>
>2)I find this code also in board.c in the takeback function/
>
>if (side == LIGHT) {
>   color[m.to + 8] = xside;
>   piece[m.to + 8] = PAWN;
>  }
>  else {
>   color[m.to - 8] = xside;
>   piece[m.to - 8] = PAWN;
>  }
>
>The following code is shorter inspite of adding some comments
>
>//if we get here then side=LIGHT or side=DARK
>//side<<4=0 for side=LIGHT so m.to+8-(side<<4) is m.to+8 in this case
>//side<<4=16 for side=DARK so m.to+8-(side<<4) is m.to-8 in this case
>color[m.to+8-(side<<4)]=xside;
>piece[m.to+8-(side<<4)]=PAWN;
>
>Uri

One golden rule to remember when writing programs of any kind:

shorter does _not_ imply faster.




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.