[gcompris] minor: fixed our internal gnuchess to compile with recent GCC (4.6).



commit 88825a60297d7944cc4efc38b59fae7d847f02c5
Author: Bruno Coudoin <bruno coudoin free fr>
Date:   Tue Mar 27 02:06:29 2012 +0200

    minor: fixed our internal gnuchess to compile with recent GCC (4.6).

 src/chess_computer-activity/gnuchess/Makefile.am   |    5 +-
 src/chess_computer-activity/gnuchess/epd.c         |   96 ++++++------
 src/chess_computer-activity/gnuchess/eval.c        |  163 +++++++++----------
 src/chess_computer-activity/gnuchess/genmove.c     |   65 ++++----
 .../gnuchess/gnome-gnuchess                        |  Bin 245180 -> 0 bytes
 src/chess_computer-activity/gnuchess/input.c       |   17 +-
 src/chess_computer-activity/gnuchess/lexpgn.c      |    2 +-
 src/chess_computer-activity/gnuchess/players.c     |   20 +--
 src/chess_computer-activity/gnuchess/search.c      |   85 +++++------
 src/chess_computer-activity/gnuchess/test.c        |   41 +++---
 10 files changed, 236 insertions(+), 258 deletions(-)
---
diff --git a/src/chess_computer-activity/gnuchess/Makefile.am b/src/chess_computer-activity/gnuchess/Makefile.am
index d59a7ea..fda3419 100644
--- a/src/chess_computer-activity/gnuchess/Makefile.am
+++ b/src/chess_computer-activity/gnuchess/Makefile.am
@@ -7,6 +7,7 @@ gcompris_gnuchess_SOURCES = atak.c book.c cmd.c debug.c epd.c eval.c genmove.c \
  swap.c test.c ttable.c util.c common.h book.h eval.h getopt.h \
  inlines.h version.h lexpgn.c lexpgn.h
 
-gcompris_gnuchess_CFLAGS = $(PTHREAD_CFLAGS) $(AM_CFLAGS)
+gcompris_gnuchess_CFLAGS = $(AM_CFLAGS)
 
-gcompris_gnuchess_LDFLAGS = $(PTHREAD_LDFLAGS) $(PTHREAD_LIBS) $(AM_LDFLAGS)
+# FIXME We only need pthread but we use GCOMPRIS_LIBS.
+gcompris_gnuchess_LDFLAGS = $(GCOMPRIS_LIBS) $(AM_LDFLAGS)
diff --git a/src/chess_computer-activity/gnuchess/epd.c b/src/chess_computer-activity/gnuchess/epd.c
index 97f76e4..c572b0f 100644
--- a/src/chess_computer-activity/gnuchess/epd.c
+++ b/src/chess_computer-activity/gnuchess/epd.c
@@ -1,7 +1,7 @@
 /* GNU Chess 5.0 - epd.c - EPD position definition code
    Copyright (c) 1999-2002 Free Software Foundation, Inc.
 
-   GNU Chess is based on the two research programs 
+   GNU Chess is based on the two research programs
    Cobalt by Chua Kong-Sian and Gazebo by Stuart Cracraft.
 
    GNU Chess is free software; you can redistribute it and/or modify
@@ -19,7 +19,7 @@
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
 
-   Contact Info: 
+   Contact Info:
      bug-gnu-chess gnu org
 */
 /*
@@ -40,8 +40,8 @@ short ReadEPDFile (const char *file, short op)
  *  Reads in an EPD file.  The first call will read the first EPD line,
  *  the second call will read the 2nd line and so on.   To improve
  *  performance, the file is never closed.  Closing of the file happens
- *  only on 2 conditions:  (i) A ReadEPDFile failed because there is no 
- *  more lines to read.  (ii) A called to ReadEPDFile to explicitly 
+ *  only on 2 conditions:  (i) A ReadEPDFile failed because there is no
+ *  more lines to read.  (ii) A called to ReadEPDFile to explicitly
  *  request that the file is closed (op = EPDCLOSE);
  *  If op == 2, then we work silently.
  *
@@ -62,8 +62,8 @@ short ReadEPDFile (const char *file, short op)
    }
 
    /*  Is this a close request? */
-   if (op == EPDCLOSE)   
-   { 
+   if (op == EPDCLOSE)
+   {
       fclose (fp);
       fp = NULL;
       return (false);
@@ -71,23 +71,25 @@ short ReadEPDFile (const char *file, short op)
 
 next_line:
    /*  Okay, we read in an EPD entry  */
-   fgets (line, MAXSTR-1, fp);
-   if (!feof(fp)) 
    {
-      int ret = ParseEPD (line);
-
-      /* For now just ignore malformed lines */
-      if (ret != EPD_SUCCESS) goto next_line;
-      if (op != 2)
-         printf ("\n%s : Best move = %s\n", id, solution);
-      return (true);
-   }
-   /* finished, must close file */
-   else
-   { 
-      fclose (fp);
-      fp = NULL;
-      return (false);
+     char *liner = fgets (line, MAXSTR-1, fp);
+     if (liner)
+       {
+	 int ret = ParseEPD (liner);
+
+	 /* For now just ignore malformed lines */
+	 if (ret != EPD_SUCCESS) goto next_line;
+	 if (op != 2)
+	   printf ("\n%s : Best move = %s\n", id, solution);
+	 return (true);
+       }
+     /* finished, must close file */
+     else
+       {
+	 fclose (fp);
+	 fp = NULL;
+	 return (false);
+       }
    }
 }
 
@@ -100,7 +102,7 @@ next_line:
 
 int ParseEPD (char *p)
 /**************************************************************************
- *   
+ *
  *  Parses an EPD input line.  A few global variables are updated e.g.
  *  current board, side to move, en passant, castling status, etc.
  *
@@ -123,71 +125,71 @@ int ParseEPD (char *p)
 		    SETBIT (board.blockerr45, r45[sq]);
 		    SETBIT (board.blockerr315, r315[sq]);
 		    board.material[white] += ValueP;
-		    break;	
+		    break;
         case 'N' :  SETBIT (board.b[white][knight], sq);
 		    SETBIT (board.blockerr90, r90[sq]);
 		    SETBIT (board.blockerr45, r45[sq]);
 		    SETBIT (board.blockerr315, r315[sq]);
 		    board.material[white] += ValueN;
-		    break;	
+		    break;
         case 'B' :  SETBIT (board.b[white][bishop], sq);
 		    SETBIT (board.blockerr90, r90[sq]);
 		    SETBIT (board.blockerr45, r45[sq]);
 		    SETBIT (board.blockerr315, r315[sq]);
 		    board.material[white] += ValueB;
-		    break;	
+		    break;
         case 'R' :  SETBIT (board.b[white][rook], sq);
 		    SETBIT (board.blockerr90, r90[sq]);
 		    SETBIT (board.blockerr45, r45[sq]);
 		    SETBIT (board.blockerr315, r315[sq]);
 		    board.material[white] += ValueR;
-		    break;	
+		    break;
         case 'Q' :  SETBIT (board.b[white][queen], sq);
 		    SETBIT (board.blockerr90, r90[sq]);
 		    SETBIT (board.blockerr45, r45[sq]);
 		    SETBIT (board.blockerr315, r315[sq]);
 		    board.material[white] += ValueQ;
-		    break;	
+		    break;
         case 'K' :  SETBIT (board.b[white][king], sq);
 		    SETBIT (board.blockerr90, r90[sq]);
 		    SETBIT (board.blockerr45, r45[sq]);
 		    SETBIT (board.blockerr315, r315[sq]);
-		    break;	
+		    break;
         case 'p' :  SETBIT (board.b[black][pawn], sq);
 		    SETBIT (board.blockerr90, r90[sq]);
 		    SETBIT (board.blockerr45, r45[sq]);
 		    SETBIT (board.blockerr315, r315[sq]);
 		    board.material[black] += ValueP;
-		    break;	
+		    break;
         case 'n' :  SETBIT (board.b[black][knight], sq);
 		    SETBIT (board.blockerr90, r90[sq]);
 		    SETBIT (board.blockerr45, r45[sq]);
 		    SETBIT (board.blockerr315, r315[sq]);
 		    board.material[black] += ValueN;
-		    break;	
+		    break;
         case 'b' :  SETBIT (board.b[black][bishop], sq);
 		    SETBIT (board.blockerr90, r90[sq]);
 		    SETBIT (board.blockerr45, r45[sq]);
 		    SETBIT (board.blockerr315, r315[sq]);
 		    board.material[black] += ValueB;
-		    break;	
+		    break;
         case 'r' :  SETBIT (board.b[black][rook], sq);
 		    SETBIT (board.blockerr90, r90[sq]);
 		    SETBIT (board.blockerr45, r45[sq]);
 		    SETBIT (board.blockerr315, r315[sq]);
 		    board.material[black] += ValueR;
-		    break;	
+		    break;
         case 'q' :  SETBIT (board.b[black][queen], sq);
 		    SETBIT (board.blockerr90, r90[sq]);
 		    SETBIT (board.blockerr45, r45[sq]);
 		    SETBIT (board.blockerr315, r315[sq]);
                     board.material[black] += ValueQ;
-		    break;	
+		    break;
         case 'k' :  SETBIT (board.b[black][king], sq);
 		    SETBIT (board.blockerr90, r90[sq]);
 		    SETBIT (board.blockerr45, r45[sq]);
 		    SETBIT (board.blockerr315, r315[sq]);
-		    break;	
+		    break;
         case '/' :  r -= 8;
 	 	    c = -1;
 		    break;
@@ -198,7 +200,7 @@ int ParseEPD (char *p)
      else
         c++;
 
-     /* 
+     /*
       * Special case, a trailing "/" is accepted on the
       * end of the board settings.
       */
@@ -211,25 +213,25 @@ int ParseEPD (char *p)
      p++;
    }
 
