~ml-launchpad/ubuntu/natty/gcompris/fix-for-777349

« back to all changes in this revision

Viewing changes to src/chess_computer-activity/gnuchess/solve.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 - solve.c - position solving 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
 *
 
28
 */
 
29
 
 
30
#include <config.h>
 
31
#include <stdio.h>
 
32
#include <string.h>
 
33
#include "common.h"
 
34
 
 
35
 
 
36
void Solve (char *file)
 
37
/*****************************************************************************
 
38
 *
 
39
 *
 
40
 *
 
41
 *****************************************************************************/
 
42
{
 
43
   int total, correct, found;
 
44
   long TotalNodes;
 
45
   char *p;
 
46
 
 
47
   total = correct = 0;
 
48
   TotalNodes = 0;
 
49
   SET (flags, SOLVE); 
 
50
   while (ReadEPDFile (file, 0))
 
51
   {
 
52
      NewPosition ();
 
53
      total++;
 
54
      ShowBoard (); 
 
55
      Iterate ();
 
56
      TotalNodes += NodeCnt + QuiesCnt;
 
57
      p = solution;
 
58
      found = false;
 
59
      while (*p != '\0')
 
60
      {
 
61
         if (!strncmp (p, SANmv, strlen(SANmv)))
 
62
         {
 
63
            correct++;
 
64
            found = true;
 
65
            break;
 
66
         }
 
67
         while (*p != ' ' && *p != '\0') p++;
 
68
         while (*p == ' ' && *p != '\0') p++;
 
69
      }
 
70
      printf ("%s : ", id);
 
71
      printf (found ? "Correct:  " : "Incorrect:  ");
 
72
      printf ("%s %s\n", SANmv, solution);
 
73
      printf ("Correct=%d Total=%d\n", correct, total);
 
74
   }
 
75
   printf ("\nTotal nodes = %ld\n", TotalNodes);
 
76
   CLEAR (flags, SOLVE);
 
77
}
 
78