~paulbrianstewart/ubuntu/oneiric/gcompris/825448-Spelling-And-Grammar-Error

« back to all changes in this revision

Viewing changes to src/chess_computer-activity/gnuchess/hung.c

  • Committer: Bazaar Package Importer
  • Author(s): Yann Dirson
  • Date: 2010-06-27 22:51:30 UTC
  • mfrom: (1.1.16 upstream) (5.1.6 sid)
  • Revision ID: james.westby@ubuntu.com-20100627225130-mf7h4m5r8m7bd9fb
Tags: 9.3-1
* New upstream release.
* Drop GTK_DISABLE_DEPRECATED patch, useless for now.
* Provide RELEASE_NOTE_9.3.txt downloaded from sourceforge.
* New voice package for Asturian.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* GNU Chess 5.0 - hung.c - hung piece evaluation code
 
2
   Copyright (c) 1999-2002 Free Software Foundation, Inc.
 
3
 
 
4
   GNU Chess is based on the two research programs 
 
5
   Cobalt by Chua Kong-Sian and Gazebo by Stuart Cracraft.
 
6
 
 
7
   GNU Chess is free software; you can redistribute it and/or modify
 
8
   it under the terms of the GNU General Public License as published by
 
9
   the Free Software Foundation; either version 2, or (at your option)
 
10
   any later version.
 
11
 
 
12
   GNU Chess is distributed in the hope that it will be useful,
 
13
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
   GNU General Public License for more details.
 
16
 
 
17
   You should have received a copy of the GNU General Public License
 
18
   along with GNU Chess; see the file COPYING.  If not, write to
 
19
   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 
20
   Boston, MA 02111-1307, USA.
 
21
 
 
22
   Contact Info: 
 
23
     bug-gnu-chess@gnu.org
 
24
     cracraft@ai.mit.edu, cracraft@stanfordalumni.org, cracraft@earthlink.net
 
25
*/
 
26
/*
 
27
 *  Hung piece evaluation.
 
28
 */
 
29
 
 
30
#include <config.h>
 
31
#include <stdio.h>
 
32
#include "common.h"
 
33
 
 
34
int EvalHung(int side)
 
35
/****************************************************************************
 
36
 *
 
37
 *  Calculate the number of hung pieces for a side.
 
38
 *
 
39
 ****************************************************************************/
 
40
{
 
41
   BitBoard c, n, b, r, q;
 
42
   int xside;
 
43
 
 
44
   xside = 1 ^ side;
 
45
   hunged[side] = 0;
 
46
 
 
47
   /* Knight */
 
48
   n = (Ataks[xside][pawn] & board.b[side][knight]);
 
49
   n |= (Ataks[xside][0] & board.b[side][knight] & ~Ataks[side][0]);
 
50
 
 
51
   /* Bishop */
 
52
   b = (Ataks[xside][pawn] & board.b[side][bishop]);
 
53
   b |= (Ataks[xside][0] & board.b[side][bishop] & ~Ataks[side][0]);
 
54
 
 
55
   /* Rook */
 
56
   r = Ataks[xside][pawn] | Ataks[xside][knight] | Ataks[xside][bishop];
 
57
   r = (r & board.b[side][rook]);
 
58
   r |= (Ataks[xside][0] & board.b[side][rook] & ~Ataks[side][0]);
 
59
 
 
60
   /* Queen */
 
61
   q = Ataks[xside][pawn] | Ataks[xside][knight] | Ataks[xside][bishop] |
 
62
       Ataks[xside][rook];
 
63
   q = (q & board.b[side][queen]);
 
64
   q |= (Ataks[xside][0] & board.b[side][queen] & ~Ataks[side][0]);
 
65
 
 
66
   c = n | b | r | q ;
 
67
 
 
68
   if (c)
 
69
      hunged[side] += nbits (c);
 
70
 
 
71
   /* King */
 
72
   if (Ataks[xside][0] & board.b[side][king])
 
73
      hunged[side] ++;
 
74
 
 
75
   return (hunged[side]);
 
76
}