-   board.pmaterial[white] = board.material[white] - 
+   board.pmaterial[white] = board.material[white] -
 				nbits(board.b[white][pawn]) * ValueP;
-   board.pmaterial[black] = board.material[black] - 
+   board.pmaterial[black] = board.material[black] -
 				nbits(board.b[black][pawn]) * ValueP;
    board.king[white] = leadz (board.b[white][king]);
    board.king[black] = leadz (board.b[black][king]);
-   UpdateFriends (); 
+   UpdateFriends ();
    UpdateCBoard ();
    UpdateMvboard ();
 
    /*  Get side to move  */
    if (!++p) return EPD_ERROR;
-   if      (*p == 'w') board.side = white; 
+   if      (*p == 'w') board.side = white;
    else if (*p == 'b') board.side = black;
    else return EPD_ERROR;
 
    /* Isn't this one cute? */
    if (!++p || *p != ' ' || !++p) return EPD_ERROR;
-  
+
    /*  Castling status  */
    while (p && *p != ' ') {
       if      (*p == 'K') board.flag |= WKINGCASTLE;
@@ -264,7 +266,7 @@ int ParseEPD (char *p)
 
    /*  Read in best move; "bm" operator */
    str_p = strstr(p, "bm");
-   if (str_p) sscanf (str_p, "bm %63[^;];", solution); 
+   if (str_p) sscanf (str_p, "bm %63[^;];", solution);
 
    /*  Read in the description; "id" operator */
    str_p = strstr(p, "id");
@@ -279,7 +281,7 @@ int ParseEPD (char *p)
 
 void LoadEPD (char *p)
 /**************************************************************************
- *   
+ *
  *  This routine reads in the next or the Nth position in the file.
  *
  **************************************************************************/
@@ -293,14 +295,14 @@ void LoadEPD (char *p)
       ReadEPDFile (file, 0);
    }
    else
