Computer Chess Club Archives


Search

Terms

Messages

Subject: ways to do TSCP shorter

Author: Uri Blass

Date: 08:51:46 06/24/01


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



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.