-   { 
+   {
       ReadEPDFile (file, 1);
       while (--N)
       {
          if (ReadEPDFile (file, 2) == false)
          {
 	    printf ("File position exceeded\n");
-	    return; 
+	    return;
          }
       }
       ReadEPDFile (file, 0);
@@ -312,7 +314,7 @@ void LoadEPD (char *p)
 
 void SaveEPD (char *p)
 /**************************************************************************
- *   
+ *
  *  This routine appends the current position in EPD format into a file.
  *
  **************************************************************************/
@@ -334,7 +336,7 @@ void SaveEPD (char *p)
 	    k++;
 	 else
 	 {
-	    if (k) 
+	    if (k)
 	       fprintf (fp, "%1d", k);
 	    k = 0;
 	    c1 = notation[cboard[sq]];
diff --git a/src/chess_computer-activity/gnuchess/eval.c b/src/chess_computer-activity/gnuchess/eval.c
index c3e72ff..fb5af0a 100644
--- a/src/chess_computer-activity/gnuchess/eval.c
+++ b/src/chess_computer-activity/gnuchess/eval.c
@@ -1,7 +1,7 @@
 /* GNU Chess 5.0 - eval.c - evaluation code
    Copyright (c) 1999-2002 Free Software Foundation, Inc.
 
-   GNU Chess is based on the two research programs 
+   GNU Chess is based on the two research programs
    Cobalt by Chua Kong-Sian and Gazebo by Stuart Cracraft.
 
    GNU Chess is free software; you can redistribute it and/or modify
@@ -19,7 +19,7 @@
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
 
-   Contact Info: 
+   Contact Info:
      bug-gnu-chess gnu org
      cracraft ai mit edu, cracraft stanfordalumni org, cracraft earthlink net
 */
@@ -47,7 +47,7 @@ int DoubleQR7 (short);
 BitBoard passed[2];
 BitBoard weaked[2];
 
-static int PawnSq[2][64] = 
+static int PawnSq[2][64] =
 {
 {  0,  0,  0,  0,  0,  0,  0,  0,
    5,  5,  5,-10,-10,  5,  5,  5,
@@ -99,8 +99,8 @@ int ScoreP (short side)
  *  2.  Passed pawns.
  *  3.  Backward pawns.
  *  4.  Pawn base under attack.
- *  5.  Doubled pawns 
- *  6.  Isolated pawns 
+ *  5.  Doubled pawns
+ *  6.  Isolated pawns
  *  7.  Connected passed pawns on 6/7th rank.
  *  8.  Unmoved & blocked d, e pawn
  *  9.  Passed pawn which cannot be caught.
@@ -112,14 +112,12 @@ int ScoreP (short side)
    int s, sq, i, i1;
    int n1, n2, backward;
    int nfile[8];
-   int EnemyKing;
-   BitBoard c, t, p, blocker, *e;
+   BitBoard c, t, p, blocker;
    PawnSlot *ptable;
 
    if (board.b[side][pawn] == NULLBITBOARD)
       return (0);
    xside = 1^side;
-   EnemyKing = board.king[xside];
    p = board.b[xside][pawn];
    c = t = board.b[side][pawn];
    ptable = PawnTab[side] + (PawnHashKey & PHashMask);
@@ -130,7 +128,7 @@ int ScoreP (short side)
       s = ptable->score;
       passed[side] = ptable->passed;
       weaked[side] = ptable->weaked;
-      goto phase2; 
+      goto phase2;
    }
 
    s = 0;
@@ -141,13 +139,13 @@ int ScoreP (short side)
    {
       sq = leadz (t);
       CLEARBIT (t, sq);
-      s += PawnSq[side][sq]; 
+      s += PawnSq[side][sq];
 
       /*  Passed pawns  */
       if ((p & PassedPawnMask[side][sq]) == NULLBITBOARD)
       {
 	 if ((side == white && (FromToRay[sq][sq|56] & c) == 0) ||
-	     (side == black && (FromToRay[sq][sq&7] & c) == 0)) 
+	     (side == black && (FromToRay[sq][sq&7] & c) == 0))
          {
             passed[side] |= BitPosArray[sq];
             s += (Passed[side][RANK(sq)] * phase) / 12;
@@ -191,7 +189,7 @@ int ScoreP (short side)
       /* Pawn base under attack */
       if ((MoveArray[ptype[side]][sq] & p) && (MoveArray[ptype[side]][sq] & c))
          s += PAWNBASEATAK;
- 
+
       /*  Increment file count for isolani & doubled pawn evaluation */
       nfile[ROW(sq)]++;
    }
@@ -238,7 +236,7 @@ int ScoreP (short side)
   }
 
 
-   /* Save the score into the pawn hash table */ 
+   /* Save the score into the pawn hash table */
    ptable->pkey = KEY(PawnHashKey);
    ptable->passed = passed[side];
    ptable->weaked = weaked[side];
@@ -246,9 +244,9 @@ int ScoreP (short side)
    ptable->phase = phase;
 
 /***************************************************************************
- *  
+ *
  *  This section of the pawn code cannot be saved into the pawn hash as
- *  they depend on the position of other pieces.  So they have to be 
+ *  they depend on the position of other pieces.  So they have to be
  *  calculated again.
  *
  ***************************************************************************/
@@ -257,7 +255,7 @@ phase2:
    /* Pawn on f6/c6 with Queen against castled king is very strong */
    c = board.b[side][pawn];
    sq = board.king[xside];
-   if (side == white && board.b[side][queen] && 
+   if (side == white && board.b[side][queen] &&
 	(BitPosArray[C6] | BitPosArray[F6]) & c)
    {
       if (c & BitPosArray[F6] && sq > H6 && distance[sq][G7]==1)
@@ -276,7 +274,7 @@ phase2:
 
    /* Connected passed pawns on 6th or 7th rank */
    t = passed[side] & brank67[side];
-   if (t && (board.pmaterial[xside] == ValueR || 
+   if (t && (board.pmaterial[xside] == ValueR ||
 	(board.pmaterial[xside] == ValueN &&
 	pieces[xside] == board.b[xside][knight])))
    {
@@ -300,7 +298,6 @@ phase2:
    /* Enemy has no pieces & King is outside of passed pawn square */
    if (passed[side] && board.pmaterial[xside]==0)
    {
-      e = board.b[xside];
       i1 = board.king[xside];
       p = passed[side];
       while (p)
@@ -407,7 +404,6 @@ int ScoreN (short side)
 {
    int xside;
    int s, s1, sq;
-   int EnemyKing;
    BitBoard c, t;
 
    if (board.b[side][knight] == NULLBITBOARD)
@@ -415,8 +411,7 @@ int ScoreN (short side)
    xside = side^1;
    s = s1 = 0;
    c = board.b[side][knight];
-   t = board.b[xside][pawn]; 
-   EnemyKing = board.king[xside];
+   t = board.b[xside][pawn];
 
    if ( c & pinned )
    {
@@ -430,11 +425,11 @@ int ScoreN (short side)
 
       /* Control */
       s1 = CTL(sq,knight,side);
-  
+
       if ( (BitPosArray[sq] & rings[3]) != NULLBITBOARD)
 	s1 += KNIGHTONRIM;
 
-      if (Outpost[side][sq] && 
+      if (Outpost[side][sq] &&
 	  !(t & IsolaniMask[ROW(sq)] & PassedPawnMask[side][sq]) )
       {
          s1 += OUTPOSTKNIGHT;
@@ -443,7 +438,7 @@ int ScoreN (short side)
          if (MoveArray[ptype[xside]][sq] & board.b[side][pawn])
             s1 += OUTPOSTKNIGHT;
       }
-    
+
       /* Attack on weak opponent pawns */
       if (MoveArray[knight][sq] & weaked[xside])
          s1 += ATAKWEAKPAWN;
@@ -467,7 +462,7 @@ int ScoreB (short side)
  ****************************************************************************/
 {
    int xside;
-   int s, s1, n, sq, EnemyKing;
+   int s, s1, n, sq;
    BitBoard c, t;
 
    if (board.b[side][bishop] == NULLBITBOARD)
@@ -475,7 +470,6 @@ int ScoreB (short side)
    s = s1 = 0;
    c = board.b[side][bishop];
    xside = side ^ 1;
-   EnemyKing = board.king[xside];
    n = 0;
    t = board.b[xside][pawn];
 
@@ -494,7 +488,7 @@ int ScoreB (short side)
       s1 = CTL(sq,bishop,side);
 
       /*  Outpost bishop */
-      if (Outpost[side][sq] && 
+      if (Outpost[side][sq] &&
 	  !(t & IsolaniMask[ROW(sq)] & PassedPawnMask[side][sq]))
       {
          s1 += OUTPOSTBISHOP;
@@ -528,7 +522,7 @@ int ScoreB (short side)
    }
 
    /* Doubled bishops */
-   if (n > 1)            
+   if (n > 1)
       s += DOUBLEDBISHOPS;
 
    return (s);
@@ -547,7 +541,7 @@ int BishopTrapped (short side)
 
    /* Don't waste time */
    if (board.b[side][bishop] == NULLBITBOARD)
-     return (0); 
+     return (0);
 
    if (side == white)
    {
@@ -650,7 +644,7 @@ int DoubleQR7 (short side)
 /***************************************************************************
  *
  *  This code just check to see if there is a QQ or QR or RR combo on the
- *  7th rank.  This is very strong and given quite a big bonus.  This 
+ *  7th rank.  This is very strong and given quite a big bonus.  This
  *  routine is called by the lazy section.
  *
  ***************************************************************************/
@@ -659,7 +653,7 @@ int DoubleQR7 (short side)
 
    xside = 1^side;
    if (nbits ((board.b[side][queen]|board.b[side][rook]) & brank7[side]) > 1
-      && ((board.b[xside][king] & brank8[side]) || 
+      && ((board.b[xside][king] & brank8[side]) ||
 	  (board.b[xside][pawn] & brank7[side])))
 
       return (ROOKS7RANK);
@@ -679,7 +673,7 @@ int ScoreQ (short side)
    int xside;
    int s, s1, sq, EnemyKing;
    BitBoard c;
-   
+
    s = s1 = 0;
 
    /* Try to keep our queen on the board for attacking purposes. */
@@ -688,7 +682,7 @@ int ScoreQ (short side)
          s += QUEEN_NOT_PRESENT;
        }
        return(s);
-    }                                                                           
+    }
 
    xside = 1 ^ side;
    c = board.b[side][queen];
@@ -771,13 +765,13 @@ int ScoreK (short side)
    rank = RANK (sq);
    KingSafety[side] = 0;
    if (!ENDING)
-   { 
+   {
 
       s += ((6 - phase) * KingSq[sq] + phase * EndingKing[sq]) / 6;
 
       /* After castling kingside, reward having all 3 pawns in front but not if
 	 there is a threatening pawn. This permits the freeing move F3/F6. */
-	 
+
       if (side == white)
         n = nbits (MoveArray[king][sq] & board.b[side][pawn] & RankBit[rank+1]);
       else
@@ -793,12 +787,12 @@ int ScoreK (short side)
 	    /* Kingside - rook on original square and unmoved. */
 	    if ( (board.b[side][rook] & BitPosArray[H1])!=NULLBITBOARD &&
 		 Mvboard[H1] == 0)
-                   n = nbits (MoveArray[king][G1] & 
+                   n = nbits (MoveArray[king][G1] &
 			      board.b[side][pawn] & RankBit[rank+1]);
 	    /* Queenside */
 	    if ( (board.b[side][rook] & BitPosArray[A1])!=NULLBITBOARD &&
 		 Mvboard[A1] == 0)
-                   n = nbits (MoveArray[king][C1] & 
+                   n = nbits (MoveArray[king][C1] &
 			      board.b[side][pawn] & RankBit[rank+1]);
           }
    	} else {
@@ -806,21 +800,21 @@ int ScoreK (short side)
 	    /* Kingside */
 	    if ( (board.b[side][rook] & BitPosArray[H8])!=NULLBITBOARD &&
 		 Mvboard[H8] == 0)
-                   n = nbits (MoveArray[king][G8] & 
+                   n = nbits (MoveArray[king][G8] &
 			      board.b[side][pawn] & RankBit[rank-1]);
 	    /* Queenside */
 	    if ( (board.b[side][rook] & BitPosArray[A8])!=NULLBITBOARD &&
 		 Mvboard[A8] == 0)
-                   n = nbits (MoveArray[king][C8] & 
+                   n = nbits (MoveArray[king][C8] &
 			      board.b[side][pawn] & RankBit[rank-1]);
           }
 	}
-        
+
 	/* Penalize breaking the wing pawn formations prior to castle */
 	if (n != -1) s += pawncover[n];
       }
 
-      if (side == computer && file >= F_FILE && 
+      if (side == computer && file >= F_FILE &&
 		!(FileBit[G_FILE] & board.b[side][pawn]))
       {
          if (side == white && cboard[F2] == pawn)
@@ -893,7 +887,7 @@ int ScoreK (short side)
 	if (file >= E_FILE && board.b[xside][queen] && board.b[xside][rook] &&
 	    !((board.b[side][pawn]|board.b[xside][pawn]) & FileBit[7]))
          s += HOPEN;
-	
+
 	/* King trapping rook */
         if (side == white) {
 	  if (file > E_FILE) {
@@ -924,16 +918,16 @@ int ScoreK (short side)
 	 if ((BitPosArray[fsq] & board.b[side][pawn]) != NULLBITBOARD)
             if (((BitPosArray[F4]|BitPosArray[H4]|
 	         BitPosArray[F5]|BitPosArray[H5])
-	      & board.b[xside][pawn]) != NULLBITBOARD) 
-	        s += FIANCHETTO_TARGET;	
+	      & board.b[xside][pawn]) != NULLBITBOARD)
+	        s += FIANCHETTO_TARGET;
       }
       if (file < E_FILE && ROW(board.king[xside]) > E_FILE) {
          if (side == white) fsq = B3; else fsq = B6;
 	 if ((BitPosArray[fsq] & board.b[side][pawn]) != NULLBITBOARD)
             if (((BitPosArray[A4]|BitPosArray[C4]|
 	         BitPosArray[A5]|BitPosArray[C5])
-	      & board.b[xside][pawn]) != NULLBITBOARD) 
-	        s += FIANCHETTO_TARGET;	
+	      & board.b[xside][pawn]) != NULLBITBOARD)
+	        s += FIANCHETTO_TARGET;
       }
 
       /* No major/minor piece in king's quadrant */
@@ -943,12 +937,12 @@ int ScoreK (short side)
       n1 = nbits(x & (board.friends[xside]));
       if (n1 > 0) {
         /* Now identify the number of non-pawn friends in quadrant */
-        n2 = nbits(x & (board.friends[side] & ~board.b[side][pawn] & 
+        n2 = nbits(x & (board.friends[side] & ~board.b[side][pawn] &
 	 	~board.b[side][king]));
         if (n1 > n2)
 	  s += (n1 - n2) * KING_DEFENDER_DEFICIT;
       }
-      
+
       KingSafety[side] = s;
       s = (s * factor[phase]) / 8;
    }
@@ -978,12 +972,12 @@ int ScoreK (short side)
     if (phase >= 4) {
       /* Weak back rank */
       if (side == white) {
-        if (sq < A2) 
-	  if (!(MoveArray[king][sq] & (~board.b[side][pawn] & RankBit[1]))) 
+        if (sq < A2)
+	  if (!(MoveArray[king][sq] & (~board.b[side][pawn] & RankBit[1])))
 	    s += KING_BACK_RANK_WEAK;
       } else {
-	if (sq > H7) 
-	  if (!(MoveArray[king][sq] & (~board.b[side][pawn] & RankBit[6]))) 
+	if (sq > H7)
+	  if (!(MoveArray[king][sq] & (~board.b[side][pawn] & RankBit[6])))
 	    s += KING_BACK_RANK_WEAK;
       }
    }
@@ -996,7 +990,7 @@ int LoneKing (int side, int loser)
 /**************************************************************************
  *
  *  One side has a lonely king and the other has no pawns, but enough
- *  mating material.  We give an additional bonus of 150 points for the 
+ *  mating material.  We give an additional bonus of 150 points for the
  *  winning side to attract the search to such positions.
  *
  **************************************************************************/
@@ -1004,7 +998,7 @@ int LoneKing (int side, int loser)
    int s, winer, sq1, sq2;
 
    winer = 1^loser;
-   if (board.material[winer] == ValueB+ValueN && 
+   if (board.material[winer] == ValueB+ValueN &&
 	nbits(board.b[winer][bishop]) == 1 &&
 	nbits(board.b[winer][knight]) == 1)
       return (ScoreKBNK (side, loser));
@@ -1038,12 +1032,12 @@ int KPK (int side)
    sq  = leadz (board.b[winer][pawn]);
    sqw = board.king[winer];
    sql = board.king[loser];
-   s = ValueP + (ValueQ * Passed[winer][RANK(sq)] / PFACTOR) + 
+   s = ValueP + (ValueQ * Passed[winer][RANK(sq)] / PFACTOR) +
 	 4 * (winer == white ? RANK(sqw) : 7-RANK(sqw));
 
 /**************************************************************************
  *
- * Pawn is outside the square of the king 
+ * Pawn is outside the square of the king
  *
  **************************************************************************/
    if (~SquarePawnMask[winer][sq] & board.b[loser][king])
@@ -1056,7 +1050,7 @@ int KPK (int side)
 
 /**************************************************************************
  *
- *  Friendly king is on same or adjacent file to the pawn, and the pawn is 
+ *  Friendly king is on same or adjacent file to the pawn, and the pawn is
  *  on a file other than a rook file and ...
  *
  **************************************************************************/
@@ -1066,8 +1060,8 @@ int KPK (int side)
 
 /**************************************************************************
  *
- * a. friendly king is 2 ranks more advanced than the pawn 
- * b. friendly king is 1 rank more advanced than the pawn 
+ * a. friendly king is 2 ranks more advanced than the pawn
+ * b. friendly king is 1 rank more advanced than the pawn
  *    i.  The friendly king is on the sixth rank.
  *    ii. The enemy king does not have direct opposition by being 2 ranks
  *        in front of the friendly king and on the same file.
@@ -1079,7 +1073,7 @@ int KPK (int side)
  *    i.  The enemy king is not on the queening square.
  *    ii. The enemy is on the queening square but both kings are in the same
  *        file.
- * 
+ *
  **************************************************************************/
       if (winer == white)
       {
@@ -1089,7 +1083,7 @@ int KPK (int side)
          {
 	    if (RANK(sqw) == 5)
                return (winer == side ? s : -s);
-            if (sqw < A6) 
+            if (sqw < A6)
 	    {
 	       if (sqw+16 == sql && winer == side)
 		  return (0);
@@ -1115,7 +1109,7 @@ int KPK (int side)
 	    if (sql == sq+8 && sql == sqw+16)
                return (winer == side ? s : 0);
 	 }
-      } 
+      }
       else
       {
          if (RANK(sqw) == RANK(sq) - 2)
@@ -1130,7 +1124,7 @@ int KPK (int side)
 	          return (0);
 	       else
                   return (winer == side ? s : -s);
-	    }	
+	    }
 	 }
          if (RANK(sqw) == RANK(sq))
          {
@@ -1150,14 +1144,14 @@ int KPK (int side)
 	    if (sql == sq-8 && sql == sqw-16)
                return (winer == side ? s : 0);
 	 }
-      } 
-   }  
+      }
+   }
 
    return (0);
 }
 
 
-int KBNK[64] = 
+int KBNK[64] =
 {
    0, 10, 20, 30, 40, 50, 60, 70,
   10, 20, 30, 40, 50, 60, 70, 60,
@@ -1197,7 +1191,7 @@ int ScoreKBNK (int side, int loser)
       s = -s;
    s += MATERIAL;
 
-   return (s); 
+   return (s);
 }
 
 
@@ -1230,7 +1224,7 @@ int ScoreDev (short side)
    s += NOTCASTLED;
 
    /* If the king is moved, nail it, otherwise check rooks */
-   if (Mvboard[board.king[side]] > 0) 
+   if (Mvboard[board.king[side]] > 0)
       s += KINGMOVED;
 
    /* Discourage rook moves */
@@ -1267,7 +1261,7 @@ int ScoreDev (short side)
    while (c) {
      sq = leadz(c);
      CLEARBIT(c, sq);
-     if (Mvboard[sq] > 0) 
+     if (Mvboard[sq] > 0)
 	s += EARLYWINGPAWNMOVE;
    }
 
@@ -1277,7 +1271,7 @@ int ScoreDev (short side)
    while (c) {
      sq = leadz(c);
      CLEARBIT(c, sq);
-     if (Mvboard[sq] > 1) 
+     if (Mvboard[sq] > 1)
 	s += EARLYCENTERPREPEAT;
    }
 
@@ -1306,7 +1300,6 @@ int Evaluate (int alpha, int beta)
 {
    int side, xside;
    int piece, s, s1, score;
-   int npiece[2];
    BitBoard *b;
 
    side = board.side;
@@ -1314,11 +1307,11 @@ int Evaluate (int alpha, int beta)
 
    /*  If we are looking for a MATE, just return the material */
    if (alpha > MATE-255 || beta < -MATE+255)
-      return (MATERIAL); 
+      return (MATERIAL);
 
    /*  A KPK endgame. */
    if (board.material[white]+board.material[black] == ValueP)
-      return (KPK (side));  
+      return (KPK (side));
 
    /*  One side has a lone king and other side has no pawns */
    if (board.material[xside] == 0 && board.b[side][pawn] == NULLBITBOARD)
@@ -1339,10 +1332,8 @@ int Evaluate (int alpha, int beta)
    phase = PHASE;
    b = board.b[white];
    pieces[white] = b[knight] | b[bishop] | b[rook] | b[queen];
-   npiece[white] = nbits (pieces[white]);
    b = board.b[black];
    pieces[black] = b[knight] | b[bishop] | b[rook] | b[queen];
-   npiece[black] = nbits (pieces[black]);
    s1 = MATERIAL;
 
    if ((s1 + maxposnscore[side] < alpha || s1 - maxposnscore[xside] > beta) &&
@@ -1363,7 +1354,7 @@ int Evaluate (int alpha, int beta)
 /**************************************************************************
  *
  *  See if we can have a lazy evaluation cut.  Otherwise its a slow eval.
- * 
+ *
  **************************************************************************/
 
    if (s1 + lazyscore[side] < alpha || s1 - lazyscore[side] > beta)
@@ -1396,7 +1387,7 @@ next:
    if (MATERIAL >= 200)
    {
       score += (RootPieces - nbits(pieces[white] | pieces[black])) * TRADEPIECE;
-      score -= (RootPawns - nbits(board.b[white][pawn] | board.b[black][pawn])) 
+      score -= (RootPawns - nbits(board.b[white][pawn] | board.b[black][pawn]))
 			* TRADEPAWNS;
    }
    else if (MATERIAL <= -200)
@@ -1405,20 +1396,20 @@ next:
       score += (RootPawns - nbits(board.b[white][pawn] | board.b[black][pawn]))
 			 * TRADEPAWNS;
    }
-      
+
 /***************************************************************************
  *
  *  Opposite color bishops is drawish.
  *
  ***************************************************************************/
-   if (ENDING && pieces[white] == board.b[white][bishop] && 
+   if (ENDING && pieces[white] == board.b[white][bishop] &&
                  pieces[black] == board.b[black][bishop] &&
        ((pieces[white] & WHITESQUARES && pieces[black] & BLACKSQUARES) ||
 	(pieces[white] & BLACKSQUARES && pieces[black] & WHITESQUARES)))
    {
       score /= 2;
    }
-    
+
 /***************************************************************************
  *
  *  When one side has no mating material, then his score can never be > 0.
@@ -1430,7 +1421,7 @@ next:
    if (score < 0 && !board.b[xside][pawn] && (board.material[xside] < ValueR
         || pieces[xside] == board.b[xside][knight]))
       score = 0;
-   
+
    return (score);
 }
 
@@ -1451,8 +1442,8 @@ short EvaluateDraw (void)
    BitBoard *w, *b;
    int wm, bm, wn, bn;
 
-   /* 
-    * Exception - if we are close to a pawn move, promotion 
+   /*
+    * Exception - if we are close to a pawn move, promotion
     * or capture it is possible a forced mate will follow.
     * So we assume not drawn for 2 moves.
     */
@@ -1475,18 +1466,18 @@ short EvaluateDraw (void)
    bn = nbits (b[knight]);
    if  ((wm<ValueR || (wm==2*ValueN && wn==2)) &&
         (bm<ValueR || (bm==2*ValueN && bn==2)))
-      return (true); 
+      return (true);
 
    if (wm < ValueR)
    {
-      if (bm == 2*ValueB && 
+      if (bm == 2*ValueB &&
          ( nbits(board.b[black][bishop] & WHITESQUARES) == 2 ||
            nbits(board.b[black][bishop] & BLACKSQUARES) == 2 ))
       return (true);
    }
    if (bm < ValueR)
    {
-      if (wm == 2*ValueB && 
+      if (wm == 2*ValueB &&
          ( nbits(board.b[white][bishop] & WHITESQUARES) == 2 ||
            nbits(board.b[white][bishop] & BLACKSQUARES) == 2 ))
       return (true);
diff --git a/src/chess_computer-activity/gnuchess/genmove.c b/src/chess_computer-activity/gnuchess/genmove.c
index 69f2f7c..67b1810 100644
--- a/src/chess_computer-activity/gnuchess/genmove.c
+++ b/src/chess_computer-activity/gnuchess/genmove.c
@@ -1,7 +1,7 @@
 /* GNU Chess 5.0 - genmove.c - move generator code
    Copyright (c) 1999-2002 Free Software Foundation, Inc.
 
-   GNU Chess is based on the two research programs 
+   GNU Chess is based on the two research programs
    Cobalt by Chua Kong-Sian and Gazebo by Stuart Cracraft.
 
    GNU Chess is free software; you can redistribute it and/or modify
@@ -19,7 +19,7 @@
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
 
-   Contact Info: 
+   Contact Info:
      bug-gnu-chess gnu org
      cracraft ai mit edu, cracraft stanfordalumni org, cracraft earthlink net
 */
@@ -204,7 +204,7 @@ void GenMoves (short ply)
    /*  Black pawn forward moves   */
    if (side == black)
    {
-      c = (a[pawn] << 8) & notblocker;		
+      c = (a[pawn] << 8) & notblocker;
       while (c)
       {
          t = leadz (c);
@@ -271,28 +271,28 @@ void GenMoves (short ply)
    /* Castling code */
    b = board.b[side][rook];
    if (side == white && (board.flag & WKINGCASTLE) && (b & BitPosArray[H1]) &&
-       !(FromToRay[E1][G1] & blocker) && 
+       !(FromToRay[E1][G1] & blocker) &&
        !SqAtakd (E1, black) && !SqAtakd (F1, black) && !SqAtakd (G1, black))
    {
-           ADDMOVE (E1, G1, CASTLING);  
+           ADDMOVE (E1, G1, CASTLING);
    }
    if (side == white && (board.flag & WQUEENCASTLE) && (b & BitPosArray[A1]) &&
        !(FromToRay[E1][B1] & blocker) &&
        !SqAtakd (E1, black) && !SqAtakd (D1, black) && !SqAtakd (C1, black))
    {
-           ADDMOVE (E1, C1, CASTLING);  
+           ADDMOVE (E1, C1, CASTLING);
    }
    if (side == black && (board.flag & BKINGCASTLE) && (b & BitPosArray[H8]) &&
        !(FromToRay[E8][G8] & blocker) &&
        !SqAtakd (E8, white) && !SqAtakd (F8, white) && !SqAtakd (G8, white))
    {
-           ADDMOVE (E8, G8, CASTLING);  
+           ADDMOVE (E8, G8, CASTLING);
    }
    if (side == black && (board.flag & BQUEENCASTLE) && (b & BitPosArray[A8]) &&
        !(FromToRay[E8][B8] & blocker) &&
        !SqAtakd (E8, white) && !SqAtakd (D8, white) && !SqAtakd (C8, white))
    {
-           ADDMOVE (E8, C8, CASTLING);  
+           ADDMOVE (E8, C8, CASTLING);
    }
 
    /* Update tree pointers and count */
@@ -310,18 +310,15 @@ void GenNonCaptures (short ply)
  ****************************************************************************/
 {
    int side;
-   int piece, sq, t, ep;
-   BitBoard b, c, d, friends, notfriends, blocker, notblocker;
+   int piece, sq, t;
+   BitBoard b, c, d, blocker, notblocker;
    BitBoard *a;
 
    side = board.side;
    a = board.b[side];
-   friends = board.friends[side];
-   notfriends = ~friends;
    blocker = board.blocker;
    notblocker = ~blocker;
    node = TreePtr[ply + 1];
-   ep = board.ep;
 
    /* Knight & King */
    for (piece = knight; piece <= king; piece += 4)
@@ -392,7 +389,7 @@ void GenNonCaptures (short ply)
    /*  Black pawn forward moves   */
    if (side == black)
    {
-      c = (a[pawn] << 8) & notblocker;		
+      c = (a[pawn] << 8) & notblocker;
       while (c)
       {
          t = leadz (c);
@@ -418,25 +415,25 @@ void GenNonCaptures (short ply)
        !(FromToRay[4][6] & blocker) &&
        !SqAtakd (4, black) && !SqAtakd (5, black) && !SqAtakd (6, black))
    {
-           ADDMOVE (4, 6, CASTLING);  
+           ADDMOVE (4, 6, CASTLING);
    }
    if (side == white && (board.flag & WQUEENCASTLE) && (b & BitPosArray[0]) &&
        !(FromToRay[4][1] & blocker) &&
        !SqAtakd (4, black) && !SqAtakd (3, black) && !SqAtakd (2, black))
    {
-           ADDMOVE (4, 2, CASTLING);  
+           ADDMOVE (4, 2, CASTLING);
    }
    if (side == black && (board.flag & BKINGCASTLE) && (b & BitPosArray[63]) &&
        !(FromToRay[60][62] & blocker) &&
        !SqAtakd (60, white) && !SqAtakd (61, white) && !SqAtakd (62, white))
    {
-           ADDMOVE (60, 62, CASTLING);  
+           ADDMOVE (60, 62, CASTLING);
    }
    if (side == black && (board.flag & BQUEENCASTLE) && (b & BitPosArray[56]) &&
        !(FromToRay[60][57] & blocker) &&
        !SqAtakd (60, white) && !SqAtakd (59, white) && !SqAtakd (58, white))
    {
-           ADDMOVE (60, 58, CASTLING);  
+           ADDMOVE (60, 58, CASTLING);
    }
 
    /* Update tree pointers and count */
@@ -455,13 +452,11 @@ void GenCaptures (short ply)
 {
    int side;
    int piece, sq, t, ep;
-   BitBoard b, c, friends, notfriends, enemy, blocker;
+   BitBoard b, c, enemy, blocker;
    BitBoard *a;
 
    side = board.side;
    a = board.b[side];
-   friends = board.friends[side];
-   notfriends = ~friends;
    enemy = board.friends[1^side];
    blocker = board.blocker;
    node = TreePtr[ply + 1];
@@ -566,7 +561,7 @@ void GenCaptures (short ply)
    if (side == black)
    {
       b = a[pawn] & RankBit[1];			/* all pawns on 2nd rank */
-      c = (b << 8) & ~blocker;		
+      c = (b << 8) & ~blocker;
       while (c)
       {
          t = leadz (c);
@@ -626,7 +621,7 @@ void GenCheckEscapes (short ply)
 /**************************************************************************
  *
  *  The king is in check, so generate only moves which get the king out
- *  of check.  
+ *  of check.
  *  Caveat:  The special case of an enpassant capture must be taken into
  *  account too as the captured pawn could be the checking piece.
  *
@@ -634,7 +629,7 @@ void GenCheckEscapes (short ply)
 {
    int side, xside;
    int kingsq, chksq, sq, sq1, epsq, dir;
-   BitBoard checkers, b, c, p, escapes; 
+   BitBoard checkers, b, c, p, escapes;
    escapes = NULLBITBOARD;
    side = board.side;
    xside = 1 ^ side;
@@ -648,7 +643,7 @@ void GenCheckEscapes (short ply)
    {
       /*  Captures of checking pieces (except by king) */
       chksq = leadz (checkers);
-      b = AttackTo (chksq, side); 
+      b = AttackTo (chksq, side);
       b &= ~board.b[side][king];
       while (b)
       {
@@ -690,23 +685,23 @@ void GenCheckEscapes (short ply)
          {
             sq = leadz (c);
             CLEARBIT (c, sq);
-            b = AttackTo (sq, side); 
+            b = AttackTo (sq, side);
             b &= ~(board.b[side][king] | p);
 
             /* Add in pawn advances */
             if (side == white && sq > H2)
             {
-               if (BitPosArray[sq-8] & p) 
+               if (BitPosArray[sq-8] & p)
 	          b |= BitPosArray[sq-8];
-	       if (RANK(sq) == 3 && cboard[sq-8] == empty && 
+	       if (RANK(sq) == 3 && cboard[sq-8] == empty &&
 			(BitPosArray[sq-16] & p))
 	          b |= BitPosArray[sq-16];
             }
             if (side == black && sq < H7)
             {
-               if (BitPosArray[sq+8] & p) 
+               if (BitPosArray[sq+8] & p)
 	          b |= BitPosArray[sq+8];
-	       if (RANK(sq) == 4 && cboard[sq+8] == empty && 
+	       if (RANK(sq) == 4 && cboard[sq+8] == empty &&
 			(BitPosArray[sq+16] & p))
 	          b |= BitPosArray[sq+16];
             }
@@ -772,17 +767,17 @@ void FilterIllegalMoves (short ply)
    {
       MakeMove (side, &p->move);
       if (cboard[TOSQ(p->move)] != king)
-         check = SqAtakd (sq, xside); 
-      else 
-         check = SqAtakd (TOSQ(p->move), xside); 
+         check = SqAtakd (sq, xside);
+      else
+         check = SqAtakd (TOSQ(p->move), xside);
       UnmakeMove (xside, &p->move);
 
       if (check)	/* its an illegal move */
       {
          --TreePtr[ply+1];
          *p = *TreePtr[ply+1];
-         --p; 
+         --p;
 	 GenCnt--;
-      } 
+      }
    }
 }
diff --git a/src/chess_computer-activity/gnuchess/input.c b/src/chess_computer-activity/gnuchess/input.c
index 68c5fd2..403e485 100644
--- a/src/chess_computer-activity/gnuchess/input.c
+++ b/src/chess_computer-activity/gnuchess/input.c
@@ -1,7 +1,7 @@
 /* GNU Chess 5.0 - input.c - Input thread and related
    Copyright (c) 2002 Free Software Foundation, Inc.
 
-   GNU Chess is based on the two research programs 
+   GNU Chess is based on the two research programs
    Cobalt by Chua Kong-Sian and Gazebo by Stuart Cracraft.
 
    GNU Chess is free software; you can redistribute it and/or modify
@@ -19,7 +19,7 @@
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
 
-   Contact Info: 
+   Contact Info:
      bug-gnu-chess gnu org
      cracraft ai mit edu, cracraft stanfordalumni org, cracraft earthlink net
      lukas debian org
@@ -54,7 +54,7 @@ extern void add_history(char *);
 
 /* Variable used to communicate with the main thread */
 volatile int input_status = INPUT_NONE;
-  
+
 char inputstr[MAXSTR];
 
 /*
@@ -90,7 +90,8 @@ void getline_standard(char *p)
     fputs(p, stdout);
     fflush(stdout);
   }
-  fgets(inputstr, MAXSTR, stdin);
+  char *resstr = fgets(inputstr, MAXSTR, stdin);
+  (void) resstr; // suppress unused var warning
 }
 
 pthread_t input_thread;
@@ -123,8 +124,8 @@ void *input_func(void *arg __attribute__((unused)) )
 
   while (!(flags & QUIT)) {
     if (!(flags & XBOARD)) {
-      sprintf(prompt,"%s (%d) : ", 
-	      RealSide ? "Black" : "White", 
+      sprintf(prompt,"%s (%d) : ",
+	      RealSide ? "Black" : "White",
 	      (RealGameCnt+1)/2 + 1 );
     }
     pthread_mutex_lock(&input_mutex);
@@ -137,7 +138,7 @@ void *input_func(void *arg __attribute__((unused)) )
     /*
      * Posix waits can wake up spuriously
      * so we must ensure that we keep waiting
-     * until we are woken by something that has 
+     * until we are woken by something that has
      * consumed the input
      */
     while ( input_status == INPUT_AVAILABLE ){
@@ -150,7 +151,7 @@ void *input_func(void *arg __attribute__((unused)) )
 
 void input_wakeup(void)
 {
-  
+
   pthread_mutex_lock(&input_mutex);
   input_status = INPUT_NONE;
   pthread_mutex_unlock(&input_mutex);
diff --git a/src/chess_computer-activity/gnuchess/lexpgn.c b/src/chess_computer-activity/gnuchess/lexpgn.c
index bc00d94..21b1679 100644
--- a/src/chess_computer-activity/gnuchess/lexpgn.c
+++ b/src/chess_computer-activity/gnuchess/lexpgn.c
@@ -1847,7 +1847,7 @@ static int yy_flex_strlen YY_PROTO(( yyconst char * ));
 #ifdef __cplusplus
 static int yyinput YY_PROTO(( void ));
 #else
-static int input YY_PROTO(( void ));
+static int __attribute__ ((unused)) input YY_PROTO(( void ));
 #endif
 #endif
 
diff --git a/src/chess_computer-activity/gnuchess/players.c b/src/chess_computer-activity/gnuchess/players.c
index 7d0b8ac..365d44d 100644
--- a/src/chess_computer-activity/gnuchess/players.c
+++ b/src/chess_computer-activity/gnuchess/players.c
@@ -2,7 +2,7 @@
 /* GNU Chess 5.0 - player.c - database on players
    Copyright (c) 1999-2002 Free Software Foundation, Inc.
 
-   GNU Chess is based on the two research programs 
+   GNU Chess is based on the two research programs
    Cobalt by Chua Kong-Sian and Gazebo by Stuart Cracraft.
 
    GNU Chess is free software; you can redistribute it and/or modify
@@ -20,7 +20,7 @@
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
 
-   Contact Info: 
+   Contact Info:
      bug-gnu-chess gnu org
      cracraft ai mit edu, cracraft stanfordalumni org, cracraft earthlink net
 */
@@ -50,7 +50,7 @@ static char lname[MAXNAMESZ];
 static int rscorecompare(const void *aa, const void *bb)
 {
     const playerentry *a = aa;
-    const playerentry *b = bb;   
+    const playerentry *b = bb;
     float ascore, bscore;
     ascore = (a->wins+(a->draws/2))/(a->wins+a->draws+a->losses);
     bscore = (b->wins+(b->draws/2))/(b->wins+b->draws+b->losses);
@@ -62,7 +62,7 @@ static int rscorecompare(const void *aa, const void *bb)
 static int scorecompare(const void *aa, const void *bb)
 {
     const playerentry *a = aa;
-    const playerentry *b = bb;   
+    const playerentry *b = bb;
     int ascore, bscore;
     ascore = 100*(a->wins+(a->draws/2))/(a->wins+a->draws+a->losses);
     bscore = 100*(b->wins+(b->draws/2))/(b->wins+b->draws+b->losses);
@@ -74,7 +74,7 @@ static int scorecompare(const void *aa, const void *bb)
 static int namecompare(const void *aa, const void *bb)
 {
     const playerentry *a = aa;
-    const playerentry *b = bb;   
+    const playerentry *b = bb;
     if (strcmp(a->player,b->player) > 0) return(1);
     else if (strcmp(a->player,b->player) < 0) return(-1);
     else return(0);
@@ -94,7 +94,7 @@ void DBSortPlayer (const char *style)
 void DBListPlayer (const char *style)
 {
   int i;
-	
+
   DBReadPlayer ();
   DBSortPlayer (style);
   for (i = 0; i < totalplayers; i++) {
@@ -112,16 +112,10 @@ void DBListPlayer (const char *style)
 void DBWritePlayer (void)
 {
    int i;
-   float result1;
-   int result2;
    FILE *wfp;
    DBSortPlayer ("reverse");
    if ((wfp = fopen(PLAYERFILE,"w")) != NULL) {
      for (i = 0; i < totalplayers; i++) {
-        result1 =
-  	  100.0*(playerdb[i].wins+((float)playerdb[i].draws/2))/
-	   (playerdb[i].wins+playerdb[i].draws+playerdb[i].losses),
-	result2 = (int) result1;
         fprintf(wfp,"%s %d %d %d\n",
 	  playerdb[i].player,
           playerdb[i].wins,
@@ -175,7 +169,7 @@ void DBUpdatePlayer (const char *player, const char *resultstr)
   x = lname;
   strcpy(lname,player);
   do {
-    if (*p != ' ') 
+    if (*p != ' ')
       *x++ = *p++;
     else
 	p++;
diff --git a/src/chess_computer-activity/gnuchess/search.c b/src/chess_computer-activity/gnuchess/search.c
index c26dc3a..8325376 100644
--- a/src/chess_computer-activity/gnuchess/search.c
+++ b/src/chess_computer-activity/gnuchess/search.c
@@ -1,7 +1,7 @@
 /* GNU Chess 5.0 - search.c - tree-search code
    Copyright (c) 1999-2002 Free Software Foundation, Inc.
 
-   GNU Chess is based on the two research programs 
+   GNU Chess is based on the two research programs
    Cobalt by Chua Kong-Sian and Gazebo by Stuart Cracraft.
 
    GNU Chess is free software; you can redistribute it and/or modify
@@ -19,7 +19,7 @@
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
 
-   Contact Info: 
+   Contact Info:
      bug-gnu-chess gnu org
      cracraft ai mit edu, cracraft stanfordalumni org, cracraft earthlink net
 */
@@ -46,7 +46,7 @@ static inline void ShowThinking (leaf *p, uint8_t ply)
       return;
    }
    SANMove (p->move, ply);
-   printf ("\r%2d.         %2d/%2d%10s    ", Idepth, 
+   printf ("\r%2d.         %2d/%2d%10s    ", Idepth,
       (int) (p-TreePtr[ply]+1), (int) (TreePtr[ply+1]-TreePtr[ply]), SANmv);
    fflush (stdout);
 }
@@ -68,7 +68,7 @@ int SearchRoot (short depth, int alpha, int beta)
    short nodetype;
    leaf *p, *pbest;
 
-   ply = 1; 
+   ply = 1;
    side = board.side;
    xside = 1^side;
    ChkCnt[2] = ChkCnt[1];
@@ -89,11 +89,11 @@ int SearchRoot (short depth, int alpha, int beta)
 
    for (p = TreePtr[1]; p < TreePtr[2]; p++)
    {
-      pick (p, 1); 
+      pick (p, 1);
       ShowThinking (p, ply);
       MakeMove (side, &p->move);
       NodeCnt++;
-      
+
       /*  If first move, search against full alpha-beta window  */
       if (p == TreePtr[1])
       {
@@ -114,7 +114,7 @@ int SearchRoot (short depth, int alpha, int beta)
       else
       {
 	 nodetype = CUT;
-         alpha = MAX (best, alpha);            
+         alpha = MAX (best, alpha);
          score = -Search (2, depth-1, -alpha-1, -alpha, nodetype);
          if (score > best)
          {
@@ -159,8 +159,8 @@ int SearchRoot (short depth, int alpha, int beta)
 	 } else {
 	    ElapsedTime = GetElapsed (StartTime);
 	    if ((ElapsedTime >= SearchTime && (
-		    rootscore == -INFINITY-1 
-		    || ply1score > lastrootscore - 25 
+		    rootscore == -INFINITY-1
+		    || ply1score > lastrootscore - 25
 		    || flags & SOLVE))
 		|| ElapsedTime >= maxtime)
 	       SET (flags, TIMEOUT);
@@ -194,7 +194,7 @@ done:
 int Search (uint8_t ply, short depth, int alpha, int beta, short nodetype)
 /**************************************************************************
  *
- *  The basic algorithm for this search routine came from Anthony 
+ *  The basic algorithm for this search routine came from Anthony
  *  Marsland.  It is a PVS (Principal Variation Search) algorithm.
  *  The fail-soft alpha-beta technique is also used for improved
  *  pruning.
@@ -207,7 +207,6 @@ int Search (uint8_t ply, short depth, int alpha, int beta, short nodetype)
    int fcut, fdel, donull, savenode, extend;
    leaf *p, *pbest;
    int g0, g1;
-   int upperbound;
 
    /* Check if this position is a known draw */
    if (EvaluateDraw ())
@@ -215,7 +214,7 @@ int Search (uint8_t ply, short depth, int alpha, int beta, short nodetype)
    if (GameCnt >= Game50+3 && Repeat())
    {
       RepeatCnt++;
-      return (DRAWSCORE); 
+      return (DRAWSCORE);
    }
 
    side = board.side;
@@ -225,7 +224,7 @@ int Search (uint8_t ply, short depth, int alpha, int beta, short nodetype)
 /*************************************************************************
  *
  *  Perform some basic search extensions.
- *  1.  One reply extensions.  
+ *  1.  One reply extensions.
  *  2.  If in check, extend (maximum of Idepth-1).
  *  3.  If there is a threat to the King, extend (not beyond 2*Idepth)
  *  4.  If recapture to same square and not beyond Idepth+2
@@ -249,7 +248,7 @@ int Search (uint8_t ply, short depth, int alpha, int beta, short nodetype)
    }
 
 /*
-   We've already found a mate at the next ply.  If we aren't being mated by 
+   We've already found a mate at the next ply.  If we aren't being mated by
    a shorter line, so just return the current material value.
 */
    if (rootscore + ply >= MATE)
@@ -257,7 +256,7 @@ int Search (uint8_t ply, short depth, int alpha, int beta, short nodetype)
 
    g0 = Game[GameCnt].move;
    g1 = GameCnt > 0 ? Game[GameCnt-1].move : 0;
-   t0 = TOSQ(g0); 
+   t0 = TOSQ(g0);
    t1 = TOSQ(g1);
    ChkCnt[ply+1] = ChkCnt[ply];
    ThrtCnt[ply+1] = ThrtCnt[ply];
@@ -286,7 +285,7 @@ int Search (uint8_t ply, short depth, int alpha, int beta, short nodetype)
       extend = true;
    }
    /* Recapture extension */
-   else if ((g0 & CAPTURE) && (board.material[computer] - 
+   else if ((g0 & CAPTURE) && (board.material[computer] -
 	board.material[1^computer] == RootMaterial))
    {
       RcpExtCnt++;
@@ -301,13 +300,13 @@ int Search (uint8_t ply, short depth, int alpha, int beta, short nodetype)
       extend = true;
    }
 
-/**************************************************************************** 
+/****************************************************************************
  *
- *  The following extension is to handle cases when the opposing side is 
- *  delaying the mate by useless interposing moves. 
+ *  The following extension is to handle cases when the opposing side is
+ *  delaying the mate by useless interposing moves.
  *
  ****************************************************************************/
-   if (ply > 2 && InChk[ply-1] && cboard[t0] != king && t0 != t1 && 
+   if (ply > 2 && InChk[ply-1] && cboard[t0] != king && t0 != t1 &&
 	 !SqAtakd (t0, xside))
    {
       HorzExtCnt++;
@@ -323,9 +322,9 @@ int Search (uint8_t ply, short depth, int alpha, int beta, short nodetype)
  **************************************************************************/
 
    if (depth <= 0)
-      return (Quiesce (ply, alpha, beta)); 
+      return (Quiesce (ply, alpha, beta));
 
-/**************************************************************************** 
+/****************************************************************************
  *
  *  Probe the transposition table for a score and a move.
  *  If the score is an upperbound, then we can use it to improve the value
@@ -334,7 +333,6 @@ int Search (uint8_t ply, short depth, int alpha, int beta, short nodetype)
  *
  ***************************************************************************/
    Hashmv[ply] = 0;
-   upperbound = INFINITY;
    if (flags & USEHASH)
    {
       rc = TTGet (side, depth, ply, &score, &g1);
@@ -346,7 +344,6 @@ int Search (uint8_t ply, short depth, int alpha, int beta, short nodetype)
 	 case POORDRAFT  :  /* Not reached */ break;
 	 case EXACTSCORE :  /* Not reached */ return (score);
             case UPPERBOUND :  beta = MIN (beta, score);
-			       upperbound = score;
 			       donull = false;
 	                       break;
             case LOWERBOUND :  /*alpha = MAX (alpha, score);*/
@@ -364,7 +361,7 @@ int Search (uint8_t ply, short depth, int alpha, int beta, short nodetype)
 /*****************************************************************************
  *
  *  Perform the null move here.  There are certain cases when null move
- *  is not done.  
+ *  is not done.
  *  1.  When the previous move is a null move.
  *  2.  At the frontier (depth == 1)
  *  3.  At a PV node.
@@ -386,7 +383,7 @@ int Search (uint8_t ply, short depth, int alpha, int beta, short nodetype)
       TreePtr[ply+1] = TreePtr[ply];
       MakeNullMove (side);
       nullscore = -Search (ply+1, depth-3, -beta, -beta+1, nodetype);
-      UnmakeNullMove (xside); 
+      UnmakeNullMove (xside);
       if (nullscore >= beta)
       {
          NullCutCnt++;
@@ -471,7 +468,7 @@ int Search (uint8_t ply, short depth, int alpha, int beta, short nodetype)
 
          MakeMove (side, &p->move);
          NodeCnt++;
-         if (SqAtakd (board.king[side], xside)) 
+         if (SqAtakd (board.king[side], xside))
          {
             UnmakeMove (xside, &p->move);
             continue;
@@ -481,14 +478,14 @@ int Search (uint8_t ply, short depth, int alpha, int beta, short nodetype)
  *
  *  Futility pruning.  The idea is that at the frontier node (depth == 1),
  *  if the side on the move is materially bad, then if the move doesn't win
- *  back material or the move isn't a check or doesn't threatened the king, 
- *  then there is no point in searching this move.  So skip it.  
+ *  back material or the move isn't a check or doesn't threatened the king,
+ *  then there is no point in searching this move.  So skip it.
  *  Caveat:  However if the node is a PV, we skip this test.
  *
  *****************************************************************************/
       	 if (fcut && FUTSCORE <= alpha && !SqAtakd (board.king[xside], side) &&
 		!MateScan (xside))
-		
+
          {
             UnmakeMove (xside, &p->move);
 	    FutlCutCnt++;
@@ -508,7 +505,7 @@ int Search (uint8_t ply, short depth, int alpha, int beta, short nodetype)
             if (alpha < score && score < beta)
 	    {
                score = -Search (ply+1, depth-1, -beta, -score, nodetype);
-	    } 
+	    }
 	    if (nodetype == PV && score <= alpha &&
 		Game[GameCnt+1].move == NULLMOVE)
 	    {
@@ -534,17 +531,17 @@ int Search (uint8_t ply, short depth, int alpha, int beta, short nodetype)
       }
 
       if (((flags & PONDER) || SearchDepth == 0) && (NodeCnt & TIMECHECK) == 0)
-      {	
+      {
 	 if (flags & PONDER) {
 	    if (input_status != INPUT_NONE)
 	       SET(flags, TIMEOUT);
 	 } else {
 	    ElapsedTime = GetElapsed (StartTime);
-	    if ((ElapsedTime >= SearchTime && 
-		 (rootscore == -INFINITY-1 || 
+	    if ((ElapsedTime >= SearchTime &&
+		 (rootscore == -INFINITY-1 ||
 		  ply1score > lastrootscore - 25 || flags & SOLVE)) ||
 		ElapsedTime >= maxtime)
-	       SET (flags, TIMEOUT);        
+	       SET (flags, TIMEOUT);
 	 }
       }
 
@@ -553,7 +550,7 @@ int Search (uint8_t ply, short depth, int alpha, int beta, short nodetype)
 /*  then we can skip the rest of the moves!  				   */
       if (MATE+1 == best+ply)
          goto done;
-   } 
+   }
 
 /*****************************************************************************
  *
@@ -575,7 +572,7 @@ done:
  * Must look at failure of TIMEOUT condition more carefully!
  */
 	if ( !(flags & TIMEOUT))
-          TTPut (side, depth, ply, savealpha, beta, best, pbest->move); 
+          TTPut (side, depth, ply, savealpha, beta, best, pbest->move);
       }
 
    /*  Update history  */
@@ -648,11 +645,11 @@ void ShowLine (int move __attribute__ ((unused)), int score, char c)
        fprintf (ofp,"%2d%c%7.2f -Mat%02d%10ld\t", Idepth, c, ElapsedTime,
 		 (MATE+2-abs(score))/2, NodeCnt+QuiesCnt);
      } else {
-	 printf ("%d%c %d %d %ld\t", Idepth, c, (int)score, 
+	 printf ("%d%c %d %d %ld\t", Idepth, c, (int)score,
 		 (int)(ElapsedTime), NodeCnt+QuiesCnt);
-	 if (ofp != stdout) 
-	   fprintf (ofp,"%2d%c%7.2f%7d%10ld\t", Idepth, c, 
-		    ElapsedTime, score, NodeCnt+QuiesCnt);	 
+	 if (ofp != stdout)
+	   fprintf (ofp,"%2d%c%7.2f%7d%10ld\t", Idepth, c,
+		    ElapsedTime, score, NodeCnt+QuiesCnt);
        }
    }
    else {              /* Not XBOARD */
@@ -671,9 +668,9 @@ void ShowLine (int move __attribute__ ((unused)), int score, char c)
       } else {
 	 printf ("\r%2d%c%7.2f%7d%10ld\t", Idepth, c, ElapsedTime,
 		 score, NodeCnt+QuiesCnt);
-	 if (ofp != stdout) 
+	 if (ofp != stdout)
 	    fprintf (ofp,"\r%2d%c%7.2f%7d%10ld\t", Idepth, c, ElapsedTime,
-		    score, NodeCnt+QuiesCnt);	 
+		    score, NodeCnt+QuiesCnt);
       }
    }
 
@@ -708,7 +705,7 @@ void ShowLine (int move __attribute__ ((unused)), int score, char c)
       {
          if ((MATESCORE(score) && abs(score) == MATE+2-i) || Repeat ())
             break;
-  
+
          if (len >= 32)
          {
             printf ("\n\t\t\t\t");
diff --git a/src/chess_computer-activity/gnuchess/test.c b/src/chess_computer-activity/gnuchess/test.c
index db340df..b9becb0 100644
--- a/src/chess_computer-activity/gnuchess/test.c
+++ b/src/chess_computer-activity/gnuchess/test.c
@@ -1,7 +1,7 @@
 /* GNU Chess 5.0 - test.c - testing code
    Copyright (c) 1999-2002 Free Software Foundation, Inc.
 
-   GNU Chess is based on the two research programs 
+   GNU Chess is based on the two research programs
    Cobalt by Chua Kong-Sian and Gazebo by Stuart Cracraft.
 
    GNU Chess is free software; you can redistribute it and/or modify
@@ -19,7 +19,7 @@
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.
 
-   Contact Info: 
+   Contact Info:
      bug-gnu-chess gnu org
      cracraft ai mit edu, cracraft stanfordalumni org, cracraft earthlink net
 */
@@ -42,7 +42,6 @@ void TestMoveGenSpeed (void)
    unsigned long i;
    struct timeval t1, t2;
    double et;
-   short side, xside;
 
    GenCnt = 0;
    et = 0;
@@ -51,8 +50,6 @@ void TestMoveGenSpeed (void)
    {
 */
       gettimeofday (&t1, NULL);
-      side = board.side;
-      xside = 1^side;
       for (i = 0; i < 2000000; i++)
       {
 	 TreePtr[2] = TreePtr[1];
@@ -103,7 +100,7 @@ void TestNonCaptureGenSpeed (void)
    printf ("No. of moves generated = %lu\n", GenCnt);
    printf ("Time taken = %f\n", et);
    if (et > 0)
-      printf ("Rate = %f\n", GenCnt / et);  
+      printf ("Rate = %f\n", GenCnt / et);
 }
 
 
@@ -138,26 +135,26 @@ void TestCaptureGenSpeed (void)
    printf ("No. of moves generated = %lu\n", GenCnt);
    printf ("Time taken = %f\n", et);
    if (et > 0)
-      printf ("Rate = %f\n", GenCnt / et);  
+      printf ("Rate = %f\n", GenCnt / et);
 }
 
 
 void TestMoveList (void)
 /****************************************************************************
- *  
+ *
  *  This routine reads in a *.epd file (EPD notation) and prints the legal
- *  moves for that position.  
+ *  moves for that position.
  *
  ****************************************************************************/
 {
    while (ReadEPDFile ("TEST/GMG1.epd", 0))
    {
-      ShowBoard (); 
+      ShowBoard ();
       GenCnt = 0;
       TreePtr[2] = TreePtr[1];
       GenMoves (1);
       FilterIllegalMoves (1);
-      ShowMoveList (1); 
+      ShowMoveList (1);
       printf ("No. of moves generated = %lu\n\n", GenCnt);
    }
 }
@@ -165,20 +162,20 @@ void TestMoveList (void)
 
 void TestNonCaptureList (void)
 /****************************************************************************
- *  
- *  This routine reads in a *.epd file (EPD notation) and prints the 
- *  non-capturing moves for that position.  
+ *
+ *  This routine reads in a *.epd file (EPD notation) and prints the
+ *  non-capturing moves for that position.
  *
  ****************************************************************************/
 {
    while (ReadEPDFile ("TEST/GMG1.epd", 0))
    {
-      ShowBoard (); 
+      ShowBoard ();
       GenCnt = 0;
       TreePtr[2] = TreePtr[1];
       GenNonCaptures (1);
       FilterIllegalMoves (1);
-      ShowMoveList (1); 
+      ShowMoveList (1);
       printf ("No. of moves generated = %lu\n\n", GenCnt);
    }
 }
@@ -186,20 +183,20 @@ void TestNonCaptureList (void)
 
 void TestCaptureList (void)
 /****************************************************************************
- *  
+ *
  *  This routine reads in a *.epd file (EPD notation) and prints the capture
- *  moves for that position.  
+ *  moves for that position.
  *
  ****************************************************************************/
 {
    while (ReadEPDFile ("TEST/GMG1.epd", 0))
    {
-      ShowBoard (); 
+      ShowBoard ();
       GenCnt = 0;
       TreePtr[2] = TreePtr[1];
       GenCaptures (1);
       FilterIllegalMoves (1);
-      ShowMoveList (1); 
+      ShowMoveList (1);
       printf ("No. of moves generated = %lu\n\n", GenCnt);
    }
 }
@@ -210,7 +207,7 @@ void TestCaptureList (void)
 void TestEvalSpeed (void)
 /***************************************************************************
  *
- *  This routine reads in the BK.epd and test the speed of the 
+ *  This routine reads in the BK.epd and test the speed of the
  *  evaluation routines.
  *
  ***************************************************************************/
@@ -235,7 +232,7 @@ void TestEvalSpeed (void)
    printf ("No. of positions evaluated = %lu\n", EvalCnt);
    printf ("Time taken = %f\n", et);
    if (et > 0)
-      printf ("Rate = %f\n", EvalCnt / et);  
+      printf ("Rate = %f\n", EvalCnt / et);
 }
 
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]