[llvm-commits] CVS: llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/Makefile count.c countlib.c endgame.c eval.c exambord.c findcolr.c findnext.c findopen.c findpatn.c findsavr.c findwinr.c fioe.c genmove.c getij.c getmove.c initmark.c main.c matchpat.c opening.c openregn.c random.c seed.c sethand.c showbord.c showinst.c suicide.c
Chris Lattner
lattner at cs.uiuc.edu
Tue Oct 5 12:42:27 PDT 2004
Changes in directory llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo:
Makefile added (r1.1)
count.c added (r1.1)
countlib.c added (r1.1)
endgame.c added (r1.1)
eval.c added (r1.1)
exambord.c added (r1.1)
findcolr.c added (r1.1)
findnext.c added (r1.1)
findopen.c added (r1.1)
findpatn.c added (r1.1)
findsavr.c added (r1.1)
findwinr.c added (r1.1)
fioe.c added (r1.1)
genmove.c added (r1.1)
getij.c added (r1.1)
getmove.c added (r1.1)
initmark.c added (r1.1)
main.c added (r1.1)
matchpat.c added (r1.1)
opening.c added (r1.1)
openregn.c added (r1.1)
random.c added (r1.1)
seed.c added (r1.1)
sethand.c added (r1.1)
showbord.c added (r1.1)
showinst.c added (r1.1)
suicide.c added (r1.1)
---
Log message:
New benchmark: gnu go 1.1.
This also has no input, but should at least be easier to come up with one
---
Diffs of the changes: (+2932 -0)
Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/Makefile
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/Makefile:1.1
*** /dev/null Tue Oct 5 14:42:26 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/Makefile Tue Oct 5 14:42:15 2004
***************
*** 0 ****
--- 1,5 ----
+ LEVEL = ../../../..
+
+ PROG = gnugo
+ include $(LEVEL)/MultiSource/Makefile.multisrc
+
Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/count.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/count.c:1.1
*** /dev/null Tue Oct 5 14:42:26 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/count.c Tue Oct 5 14:42:15 2004
***************
*** 0 ****
--- 1,97 ----
+ /*
+ GNU GO - the game of Go (Wei-Chi)
+ Version 1.1 last revised 3-1-89
+ Copyright (C) Free Software Foundation, Inc.
+ written by Man L. Li
+ modified by Wayne Iba
+ documented by Bob Webber
+ */
+ /*
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation - version 1.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License in file COPYING for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ Please report any bug/fix, modification, suggestion to
+
+ mail address: Man L. Li
+ Dept. of Computer Science
+ University of Houston
+ 4800 Calhoun Road
+ Houston, TX 77004
+
+ e-mail address: manli at cs.uh.edu (Internet)
+ coscgbn at uhvax1.bitnet (BITNET)
+ 70070,404 (CompuServe)
+ */
+
+ #include <stdio.h>
+
+ #define EMPTY 0
+
+ extern unsigned char p[19][19], ml[19][19];
+ extern int lib;
+
+ void count(int i, int j, int color)
+ /* count liberty of color piece at i, j */
+ {
+ /* set current piece as marked */
+ ml[i][j] = EMPTY;
+
+ /* check North neighbor */
+ if (i != EMPTY)
+ {
+ if ((p[i - 1][j] == EMPTY) && ml[i - 1][j])
+ {
+ ++lib;
+ ml[i - 1][j] = EMPTY;
+ }
+ else
+ if ((p[i - 1][j] == color) && ml[i - 1][j])
+ count(i - 1, j, color);
+ }
+ /* check South neighbor */
+ if (i != 18)
+ {
+ if ((p[i + 1][j] == EMPTY) && ml[i + 1][j])
+ {
+ ++lib;
+ ml[i + 1][j] = EMPTY;
+ }
+ else
+ if ((p[i + 1][j] == color) && ml[i + 1][j])
+ count(i + 1, j, color);
+ }
+ /* check West neighbor */
+ if (j != EMPTY)
+ {
+ if ((p[i][j - 1] == EMPTY) && ml[i][j - 1])
+ {
+ ++lib;
+ ml[i][j - 1] = EMPTY;
+ }
+ else
+ if ((p[i][j - 1] == color) && ml[i][j - 1])
+ count(i, j - 1, color);
+ }
+ /* check East neighbor */
+ if (j != 18)
+ {
+ if ((p[i][j + 1] == EMPTY) && ml[i][j + 1])
+ {
+ ++lib;
+ ml[i][j + 1] = EMPTY;
+ }
+ else
+ if ((p[i][j + 1] == color) && ml[i][j + 1])
+ count(i, j + 1, color);
+ }
+ } /* end count */
Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/countlib.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/countlib.c:1.1
*** /dev/null Tue Oct 5 14:42:26 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/countlib.c Tue Oct 5 14:42:15 2004
***************
*** 0 ****
--- 1,55 ----
+ /*
+ GNU GO - the game of Go (Wei-Chi)
+ Version 1.1 last revised 3-1-89
+ Copyright (C) Free Software Foundation, Inc.
+ written by Man L. Li
+ modified by Wayne Iba
+ documented by Bob Webber
+ */
+ /*
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation - version 1.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License in file COPYING for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ Please report any bug/fix, modification, suggestion to
+
+ mail address: Man L. Li
+ Dept. of Computer Science
+ University of Houston
+ 4800 Calhoun Road
+ Houston, TX 77004
+
+ e-mail address: manli at cs.uh.edu (Internet)
+ coscgbn at uhvax1.bitnet (BITNET)
+ 70070,404 (CompuServe)
+ */
+
+ #include <stdio.h>
+
+ extern unsigned char ml[19][19];
+
+ extern void count(int i, int j, int color);
+
+ void countlib(int m, int n, int color)
+ /* count liberty of color piece at m, n */
+ {
+ int i, j;
+
+ /* set all piece as unmarked */
+ for (i = 0; i < 19; i++)
+ for (j = 0; j < 19; j++)
+ ml[i][j] = 1;
+
+ /* count liberty of current piece */
+ count(m, n, color);
+ } /* end countlib */
+
Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/endgame.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/endgame.c:1.1
*** /dev/null Tue Oct 5 14:42:27 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/endgame.c Tue Oct 5 14:42:15 2004
***************
*** 0 ****
--- 1,135 ----
+ /*
+ GNU GO - the game of Go (Wei-Chi)
+ Version 1.1 last revised 3-1-89
+ Copyright (C) Free Software Foundation, Inc.
+ written by Man L. Li
+ modified by Wayne Iba
+ documented by Bob Webber
+ */
+ /*
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation - version 1.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License in file COPYING for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ Please report any bug/fix, modification, suggestion to
+
+ mail address: Man L. Li
+ Dept. of Computer Science
+ University of Houston
+ 4800 Calhoun Road
+ Houston, TX 77004
+
+ e-mail address: manli at cs.uh.edu (Internet)
+ coscgbn at uhvax1.bitnet (BITNET)
+ 70070,404 (CompuServe)
+ */
+
+ #include <stdio.h>
+
+ #define EMPTY 0
+
+ extern unsigned char p[19][19];
+ extern int mymove, umove;
+ extern int mk, uk; /* piece captured */
+
+ extern int getij(char move[], int *i, int *j);
+ extern void showboard(void);
+ extern int findcolor(int i, int j);
+
+ void endgame(void)
+ /* count pieces and announce the winner */
+ {
+ char an[10];
+ int i, j, mtot, utot, cont;
+
+ printf("\nTo count score, we need the following steps:\n");
+ printf("First, I need you to remove all dead pieces on the board.\n");
+ printf("Second, I need you to fill in neutral territories with ");
+ printf("pieces.\n");
+ printf("Last, I will fill in all pieces and anounce the winner.\n");
+
+ /* remove dead pieces */
+ printf("\nFirst, you should enter the dead pieces (blank and white) to");
+ printf(" be removed. Enter\n");
+ printf(" 'stop' when you have finished.\n");
+
+ cont = 1;
+ do {
+ printf("Dead piece? ");
+ scanf("%s", an);
+ if (strcmp(an, "stop"))
+ {
+ getij(an, &i, &j);
+ if (p[i][j] == mymove)
+ {
+ p[i][j] = EMPTY;
+ mk++;
+ }
+ else
+ if (p[i][j] == umove)
+ {
+ p[i][j] = EMPTY;
+ uk++;
+ }
+ showboard();
+ }
+ else
+ cont = 0;
+ }
+ while (cont);
+
+ /* fill in neutral */
+ printf("Next, you need to fill in pieces (black and white) in all neutral");
+ printf(" territories.\n");
+ printf("Enter your and my pieces alternately and enter 'stop' when finish\n");
+ cont = 1;
+
+ do {
+ printf("Your piece? ");
+ scanf("%s", an);
+ if (strcmp(an, "stop"))
+ {
+ getij(an, &i, &j);
+ p[i][j] = umove;
+ printf("My piece? ");
+ scanf("%s", an);
+ getij(an, &i, &j);
+ p[i][j] = mymove;
+ showboard();
+ }
+ else
+ cont = 0;
+ }
+ while (cont);
+
+ /* set empty to side they belong to */
+ for (i = 0; i < 19; i++)
+ for (j = 0; j < 19; j++)
+ if (p[i][j] == EMPTY)
+ p[i][j] = findcolor(i, j);
+
+ /* count total */
+ mtot = 0; utot = 0;
+ for (i = 0; i < 19; i++)
+ for (j = 0; j < 19; j++)
+ if (p[i][j] == mymove)
+ ++mtot;
+ else
+ if (p[i][j] == umove)
+ ++utot;
+
+ showboard();
+ printf("Your total number of pieces %d\n", utot);
+ printf("My total number of pieces %d\n", mtot);
+
+ } /* end endgame */
+
Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/eval.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/eval.c:1.1
*** /dev/null Tue Oct 5 14:42:27 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/eval.c Tue Oct 5 14:42:15 2004
***************
*** 0 ****
--- 1,57 ----
+ /*
+ GNU GO - the game of Go (Wei-Chi)
+ Version 1.1 last revised 3-1-89
+ Copyright (C) Free Software Foundation, Inc.
+ written by Man L. Li
+ modified by Wayne Iba
+ documented by Bob Webber
+ */
+ /*
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation - version 1.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License in file COPYING for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ Please report any bug/fix, modification, suggestion to
+
+ mail address: Man L. Li
+ Dept. of Computer Science
+ University of Houston
+ 4800 Calhoun Road
+ Houston, TX 77004
+
+ e-mail address: manli at cs.uh.edu (Internet)
+ coscgbn at uhvax1.bitnet (BITNET)
+ 70070,404 (CompuServe)
+ */
+
+ #include <stdio.h>
+
+ extern unsigned char p[19][19], l[19][19];
+ extern int lib;
+
+ extern void countlib(int m, int n, int color);
+
+ void eval(int color)
+ /* evaluate liberty of color pieces */
+ {
+ int i, j;
+
+ /* find liberty of each piece */
+ for (i = 0; i < 19; i++)
+ for (j = 0; j < 19; j++)
+ if (p[i][j] == color)
+ {
+ lib = 0;
+ countlib(i, j, color);
+ l[i][j] = lib;
+ }
+ } /* end eval */
Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/exambord.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/exambord.c:1.1
*** /dev/null Tue Oct 5 14:42:27 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/exambord.c Tue Oct 5 14:42:15 2004
***************
*** 0 ****
--- 1,101 ----
+ /*
+ GNU GO - the game of Go (Wei-Chi)
+ Version 1.1 last revised 3-1-89
+ Copyright (C) Free Software Foundation, Inc.
+ written by Man L. Li
+ modified by Wayne Iba
+ documented by Bob Webber
+ */
+ /*
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation - version 1.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License in file COPYING for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ Please report any bug/fix, modification, suggestion to
+
+ mail address: Man L. Li
+ Dept. of Computer Science
+ University of Houston
+ 4800 Calhoun Road
+ Houston, TX 77004
+
+ e-mail address: manli at cs.uh.edu (Internet)
+ coscgbn at uhvax1.bitnet (BITNET)
+ 70070,404 (CompuServe)
+ */
+
+ #include <stdio.h>
+
+ #define EMPTY 0
+
+ extern unsigned char p[19][19], l[19][19];
+ extern int mymove;
+ extern int mik, mjk, uik, ujk, mk, uk; /* piece captured */
+
+ extern void eval(int color);
+
+ void examboard(int color)
+ /* examine pieces */
+ {
+ int i, j, n;
+
+
+ /* find liberty of each piece */
+ eval(color);
+
+ /* initialize piece captured */
+ if (color == mymove)
+ {
+ mik = -1;
+ mjk = -1;
+ }
+ else
+ {
+ uik = -1;
+ ujk = -1;
+ }
+ n = 0; /* The number of captures this move for Ko purposes */
+
+ /* remove all piece of zero liberty */
+ for (i = 0; i < 19; i++)
+ for (j = 0; j < 19; j++)
+ if ((p[i][j] == color) && (l[i][j] == 0))
+ {
+ p[i][j] = EMPTY;
+ /* record piece captured */
+ if (color == mymove)
+ {
+ mik = i;
+ mjk = j;
+ ++mk;
+ }
+ else
+ {
+ uik = i;
+ ujk = j;
+ ++uk;
+ }
+ ++n; /* increment number of captures on this move */
+ }
+ /* reset to -1 if more than one stone captured since no Ko possible */
+ if (color == mymove && n > 1)
+ {
+ mik = -1;
+ mjk = -1;
+ }
+ else if ( n > 1 )
+ {
+ uik = -1;
+ ujk = -1;
+ }
+ } /* end examboard */
+
Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/findcolr.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/findcolr.c:1.1
*** /dev/null Tue Oct 5 14:42:27 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/findcolr.c Tue Oct 5 14:42:15 2004
***************
*** 0 ****
--- 1,101 ----
+ /*
+ GNU GO - the game of Go (Wei-Chi)
+ Version 1.1 last revised 3-1-89
+ Copyright (C) Free Software Foundation, Inc.
+ written by Man L. Li
+ modified by Wayne Iba
+ documented by Bob Webber
+ */
+ /*
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation - version 1.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License in file COPYING for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ Please report any bug/fix, modification, suggestion to
+
+ mail address: Man L. Li
+ Dept. of Computer Science
+ University of Houston
+ 4800 Calhoun Road
+ Houston, TX 77004
+
+ e-mail address: manli at cs.uh.edu (Internet)
+ coscgbn at uhvax1.bitnet (BITNET)
+ 70070,404 (CompuServe)
+ */
+
+ #include <stdio.h>
+
+ #define EMPTY 0
+
+ extern unsigned char p[19][19];
+
+ int findcolor(int i, int j)
+ /* find color for empty piece */
+ {
+ int k, color1, color2;
+
+ /* check North neighbor */
+ color1 = 0;
+ k = i;
+ do --k;
+ while ((p[k][j] == EMPTY) && (k > 0));
+ color1 = p[k][j];
+
+ /* check South neighbor */
+ color2 = 0;
+ k = i;
+ do k++;
+ while ((p[k][j] == EMPTY) && (k < 18));
+ color2 = p[k][j];
+
+ if (color1)
+ {
+ if ((color1 == color2) || (color2 == 0))
+ return color1;
+ else
+ return 0; /* cannot determine */
+ }
+ else
+ if (color2)
+ return color2;
+ else /* both zero */
+ {
+ /* check West neighbor */
+ color1 = 0;
+ k = j;
+ do --k;
+ while ((p[i][k] == EMPTY) && (k > 0));
+ color1 = p[i][k];
+
+ /* check East neighbor */
+ color2 = 0;
+ k = j;
+ do k++;
+ while ((p[i][k] == EMPTY) && (k < 18));
+ color2 = p[i][k];
+
+ if (color1)
+ {
+ if ((color1 == color2) || (color2 == 0))
+ return color1;
+ else
+ return 0; /* cannot determine */
+ }
+ else
+ if (color2)
+ return color2;
+ else
+ return 0;
+ }
+ } /* end findcolor */
+
Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/findnext.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/findnext.c:1.1
*** /dev/null Tue Oct 5 14:42:27 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/findnext.c Tue Oct 5 14:42:15 2004
***************
*** 0 ****
--- 1,189 ----
+ /*
+ GNU GO - the game of Go (Wei-Chi)
+ Version 1.1 last revised 3-1-89
+ Copyright (C) Free Software Foundation, Inc.
+ written by Man L. Li
+ modified by Wayne Iba
+ documented by Bob Webber
+ */
+ /*
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation - version 1.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License in file COPYING for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ Please report any bug/fix, modification, suggestion to
+
+ mail address: Man L. Li
+ Dept. of Computer Science
+ University of Houston
+ 4800 Calhoun Road
+ Houston, TX 77004
+
+ e-mail address: manli at cs.uh.edu (Internet)
+ coscgbn at uhvax1.bitnet (BITNET)
+ 70070,404 (CompuServe)
+ */
+
+ #include <stdio.h>
+
+ #define EMPTY 0
+
+ extern unsigned char p[19][19], ma[19][19];
+ extern int mymove;
+ extern int lib;
+
+ extern void countlib(int m, int n, int color);
+ extern int fval(int newlib, int minlib);
+
+ int findnextmove(int m, int n, int *i, int *j, int *val, int minlib)
+ /* find new move i, j from group containing m, n */
+ {
+ int ti, tj, tval;
+ int found = 0;
+
+ *i = -1; *j = -1; *val = -1;
+ /* mark current position */
+ ma[m][n] = 1;
+
+ /* check North neighbor */
+ if (m != 0)
+ if (p[m - 1][n] == EMPTY)
+ {
+ ti = m - 1;
+ tj = n;
+ lib = 0;
+ countlib(ti, tj, mymove);
+ tval = fval(lib, minlib);
+ found = 1;
+ }
+ else
+ if ((p[m - 1][n] == mymove) && !ma[m - 1][n])
+ if (findnextmove(m - 1, n, &ti, &tj, &tval, minlib))
+ found = 1;
+
+ if (found)
+ {
+ found = 0;
+ if (tval > *val)
+ {
+ *val = tval;
+ *i = ti;
+ *j = tj;
+ }
+ if (minlib == 1) return 1;
+ }
+
+ /* check South neighbor */
+ if (m != 18)
+ if (p[m + 1][n] == EMPTY)
+ {
+ ti = m + 1;
+ tj = n;
+ lib = 0;
+ countlib(ti, tj, mymove);
+ tval = fval(lib, minlib);
+ found = 1;
+ }
+ else
+ if ((p[m + 1][n] == mymove) && !ma[m + 1][n])
+ if (findnextmove(m + 1, n, &ti, &tj, &tval, minlib))
+ found = 1;
+
+ if (found)
+ {
+ found = 0;
+ if (tval > *val)
+ {
+ *val = tval;
+ *i = ti;
+ *j = tj;
+ }
+ if (minlib == 1) return 1;
+ }
+
+ /* check West neighbor */
+ if (n != 0)
+ if (p[m][n - 1] == EMPTY)
+ {
+ ti = m;
+ tj = n - 1;
+ lib = 0;
+ countlib(ti, tj, mymove);
+ tval = fval(lib, minlib);
+ found = 1;
+ }
+ else
+ if ((p[m][n - 1] == mymove) && !ma[m][n - 1])
+ if (findnextmove(m, n - 1, &ti, &tj, &tval, minlib))
+ found = 1;
+
+ if (found)
+ {
+ found = 0;
+ if (tval > *val)
+ {
+ *val = tval;
+ *i = ti;
+ *j = tj;
+ }
+ if (minlib == 1) return 1;
+ }
+
+ /* check East neighbor */
+ if (n != 18)
+ if (p[m][n + 1] == EMPTY)
+ {
+ ti = m;
+ tj = n + 1;
+ lib = 0;
+ countlib(ti, tj, mymove);
+ tval = fval(lib, minlib);
+ found = 1;
+ }
+ else
+ if ((p[m][n + 1] == mymove) && !ma[m][n + 1])
+ if (findnextmove(m, n + 1, &ti, &tj, &tval, minlib))
+ found = 1;
+
+ if (found)
+ {
+ found = 0;
+ if (tval > *val)
+ {
+ *val = tval;
+ *i = ti;
+ *j = tj;
+ }
+ if (minlib == 1) return 1;
+ }
+
+ if (*val > 0) /* found next move */
+ return 1;
+ else /* next move failed */
+ return 0;
+ } /* end findnextmove */
+
+
+ int fval(int newlib, int minlib)
+ /* evaluate new move */
+ {
+ int k, val;
+
+ if (newlib <= minlib)
+ val = -1;
+ else
+ {
+ k = newlib - minlib;
+ val = 40 + (k - 1) * 50 / (minlib * minlib * minlib);
+ }
+ return val;
+ } /* end fval */
Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/findopen.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/findopen.c:1.1
*** /dev/null Tue Oct 5 14:42:27 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/findopen.c Tue Oct 5 14:42:15 2004
***************
*** 0 ****
--- 1,115 ----
+ /*
+ GNU GO - the game of Go (Wei-Chi)
+ Version 1.1 last revised 3-1-89
+ Copyright (C) Free Software Foundation, Inc.
+ written by Man L. Li
+ modified by Wayne Iba
+ documented by Bob Webber
+ */
+ /*
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation - version 1.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License in file COPYING for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ Please report any bug/fix, modification, suggestion to
+
+ mail address: Man L. Li
+ Dept. of Computer Science
+ University of Houston
+ 4800 Calhoun Road
+ Houston, TX 77004
+
+ e-mail address: manli at cs.uh.edu (Internet)
+ coscgbn at uhvax1.bitnet (BITNET)
+ 70070,404 (CompuServe)
+ */
+
+ #include <stdio.h>
+
+ #define EMPTY 0
+
+ extern unsigned char p[19][19], ma[19][19];
+ extern int mik, mjk; /* piece captured */
+
+ int findopen(int m, int n, int i[], int j[], int color, int minlib, int *ct)
+ /* find all open spaces i, j from m, n */
+ {
+ /* mark this one */
+ ma[m][n] = 1;
+
+ /* check North neighbor */
+ if (m != 0)
+ {
+ if ((p[m - 1][n] == EMPTY) && (((m - 1) != mik) || (n != mjk)))
+ {
+ i[*ct] = m - 1;
+ j[*ct] = n;
+ ++*ct;
+ if (*ct == minlib) return 1;
+ }
+ else
+ if ((p[m - 1][n] == color) && !ma[m - 1][n])
+ if (findopen(m - 1, n, i, j, color, minlib, ct) && (*ct == minlib))
+ return 1;
+ }
+
+ /* check South neighbor */
+ if (m != 18)
+ {
+ if ((p[m + 1][n] == EMPTY) && (((m + 1) != mik) || (n != mjk)))
+ {
+ i[*ct] = m + 1;
+ j[*ct] = n;
+ ++*ct;
+ if (*ct == minlib) return 1;
+ }
+ else
+ if ((p[m + 1][n] == color) && !ma[m + 1][n])
+ if (findopen(m + 1, n, i, j, color, minlib, ct) && (*ct == minlib))
+ return 1;
+ }
+
+ /* check West neighbor */
+ if (n != 0)
+ {
+ if ((p[m][n - 1] == EMPTY) && ((m != mik) || ((n - 1) != mjk)))
+ {
+ i[*ct] = m;
+ j[*ct] = n - 1;
+ ++*ct;
+ if (*ct == minlib) return 1;
+ }
+ else
+ if ((p[m][n - 1] == color) && !ma[m][n - 1])
+ if (findopen(m, n - 1, i, j, color, minlib, ct) && (*ct == minlib))
+ return 1;
+ }
+
+ /* check East neighbor */
+ if (n != 18)
+ {
+ if ((p[m][n + 1] == EMPTY) && ((m != mik) || ((n + 1) != mjk)))
+ {
+ i[*ct] = m;
+ j[*ct] = n + 1;
+ ++*ct;
+ if (*ct == minlib) return 1;
+ }
+ else
+ if ((p[m][n + 1] == color) && !ma[m][n + 1])
+ if (findopen(m, n + 1, i, j, color, minlib, ct) && (*ct == minlib))
+ return 1;
+ }
+
+ /* fail to find open space */
+ return 0;
+ } /* end findopen */
Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/findpatn.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/findpatn.c:1.1
*** /dev/null Tue Oct 5 14:42:27 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/findpatn.c Tue Oct 5 14:42:15 2004
***************
*** 0 ****
--- 1,193 ----
+ /*
+ GNU GO - the game of Go (Wei-Chi)
+ Version 1.1 last revised 3-1-89
+ Copyright (C) Free Software Foundation, Inc.
+ written by Man L. Li
+ modified by Wayne Iba
+ documented by Bob Webber
+ */
+ /*
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation - version 1.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License in file COPYING for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ Please report any bug/fix, modification, suggestion to
+
+ mail address: Man L. Li
+ Dept. of Computer Science
+ University of Houston
+ 4800 Calhoun Road
+ Houston, TX 77004
+
+ e-mail address: manli at cs.uh.edu (Internet)
+ coscgbn at uhvax1.bitnet (BITNET)
+ 70070,404 (CompuServe)
+ */
+
+ #include <stdio.h>
+
+ #define EMPTY 0
+
+ extern unsigned char p[19][19];
+ extern int mymove, umove;
+ extern int opn[9];
+
+ extern int opening(int *i, int *j, int *cnd, int type);
+ extern int openregion(int i1, int j1, int i2, int j2);
+ extern int matchpat(int m, int n, int *i, int *j, int *val);
+
+ int findpatn(int *i, int *j, int *val)
+ /* find pattern to match for next move */
+ {
+ int m, n;
+ int ti, tj, tval;
+ static int cnd, mtype; /* game tree node number, move type */
+ /* mtype = 0, basic; 1, inverted; 2, reflected; 3, inverted & reflected */
+
+ /* open game then occupy corners */
+ if (opn[4]) /* continue last move */
+ {
+ opn[4] = 0; /* clear flag */
+ if (opening(i, j, &cnd, mtype)) opn[4] = 1; /* more move then reset flag */
+ if (p[*i][*j] == EMPTY) /* valid move */
+ {
+ *val = 80;
+ return 1;
+ }
+ else
+ opn[4] = 0;
+ }
+
+ if (opn[0]) /* Northwest corner */
+ {
+ opn[0] = 0; /* clear flag */
+ if (openregion(0, 0, 5, 5))
+ {
+ cnd = 0;
+ mtype = 0;
+ opening(i, j, &cnd, mtype); /* get new node for next move */
+ if (opening(i, j, &cnd, mtype)) opn[4] = 1;
+ *val = 80;
+ return 1;
+ }
+ }
+
+ if (opn[1]) /* Southwest corner */
+ {
+ opn[1] = 0;
+ if (openregion(13, 0, 18, 5))
+ {
+ cnd = 0;
+ mtype = 1;
+ opening(i, j, &cnd, mtype); /* get new node for next move */
+ if (opening(i, j, &cnd, mtype)) opn[4] = 1;
+ *val = 80;
+ return 1;
+ }
+ }
+
+ if (opn[2]) /* Northeast corner */
+ {
+ opn[2] = 0;
+ if (openregion(0, 13, 5, 18))
+ {
+ cnd = 0;
+ mtype = 2;
+ opening(i, j, &cnd, mtype); /* get new node for next move */
+ if (opening(i, j, &cnd, mtype)) opn[4] = 1;
+ *val = 80;
+ return 1;
+ }
+ }
+
+ if (opn[3]) /* Northeast corner */
+ {
+ opn[3] = 0;
+ if (openregion(13, 13, 18, 18))
+ {
+ cnd = 0;
+ mtype = 3;
+ opening(i, j, &cnd, mtype); /* get new node for next move */
+ if (opening(i, j, &cnd, mtype)) opn[4] = 1;
+ *val = 80;
+ return 1;
+ }
+ }
+
+ /* occupy edges */
+ if (opn[5]) /* North edge */
+ {
+ opn[5] = 0;
+ if (openregion(0, 6, 4, 11))
+ {
+ *i = 3;
+ *j = 9;
+ *val = 80;
+ return 1;
+ }
+ }
+
+ if (opn[6]) /* South edge */
+ {
+ opn[6] = 0;
+ if (openregion(18, 6, 14, 11))
+ {
+ *i = 15;
+ *j = 9;
+ *val = 80;
+ return 1;
+ }
+ }
+
+ if (opn[7]) /* West edge */
+ {
+ opn[7] = 0;
+ if (openregion(6, 0, 11, 4))
+ {
+ *i = 9;
+ *j = 3;
+ *val = 80;
+ return 1;
+ }
+ }
+
+ if (opn[8]) /* East edge */
+ {
+ opn[8] = 0;
+ if (openregion(6, 18, 11, 14))
+ {
+ *i = 9;
+ *j = 15;
+ *val = 80;
+ return 1;
+ }
+ }
+
+ *i = -1;
+ *j = -1;
+ *val = -1;
+
+ /* find local pattern */
+ for (m = 0; m < 19; m++)
+ for (n = 0; n < 19; n++)
+ if ((p[m][n] == mymove) &&
+ (matchpat(m, n, &ti, &tj, &tval) && (tval > *val)))
+ {
+ *val = tval;
+ *i = ti;
+ *j = tj;
+ }
+ if (*val > 0) /* pattern found */
+ return 1;
+ else /* no match found */
+ return 0;
+ } /* end findpatn */
Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/findsavr.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/findsavr.c:1.1
*** /dev/null Tue Oct 5 14:42:27 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/findsavr.c Tue Oct 5 14:42:15 2004
***************
*** 0 ****
--- 1,75 ----
+ /*
+ GNU GO - the game of Go (Wei-Chi)
+ Version 1.1 last revised 3-1-89
+ Copyright (C) Free Software Foundation, Inc.
+ written by Man L. Li
+ modified by Wayne Iba
+ documented by Bob Webber
+ */
+ /*
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation - version 1.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License in file COPYING for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ Please report any bug/fix, modification, suggestion to
+
+ mail address: Man L. Li
+ Dept. of Computer Science
+ University of Houston
+ 4800 Calhoun Road
+ Houston, TX 77004
+
+ e-mail address: manli at cs.uh.edu (Internet)
+ coscgbn at uhvax1.bitnet (BITNET)
+ 70070,404 (CompuServe)
+
+
+
+ */
+
+ #include <stdio.h>
+
+ extern unsigned char p[19][19], l[19][19];
+ extern int mymove;
+
+ extern void initmark(void);
+ extern int findnextmove(int m, int n, int *i, int *j, int *val, int minlib);
+
+ int findsaver(int *i, int *j, int *val)
+ /* find move if any pieces is threaten */
+ {
+ int m, n, minlib;
+ int ti, tj, tval;
+
+ *i = -1; *j = -1; *val = -1;
+ for (minlib = 1; minlib < 4; minlib++)
+ {
+ /* count piece with minimum liberty */
+ for (m = 0; m < 19; m++)
+ for (n = 0; n < 19; n++)
+ if ((p[m][n] == mymove) && (l[m][n] == minlib))
+ /* find move to save pieces */
+ {
+ initmark();
+ if (findnextmove(m, n, &ti, &tj, &tval, minlib) && (tval > *val))
+ {
+ *val = tval;
+ *i = ti;
+ *j = tj;
+ }
+ }
+ }
+ if (*val > 0) /* find move */
+ return 1;
+ else /* move not found */
+ return 0;
+ } /* findsaver */
Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/findwinr.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/findwinr.c:1.1
*** /dev/null Tue Oct 5 14:42:27 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/findwinr.c Tue Oct 5 14:42:15 2004
***************
*** 0 ****
--- 1,106 ----
+ /*
+ GNU GO - the game of Go (Wei-Chi)
+ Version 1.1 last revised 3-1-89
+ Copyright (C) Free Software Foundation, Inc.
+ written by Man L. Li
+ modified by Wayne Iba
+ documented by Bob Webber
+ */
+ /*
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation - version 1.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License in file COPYING for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ Please report any bug/fix, modification, suggestion to
+
+ mail address: Man L. Li
+ Dept. of Computer Science
+ University of Houston
+ 4800 Calhoun Road
+ Houston, TX 77004
+
+ e-mail address: manli at cs.uh.edu (Internet)
+ coscgbn at uhvax1.bitnet (BITNET)
+ 70070,404 (CompuServe)
+ */
+
+ #include <stdio.h>
+
+ #define EMPTY 0
+
+ extern unsigned char p[19][19], l[19][19];
+ extern int mymove, umove;
+ extern int lib;
+
+ extern void initmark(void);
+ extern int findopen(int m, int n, int i[], int j[], int color, int minlib, int *ct);
+ extern void countlib(int m, int n, int color);
+
+ int findwinner(int *i, int *j, int *val)
+ /* find opponent piece to capture or attack */
+ {
+ int m, n, ti[3], tj[3], tval, ct, u, v, lib1;
+
+ *i = -1; *j = -1; *val = -1;
+
+ /* find opponent with liberty less than four */
+ for (m = 0; m < 19; m++)
+ for (n = 0; n < 19; n++)
+ if ((p[m][n] == umove) && (l[m][n] < 4))
+ {
+ ct = 0;
+ initmark();
+ if (findopen(m, n, ti, tj, umove, l[m][n], &ct))
+ {
+ if (l[m][n] == 1)
+ {
+ if (*val < 120)
+ {
+ *val = 120;
+ *i = ti[0];
+ *j = tj[0];
+ }
+ }
+ else
+ for (u = 0; u < l[m][n]; u++)
+ for (v = 0; v < l[m][n]; v++)
+ if (u != v)
+ {
+ lib = 0;
+ countlib(ti[u], tj[u], mymove);
+ if (lib > 0) /* valid move */
+ {
+ lib1 = lib;
+ p[ti[u]][tj[u]] = mymove;
+ /* look ahead opponent move */
+ lib = 0;
+ countlib(ti[v], tj[v], umove);
+ if ((lib1 == 1) && (lib > 0))
+ tval = 0;
+ else
+ tval = 120 - 20 * lib;
+ if (*val < tval)
+ {
+ *val = tval;
+ *i = ti[u];
+ *j = tj[u];
+ }
+ p[ti[u]][tj[u]] = EMPTY;
+ }
+ }
+ }
+ }
+ if (*val > 0) /* find move */
+ return 1;
+ else /* fail to find winner */
+ return 0;
+ } /* end findwinner */
Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/fioe.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/fioe.c:1.1
*** /dev/null Tue Oct 5 14:42:27 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/fioe.c Tue Oct 5 14:42:15 2004
***************
*** 0 ****
--- 1,84 ----
+ /*
+ GNU GO - the game of Go (Wei-Chi)
+ Version 1.1 last revised 3-1-89
+ Copyright (C) Free Software Foundation, Inc.
+ written by Man L. Li
+ modified by Wayne Iba
+ documented by Bob Webber
+ */
+ /*
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation - version 1.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License in file COPYING for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ Please report any bug/fix, modification, suggestion to
+
+ mail address: Man L. Li
+ Dept. of Computer Science
+ University of Houston
+ 4800 Calhoun Road
+ Houston, TX 77004
+
+ e-mail address: manli at cs.uh.edu (Internet)
+ coscgbn at uhvax1.bitnet (BITNET)
+ 70070,404 (CompuServe)
+ */
+
+ #include <stdio.h>
+
+ extern unsigned char p[19][19];
+ extern int mymove;
+
+ int fioe(int i, int j)
+ {
+ /* check top edge */
+ if (i == 0)
+ {
+ if ((j == 0) && ((p[1][0] == mymove) && (p[0][1] == mymove))) return 1;
+ if ((j == 18) && ((p[1][18] == mymove) && (p[0][17] == mymove))) return 1;
+ if ((p[1][j] == mymove) &&
+ ((p[0][j - 1] == mymove) && (p[0][j + 1] == mymove))) return 1;
+ else
+ return 0;
+ }
+ /* check bottom edge */
+ if (i == 18)
+ {
+ if ((j == 0) && ((p[17][0] == mymove) && (p[18][1] == mymove))) return 1;
+ if ((j == 18) && ((p[17][18] == mymove) && (p[18][17] == mymove))) return 1;
+ if ((p[17][j] == mymove) &&
+ ((p[18][j - 1] == mymove) && (p[18][j + 1] == mymove)))
+ return 1;
+ else
+ return 0;
+ }
+ /* check left edge */
+ if (j == 0)
+ if ((p[i][1] == mymove) &&
+ ((p[i - 1] [0] == mymove) && (p[i + 1][0] == mymove)))
+ return 1;
+ else
+ return 0;
+ /* check right edge */
+ if (j == 18)
+ if ((p[i][17] == mymove) &&
+ ((p[i - 1] [18] == mymove) && (p[i + 1][18] == mymove)))
+ return 1;
+ else
+ return 0;
+ /* check center pieces */
+ if (((p[i][j - 1] == mymove) && (p[i][j + 1] == mymove)) &&
+ ((p[i - 1][j] == mymove) && (p[i + 1][j] == mymove)))
+ return 1;
+ else
+ return 0;
+ } /* fioe */
Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/genmove.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/genmove.c:1.1
*** /dev/null Tue Oct 5 14:42:27 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/genmove.c Tue Oct 5 14:42:15 2004
***************
*** 0 ****
--- 1,151 ----
+ /*
+ GNU GO - the game of Go (Wei-Chi)
+ Version 1.1 last revised 3-1-89
+ Copyright (C) Free Software Foundation, Inc.
+ written by Man L. Li
+ modified by Wayne Iba
+ documented by Bob Webber
+ */
+ /*
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation - version 1.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License in file COPYING for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ Please report any bug/fix, modification, suggestion to
+
+ mail address: Man L. Li
+ Dept. of Computer Science
+ University of Houston
+ 4800 Calhoun Road
+ Houston, TX 77004
+
+ e-mail address: manli at cs.uh.edu (Internet)
+ coscgbn at uhvax1.bitnet (BITNET)
+ 70070,404 (CompuServe)
+ */
+
+ #include <stdio.h>
+
+ #define EMPTY 0
+ #define MAXTRY 400
+
+ extern unsigned char p[19][19];
+ extern int mymove, umove;
+ extern int rd, lib, pass;
+
+ extern void eval(int color);
+ extern int findwinner(int *i, int *j, int *val);
+ extern int findsaver(int *i, int *j, int *val);
+ extern int findpatn(int *i, int *j, int *val);
+ extern void random_nasko(int *i);
+ extern void countlib(int m, int n, int color);
+ extern int fioe(int i, int j);
+
+ void genmove(int *i, int *j)
+ /* generate computer move */
+ {
+ int ti, tj, tval;
+ char a;
+ int ii, val;
+ int try1 = 0; /* number of try */
+
+ /* initialize move and value */
+ *i = -1; *j = -1; val = -1;
+
+ /* re-evaluate liberty of opponent pieces */
+ eval(umove);
+
+ /* find opponent piece to capture or attack */
+ if (findwinner(&ti, &tj, &tval))
+ if (tval > val)
+ {
+ val = tval;
+ *i = ti;
+ *j = tj;
+ }
+
+ /* save any piece if threaten */
+ if (findsaver(&ti, &tj, &tval))
+ if (tval > val)
+ {
+ val = tval;
+ *i = ti;
+ *j = tj;
+ }
+
+ /* try match local play pattern for new move */
+ if (findpatn(&ti, &tj, &tval))
+ if (tval > val)
+ {
+ val = tval;
+ *i = ti;
+ *j = tj;
+ }
+
+ /* no urgent move then do random move */
+ if (val < 0)
+ do {
+ random_nasko(&rd);
+ *i = rd % 19;
+ /* avoid low line and center region */
+ if ((*i < 2) || (*i > 16) || ((*i > 5) && (*i < 13)))
+ {
+ random_nasko(&rd);
+ *i = rd % 19;
+ if ((*i < 2) || (*i > 16))
+ {
+ random_nasko(&rd);
+ *i = rd % 19;
+ }
+ }
+ random_nasko(&rd);
+ *j = rd % 19;
+ /* avoid low line and center region */
+ if ((*j < 2) || (*j > 16) || ((*j > 5) && (*j < 13)))
+ {
+ random_nasko(&rd);
+ *j = rd % 19;
+ if ((*j < 2) || (*j > 16))
+ {
+ random_nasko(&rd);
+ *j = rd % 19;
+ }
+ }
+ lib = 0;
+ countlib(*i, *j, mymove);
+ }
+ /* avoid illegal move, liberty one or suicide, fill in own eye */
+ while ((++try1 < MAXTRY)
+ && ((p[*i][*j] != EMPTY) || (lib < 2) || fioe(*i, *j)));
+
+ if (try1 >= MAXTRY) /* computer pass */
+ {
+ pass++;
+ printf("I pass.\n");
+ *i = -1;
+ }
+ else /* find valid move */
+ {
+ pass = 0;
+ printf("my move: ");
+ if (*j < 8)
+ a = *j + 65;
+ else
+ a = *j + 66;
+ printf("%c", a);
+ ii = 19 - *i;
+ if (ii < 10)
+ printf("%1d\n", ii);
+ else
+ printf("%2d\n", ii);
+ }
+ } /* end genmove */
Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/getij.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/getij.c:1.1
*** /dev/null Tue Oct 5 14:42:27 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/getij.c Tue Oct 5 14:42:15 2004
***************
*** 0 ****
--- 1,63 ----
+ /*
+ GNU GO - the game of Go (Wei-Chi)
+ Version 1.1 last revised 3-1-89
+ Copyright (C) Free Software Foundation, Inc.
+ written by Man L. Li
+ modified by Wayne Iba
+ documented by Bob Webber
+ */
+ /*
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation - version 1.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License in file COPYING for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ Please report any bug/fix, modification, suggestion to
+
+ mail address: Man L. Li
+ Dept. of Computer Science
+ University of Houston
+ 4800 Calhoun Road
+ Houston, TX 77004
+
+ e-mail address: manli at cs.uh.edu (Internet)
+ coscgbn at uhvax1.bitnet (BITNET)
+ 70070,404 (CompuServe)
+ */
+
+ #include <stdio.h>
+
+ int getij(char move[], int *i, int *j)
+ /* convert string input to i, j coordinate */
+ {
+ int k;
+
+ if ((move[0] >= 65) && (move[0] <= 72))
+ *j = move[0] - 65;
+ else
+ if ((move[0] >= 74) && (move[0] <= 84))
+ *j = move[0] - 66;
+ else
+ if ((move[0] >= 97) && (move[0] <= 104))
+ *j = move[0] - 97;
+ else
+ if ((move[0] >= 106) && (move[0] <= 116))
+ *j = move[0] - 98;
+ else
+ return 0;
+ k = move[1] - 48;
+ if (move[2]) k = k * 10 + move[2] - 48;
+ *i = 19 - k;
+ if ((*i >= 0) && (*i <= 18))
+ return 1;
+ else
+ return 0;
+ } /* end getij */
Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/getmove.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/getmove.c:1.1
*** /dev/null Tue Oct 5 14:42:27 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/getmove.c Tue Oct 5 14:42:15 2004
***************
*** 0 ****
--- 1,101 ----
+ /*
+ GNU GO - the game of Go (Wei-Chi)
+ Version 1.1 last revised 3-1-89
+ Copyright (C) Free Software Foundation, Inc.
+ written by Man L. Li
+ modified by Wayne Iba
+ documented by Bob Webber
+ */
+ /*
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation - version 1.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License in file COPYING for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ Please report any bug/fix, modification, suggestion to
+
+ mail address: Man L. Li
+ Dept. of Computer Science
+ University of Houston
+ 4800 Calhoun Road
+ Houston, TX 77004
+
+ e-mail address: manli at cs.uh.edu (Internet)
+ coscgbn at uhvax1.bitnet (BITNET)
+ 70070,404 (CompuServe)
+ */
+
+ #include <stdio.h>
+
+ #define EMPTY 0
+
+ extern unsigned char p[19][19];
+ extern int mymove, umove;
+ extern int play, pass;
+ extern int mk, uk; /* piece captured */
+ extern int opn[9];
+
+ extern int getij(char move[], int *i, int *j);
+ extern int suicide(int i, int j);
+
+ void getmove(char move[], int *i, int *j)
+ /* interpret response of human move to board position */
+ {
+ FILE *fp;
+ int m, n;
+
+ if (strcmp(move, "stop") == 0)
+ /* stop game */
+ play = 0;
+ else
+ {
+ if (strcmp(move, "save") == 0)
+ /* save data and stop game */
+ {
+ fp = fopen("gnugo.dat", "w");
+ /* save board configuration */
+ for (m = 0; m < 19; m++)
+ for (n = 0; n < 19; n++)
+ fprintf(fp, "%c", p[m][n]);
+ /* my color, pieces captured */
+ fprintf(fp, "%d %d %d ", mymove, mk, uk);
+ /* opening pattern flags */
+ for (m = 0; m < 9; m++)
+ fprintf(fp, "%d ", opn[m]);
+
+ fclose(fp);
+ play = -1;
+ }
+ else
+ {
+ if (strcmp(move, "pass") == 0)
+ /* human pass */
+ {
+ pass++;
+ *i = -1; /* signal pass */
+ }
+ else
+ {
+ pass = 0;
+ /* move[0] from A to T, move[1] move[2] from 1 to 19 */
+ /* convert move to coordinate */
+ if (!getij(move, i, j) || (p[*i][*j] != EMPTY) || suicide(*i, *j))
+ {
+ if (feof(stdin)) exit(1);
+ printf("illegal move !\n");
+ printf("your move? ");
+ scanf("%s", move);
+ getmove(move, i, j);
+ }
+ }
+ }
+ }
+ } /* end getmove */
Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/initmark.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/initmark.c:1.1
*** /dev/null Tue Oct 5 14:42:27 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/initmark.c Tue Oct 5 14:42:15 2004
***************
*** 0 ****
--- 1,47 ----
+ /*
+ GNU GO - the game of Go (Wei-Chi)
+ Version 1.1 last revised 3-1-89
+ Copyright (C) Free Software Foundation, Inc.
+ written by Man L. Li
+ modified by Wayne Iba
+ documented by Bob Webber
+ */
+ /*
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation - version 1.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License in file COPYING for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ Please report any bug/fix, modification, suggestion to
+
+ mail address: Man L. Li
+ Dept. of Computer Science
+ University of Houston
+ 4800 Calhoun Road
+ Houston, TX 77004
+
+ e-mail address: manli at cs.uh.edu (Internet)
+ coscgbn at uhvax1.bitnet (BITNET)
+ 70070,404 (CompuServe)
+ */
+
+ extern unsigned char ma[19][19];
+
+ void initmark(void)
+ /* initialize all marking with zero */
+ {
+ int i, j;
+
+ for (i = 0; i < 19; i++)
+ for (j = 0; j < 19; j++)
+ ma[i][j] = 0;
+ } /* end initmark */
+
Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/main.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/main.c:1.1
*** /dev/null Tue Oct 5 14:42:27 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/main.c Tue Oct 5 14:42:15 2004
***************
*** 0 ****
--- 1,183 ----
+ /*
+ GNU GO - the game of Go (Wei-Chi)
+ Version 1.1 last revised 3-1-89
+ Copyright (C) Free Software Foundation, Inc.
+ written by Man L. Li
+ modified by Wayne Iba
+ documented by Bob Webber
+ */
+ /*
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation - version 1.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License in file COPYING for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ Please report any bug/fix, modification, suggestion to
+
+ mail address: Man L. Li
+ Dept. of Computer Science
+ University of Houston
+ 4800 Calhoun Road
+ Houston, TX 77004
+
+ e-mail address: manli at cs.uh.edu (Internet)
+ coscgbn at uhvax1.bitnet (BITNET)
+ 70070,404 (CompuServe)
+ */
+
+ #include <stdio.h>
+ #include <unistd.h>
+
+ #define EMPTY 0
+
+ extern void showinst(void);
+ extern void seed(int *i);
+ extern void sethand(int i);
+ extern void showboard(void);
+ extern void genmove(int *i, int *j);
+ extern void getmove(char move[], int *i, int *j);
+ extern void examboard(int color);
+ extern void endgame(void);
+
+ unsigned char p[19][19], l[19][19], ma[19][19], ml[19][19];
+ int mymove, umove;
+ int rd, lib, play, pass;
+ int mik, mjk, uik, ujk, mk, uk; /* piece captured */
+ int opn[9]; /* opening pattern flag */
+
+ int main(void)
+ {
+ FILE *fp;
+ int i, j;
+ char move[10], ans[5];
+ int cont = 0;
+
+ /* show instruction */
+ showinst();
+
+ if ((fp = fopen("gnugo.dat", "r")) != NULL) /* continue old game */
+ {
+ cont = 1;
+
+ /* read board configuration */
+ for (i = 0; i < 19; i++)
+ for (j = 0; j < 19; j++)
+ fscanf(fp, "%c", &p[i][j]);
+
+ /* read my color, pieces captured */
+ fscanf(fp, "%d %d %d ", &mymove, &mk, &uk);
+ /* read opening pattern flags */
+ for (i = 0; i < 9; i++)
+ fscanf(fp, "%d ", &opn[i]);
+
+ fclose(fp);
+ umove = 3 - mymove;
+
+ /* delete file */
+ unlink("gnugo.dat");
+ }
+ else
+ {
+ /* init opening pattern numbers to search */
+ for (i = 0; i < 9; i++)
+ opn[i] = 1;
+ opn[4] = 0;
+
+ /* init board */
+ for (i = 0; i < 19; i++)
+ for (j = 0; j < 19; j++)
+ p[i][j] = EMPTY;
+ /* init global variables */
+ mk = 0; uk = 0;
+ }
+
+ /* init global variables */
+ play = 1;
+ pass = 0;
+ mik = -1; mjk = -1;
+ uik = -1; ujk = -1;
+ seed(&rd); /* start random number seed */
+
+ if (!cont) /* new game */
+ {
+ /* ask for handicap */
+ printf("Number of handicap for black (0 to 17)? ");
+ scanf("%d", &i);
+ getchar();
+ sethand(i);
+
+ /* display game board */
+ showboard();
+
+ /* choose color */
+ printf("\nChoose side(b or w)? ");
+ scanf("%c",ans);
+ if (ans[0] == 'b')
+ {
+ mymove = 1; /* computer white */
+ umove = 2; /* human black */
+ if (i)
+ {
+ genmove(&i, &j); /* computer move */
+ p[i][j] = mymove;
+ }
+ }
+ else
+ {
+ mymove = 2; /* computer black */
+ umove = 1; /* human white */
+ if (i == 0)
+ {
+ genmove(&i, &j); /* computer move */
+ p[i][j] = mymove;
+ }
+ }
+ }
+
+ showboard();
+
+ /* main loop */
+ while (play > 0)
+ {
+ printf("your move? ");
+ scanf("%s", move);
+ getmove(move, &i, &j); /* read human move */
+ if (play > 0)
+ {
+ if (i >= 0) /* not pass */
+ {
+ p[i][j] = umove;
+ examboard(mymove); /* remove my dead pieces */
+ }
+ if (pass != 2)
+ {
+ genmove(&i, &j); /* computer move */
+ if (i >= 0) /* not pass */
+ {
+ p[i][j] = mymove;
+ examboard(umove); /* remove your dead pieces */
+ }
+ }
+ showboard();
+ }
+ if (pass == 2) play = 0; /* both pass then stop game */
+ }
+
+ if (play == 0)
+ {
+ /* finish game and count pieces */
+ getchar();
+ printf("Do you want to count score (y or n)? ");
+ scanf("%c",ans);
+ if (ans[0] == 'y') endgame();
+ }
+ return 0;
+ } /* end main */
Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/matchpat.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/matchpat.c:1.1
*** /dev/null Tue Oct 5 14:42:27 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/matchpat.c Tue Oct 5 14:42:15 2004
***************
*** 0 ****
--- 1,204 ----
+ /*
+ GNU GO - the game of Go (Wei-Chi)
+ Version 1.1 last revised 3-1-89
+ Copyright (C) Free Software Foundation, Inc.
+ written by Man L. Li
+ modified by Wayne Iba
+ documented by Bob Webber
+ */
+ /*
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation - version 1.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License in file COPYING for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ Please report any bug/fix, modification, suggestion to
+
+ mail address: Man L. Li
+ Dept. of Computer Science
+ University of Houston
+ 4800 Calhoun Road
+ Houston, TX 77004
+
+ e-mail address: manli at cs.uh.edu (Internet)
+ coscgbn at uhvax1.bitnet (BITNET)
+ 70070,404 (CompuServe)
+ */
+
+ #include <stdio.h>
+
+ #define EMPTY 0
+ #define MAXPC 16
+ #define abs(x) ((x) < 0 ? -(x) : (x))
+ #define line(x) (abs(x - 9))
+
+ extern unsigned char p[19][19];
+ extern int mymove, umove;
+ extern int lib;
+
+ extern void countlib(int m, int n, int color);
+
+ int matchpat(int m, int n, int *i, int *j, int *val)
+ /* match pattern and get next move */
+ {
+ struct patval {int x, y, att;}; /* pattern x, y coor and attribute */
+ /* att = 0 - empty, 1 - your piece, 2 - my piece, 3 - my next move */
+ /* 4 - empty on edge, 5 - your piece on edge, 6 - my piece on edge */
+ struct pattern {
+ struct patval patn[MAXPC]; /* pattern */
+ /* number of pieces in pattern, no. of transformation, pattern value */
+ int patlen, trfno, patwt;
+ };
+
+ /* XXZ */
+ /* #include "patterns.c" */
+ #define EMPTY 0
+ #define PATNO 24
+
+ static struct pattern pat[PATNO];
+ /* XXZ */
+
+ /* transformation matrice */
+ static int trf [8][2][2] = {
+ {{1, 0}, {0, 1}}, /* linear transfomation matrix */
+ {{1, 0}, {0, -1}}, /* invert */
+ {{0, 1}, {-1, 0}}, /* rotate 90 */
+ {{0, -1}, {-1, 0}}, /* rotate 90 and invert */
+ {{-1, 0}, {0, 1}}, /* flip left */
+ {{-1, 0}, {0, -1}}, /* flip left and invert */
+ {{0, 1}, {1, 0}}, /* rotate 90 and flip left */
+ {{0, -1}, {1, 0}} /* rotate 90, flip left and invert */
+ };
+ int k, my, nx, l, r, cont;
+ int ti, tj, tval;
+
+ *i = -1; *j = -1; *val = -1;
+ for (r = 0; r < PATNO; r++)
+ /* try each pattern */
+ for (l = 0; l < pat[r].trfno; l++)
+ /* try each orientation transformation */
+ {
+ k = 0; cont = 1;
+ while ((k != pat[r].patlen) && cont)
+ /* match each point */
+ {
+ /* transform pattern real coordinate */
+ nx = n + trf[l][0][0] * pat[r].patn[k].x
+ + trf[l][0][1] * pat[r].patn[k].y;
+ my = m + trf[l][1][0] * pat[r].patn[k].x
+ + trf[l][1][1] * pat[r].patn[k].y;
+
+ /* outside the board */
+ if ((my < 0) || ( my > 18) || (nx < 0) || (nx > 18))
+ {
+ cont = 0;
+ break;
+ }
+ switch (pat[r].patn[k].att) {
+ case 0 : if (p[my][nx] == EMPTY) /* open */
+ break;
+ else
+ {
+ cont = 0;
+ break;
+ }
+ case 1 : if (p[my][nx] == umove) /* your piece */
+ break;
+ else
+ {
+ cont = 0;
+ break;
+ }
+ case 2 : if (p[my][nx] == mymove) /* my piece */
+ break;
+ else
+ {
+ cont = 0;
+ break;
+ }
+ case 3 : if (p[my][nx] == EMPTY) /* open for new move */
+ {
+ lib = 0;
+ countlib(my, nx, mymove); /* check liberty */
+ if (lib > 1) /* move o.k. */
+ {
+ ti = my;
+ tj = nx;
+ break;
+ }
+ else
+ {
+ cont = 0;
+ break;
+ }
+ }
+ else
+ {
+ cont = 0;
+ break;
+ }
+ case 4 : if ((p[my][nx] == EMPTY) /* open on edge */
+ && ((my == 0) || (my == 18) || (nx == 0) || (nx == 18)))
+ break;
+ else
+ {
+ cont = 0;
+ break;
+ }
+ case 5 : if ((p[my][nx] == umove) /* your piece on edge */
+ && ((my == 0) || (my == 18) || (nx == 0) || (nx == 18)))
+ break;
+ else
+ {
+ cont = 0;
+ break;
+ }
+ case 6 : if ((p[my][nx] == mymove) /* my piece on edge */
+ && ((my == 0) || (my == 18) || (nx == 0) || (nx == 18)))
+ break;
+ else
+ {
+ cont = 0;
+ break;
+ }
+ }
+ ++k;
+ }
+ if (cont) /* match pattern */
+ {
+ tval = pat[r].patwt;
+ if ((r >= 8) && (r <= 13)) /* patterns for expand region */
+ {
+ if (line(ti) > 7) /* penalty on line 1, 2 */
+ tval--;
+ else
+ if ((line(ti) == 6) || (line(ti) == 7))
+ tval++; /* reward on line 3, 4 */
+
+ if (line(tj) > 7) /* penalty on line 1, 2 */
+ tval--;
+ else
+ if ((line(tj) == 6) || (line(tj) == 7))
+ tval++; /* reward on line 3, 4 */
+ }
+ if (tval > *val)
+ {
+ *val = tval;
+ *i = ti;
+ *j = tj;
+ }
+ }
+ }
+ if (*val > 0) /* pattern matched */
+ return 1;
+ else /* match failed */
+ return 0;
+ } /* end matchpat */
Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/opening.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/opening.c:1.1
*** /dev/null Tue Oct 5 14:42:27 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/opening.c Tue Oct 5 14:42:15 2004
***************
*** 0 ****
--- 1,92 ----
+ /*
+ GNU GO - the game of Go (Wei-Chi)
+ Version 1.1 last revised 3-1-89
+ Copyright (C) Free Software Foundation, Inc.
+ written by Man L. Li
+ modified by Wayne Iba
+ documented by Bob Webber
+ */
+ /*
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation - version 1.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License in file COPYING for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ Please report any bug/fix, modification, suggestion to
+
+ mail address: Man L. Li
+ Dept. of Computer Science
+ University of Houston
+ 4800 Calhoun Road
+ Houston, TX 77004
+
+ e-mail address: manli at cs.uh.edu (Internet)
+ coscgbn at uhvax1.bitnet (BITNET)
+ 70070,404 (CompuServe)
+ */
+
+ #include <stdio.h>
+
+ extern int rd;
+ extern void random_nasko(int *i);
+
+ int opening(int *i, int *j, int *cnd, int type)
+ /* get move for opening from game tree */
+ {
+ struct tnode {
+ int i, j, ndct, next[8];
+ };
+
+ static struct tnode tree[] = {
+ {-1, -1, 8, { 1, 2, 3, 4, 5, 6, 7, 20}}, /* 0 */
+ {2, 3, 2, { 8, 9}},
+ {2, 4, 1, {10}},
+ {3, 2, 2, {11, 12}},
+ {3, 3, 6, {14, 15, 16, 17, 18, 19}},
+ {3, 4, 1, {10}}, /* 5 */
+ {4, 2, 1, {13}},
+ {4, 3, 1, {13}},
+ {4, 2, 0},
+ {4, 3, 0},
+ {3, 2, 0}, /* 10 */
+ {2, 4, 0},
+ {3, 4, 0},
+ {2, 3, 0},
+ {2, 5, 1, {10}},
+ {2, 6, 1, {10}}, /* 15 */
+ {3, 5, 1, {10}},
+ {5, 2, 1, {13}},
+ {5, 3, 1, {13}},
+ {6, 2, 1, {13}},
+ {2, 2, 0} /* 20 */
+ };
+ int m;
+
+ /* get i, j */
+ if ((type == 1) || (type == 3))
+ *i = 18 - tree[*cnd].i; /* inverted */
+ else
+ *i = tree[*cnd].i;
+ if ((type == 2) || (type == 3))
+ *j = 18 - tree[*cnd].j; /* reflected */
+ else
+ *j = tree[*cnd].j;
+ if (tree[*cnd].ndct) /* more move */
+ {
+ random_nasko(&rd);
+ m = rd % tree[*cnd].ndct; /* select move */
+ *cnd = tree[*cnd].next[m]; /* new current node */
+ return 1;
+ }
+ else
+ return 0;
+ } /* end opening */
+
Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/openregn.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/openregn.c:1.1
*** /dev/null Tue Oct 5 14:42:27 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/openregn.c Tue Oct 5 14:42:15 2004
***************
*** 0 ****
--- 1,77 ----
+ /*
+ GNU GO - the game of Go (Wei-Chi)
+ Version 1.1 last revised 3-1-89
+ Copyright (C) Free Software Foundation, Inc.
+ written by Man L. Li
+ modified by Wayne Iba
+ documented by Bob Webber
+ */
+ /*
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation - version 1.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License in file COPYING for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ Please report any bug/fix, modification, suggestion to
+
+ mail address: Man L. Li
+ Dept. of Computer Science
+ University of Houston
+ 4800 Calhoun Road
+ Houston, TX 77004
+
+ e-mail address: manli at cs.uh.edu (Internet)
+ coscgbn at uhvax1.bitnet (BITNET)
+ 70070,404 (CompuServe)
+ */
+
+ #include <stdio.h>
+
+ #define EMPTY 0
+
+ extern unsigned char p[19][19];
+
+ int openregion(int i1, int j1, int i2, int j2)
+ /* check if region from i1, j1 to i2, j2 is open */
+ {
+ int minx, maxx, miny, maxy, x, y;
+
+ /* exchange upper and lower limits */
+
+ if (i1 < i2)
+ {
+ miny = i1;
+ maxy = i2;
+ }
+ else
+ {
+ miny = i2;
+ maxy = i1;
+ }
+
+ if (j1 < j2)
+ {
+ minx = j1;
+ maxx = j2;
+ }
+ else
+ {
+ minx = j2;
+ maxx = j1;
+ }
+
+ /* check for empty region */
+ for (y = miny; y <= maxy; y++)
+ for (x = minx; x <= maxx; x++)
+ if (p[y][x] != EMPTY) return 0;
+ return 1;
+ } /* end openregion */
+
Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/random.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/random.c:1.1
*** /dev/null Tue Oct 5 14:42:27 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/random.c Tue Oct 5 14:42:16 2004
***************
*** 0 ****
--- 1,49 ----
+ /*
+ GNU GO - the game of Go (Wei-Chi)
+ Version 1.1 last revised 3-1-89
+ Copyright (C) Free Software Foundation, Inc.
+ written by Man L. Li
+ modified by Wayne Iba
+ documented by Bob Webber
+ */
+ /*
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation - version 1.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License in file COPYING for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ Please report any bug/fix, modification, suggestion to
+
+ mail address: Man L. Li
+ Dept. of Computer Science
+ University of Houston
+ 4800 Calhoun Road
+ Houston, TX 77004
+
+ e-mail address: manli at cs.uh.edu (Internet)
+ coscgbn at uhvax1.bitnet (BITNET)
+ 70070,404 (CompuServe)
+ */
+
+ extern void seed(int *i);
+
+ void random_nasko(int *i)
+ /* random number generator */
+ {
+ if (*i == 0)
+ seed(i);
+ else
+ {
+ *i = *i * 137 % 3833;
+ if (*i < 0) *i = -*i;
+ }
+ } /* end random */
+
Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/seed.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/seed.c:1.1
*** /dev/null Tue Oct 5 14:42:27 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/seed.c Tue Oct 5 14:42:16 2004
***************
*** 0 ****
--- 1,79 ----
+ /*
+ GNU GO - the game of Go (Wei-Chi)
+ Version 1.1 last revised 3-1-89
+ Copyright (C) Free Software Foundation, Inc.
+ written by Man L. Li
+ modified by Wayne Iba
+ documented by Bob Webber
+ */
+ /*
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation - version 1.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License in file COPYING for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ Please report any bug/fix, modification, suggestion to
+
+ mail address: Man L. Li
+ Dept. of Computer Science
+ University of Houston
+ 4800 Calhoun Road
+ Houston, TX 77004
+
+ e-mail address: manli at cs.uh.edu (Internet)
+ coscgbn at uhvax1.bitnet (BITNET)
+ 70070,404 (CompuServe)
+ */
+
+ /*
+ #define IBM 8086
+ */
+
+ #define SUN 68000
+
+ #include <stdio.h>
+
+ #ifdef SUN
+
+ #include <sys/time.h>
+
+ #endif
+
+ #ifdef IBM
+
+ void seed(int *i)
+ /* start seed of random number generator for PC */
+ /* Computer Innovation C86 compiler version */
+ {
+ struct regval {int ax, bx, cx, dx, si, di, ds, es;};
+ struct regval sreg, rreg;
+
+ sreg.ax = 0x2c00;
+ sysint21(&sreg, &rreg);
+ *i = rreg.dx;
+ } /* end seed */
+ #endif
+
+
+ #ifdef SUN
+
+ void seed(int *i)
+ /* start seed of random number generator for Sun */
+ {
+ struct timeval tp;
+ struct timezone tzp;
+
+ gettimeofday(&tp, &tzp);
+ *i = tp.tv_usec;
+ } /* end seed */
+
+ #endif
+
Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/sethand.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/sethand.c:1.1
*** /dev/null Tue Oct 5 14:42:27 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/sethand.c Tue Oct 5 14:42:16 2004
***************
*** 0 ****
--- 1,103 ----
+ /*
+ GNU GO - the game of Go (Wei-Chi)
+ Version 1.1 last revised 3-1-89
+ Copyright (C) Free Software Foundation, Inc.
+ written by Man L. Li
+ modified by Wayne Iba
+ documented by Bob Webber
+ */
+ /*
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation - version 1.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License in file COPYING for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ Please report any bug/fix, modification, suggestion to
+
+ mail address: Man L. Li
+ Dept. of Computer Science
+ University of Houston
+ 4800 Calhoun Road
+ Houston, TX 77004
+
+ e-mail address: manli at cs.uh.edu (Internet)
+ coscgbn at uhvax1.bitnet (BITNET)
+ 70070,404 (CompuServe)
+ */
+
+ #include <stdio.h>
+
+ #define BLACK 2
+
+ extern unsigned char p[19][19];
+
+ void sethand(int i)
+ /* set up handicap pieces */
+ {
+ if (i > 0)
+ {
+ p[3][3] = BLACK;
+ if (i > 1)
+ {
+ p[15][15] = BLACK;
+ if (i > 2)
+ {
+ p[3][15] = BLACK;
+ if (i > 3)
+ {
+ p[15][3] = BLACK;
+ if (i == 5)
+ p[9][9] = BLACK;
+ else
+ if (i > 5)
+ {
+ p[9][15] = BLACK;
+ p[9][3] = BLACK;
+ if (i == 7)
+ p[9][9] = BLACK;
+ else
+ if (i > 7)
+ {
+ p[15][9] = BLACK;
+ p[3][9] = BLACK;
+ if (i > 8)
+ p[9][9] = BLACK;
+ if (i > 9)
+ {p[2][2] = 2;
+ if (i > 10)
+ {p[16][16] = 2;
+ if (i > 11)
+ {p[2][16] = 2;
+ if (i > 12)
+ {p[16][2] = 2;
+ if (i > 13)
+ {p[6][6] = 2;
+ if (i > 14)
+ {p[12][12] = 2;
+ if (i > 15)
+ {p[6][12] = 2;
+ if (i > 16)
+ p[12][6] = 2;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ } /* end sethand */
+
Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/showbord.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/showbord.c:1.1
*** /dev/null Tue Oct 5 14:42:27 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/showbord.c Tue Oct 5 14:42:16 2004
***************
*** 0 ****
--- 1,290 ----
+ /*
+ GNU GO - the game of Go (Wei-Chi)
+ Version 1.1 last revised 3-1-89
+ Copyright (C) Free Software Foundation, Inc.
+ written by Man L. Li
+ modified by Wayne Iba
+ documented by Bob Webber
+ */
+ /*
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation - version 1.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License in file COPYING for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ Please report any bug/fix, modification, suggestion to
+
+ mail address: Man L. Li
+ Dept. of Computer Science
+ University of Houston
+ 4800 Calhoun Road
+ Houston, TX 77004
+
+ e-mail address: manli at cs.uh.edu (Internet)
+ coscgbn at uhvax1.bitnet (BITNET)
+ 70070,404 (CompuServe)
+ */
+
+ #include <stdio.h>
+
+ #define EMPTY 0
+ #define WHITE 1
+
+ extern unsigned char p[19][19];
+ extern int mymove, umove;
+ extern int mk, uk; /* piece captured */
+
+ void showboard(void)
+ /* show go board */
+ {
+ int i, j, ii;
+
+ /* p = 0 for empty ,p = 1 for white piece, p = 2 for black piece */
+ printf(" A B C D E F G H J K L M N O P Q R S T\n");
+ /* row 19 to 17 */
+ for (i = 0; i < 3; i++)
+ {
+ ii = 19 - i;
+ printf("%2d",ii);
+
+ for (j = 0; j < 19; j++)
+ if (p[i][j] == EMPTY)
+ printf(" -");
+ else if (p[i][j] == WHITE)
+ printf(" O");
+ else printf(" X");
+
+ printf("%2d",ii);
+ printf("\n");
+ }
+ /* row 16 */
+ printf("16");
+
+ for (j = 0; j < 3; j++)
+ if (p[3][j] == EMPTY)
+ printf(" -");
+ else if (p[3][j] == WHITE)
+ printf(" O");
+ else printf(" X");
+
+ if (p[3][3] == 0)
+ printf(" +");
+ else if (p[3][3] == WHITE)
+ printf(" O");
+ else printf(" X");
+
+ for (j = 4; j < 9; j++)
+ if (p[3][j] == EMPTY)
+ printf(" -");
+ else if (p[3][j] == WHITE)
+ printf(" O");
+ else printf(" X");
+
+ if (p[3][9] == EMPTY)
+ printf(" +");
+ else if (p[3][9] == WHITE)
+ printf(" O");
+ else printf(" X");
+
+ for (j = 10; j < 15; j++)
+ if (p[3][j] == EMPTY)
+ printf(" -");
+ else if (p[3][j] == WHITE)
+ printf(" O");
+ else printf(" X");
+
+ if (p[3][15] == EMPTY)
+ printf(" +");
+ else if (p[3][15] == WHITE)
+ printf(" O");
+ else printf(" X");
+
+ for (j = 16; j < 19; j++)
+ if (p[3][j] == EMPTY)
+ printf(" -");
+ else if (p[3][j] == WHITE)
+ printf(" O");
+ else printf(" X");
+
+ printf("16");
+ if (umove == 1)
+ printf(" Your color: White O\n");
+ else
+ if (umove == 2)
+ printf(" Your color: Black X\n");
+ else
+ printf("\n");
+ /* row 15 to 11 */
+ for (i = 4; i < 9; i++)
+ {
+ ii = 19 - i;
+ printf("%2d",ii);
+
+ for (j = 0; j < 19; j++)
+ if (p[i][j] == EMPTY)
+ printf(" -");
+ else if (p[i][j] == WHITE)
+ printf(" O");
+ else printf(" X");
+
+ printf("%2d",ii);
+ if (i == 4)
+ {
+ if (mymove == 1)
+ printf(" My color: White O\n");
+ else
+ if (mymove == 2)
+ printf(" My color: Black X\n");
+ else
+ printf("\n");
+ }
+ else
+ if (i != 8)
+ printf("\n");
+ else
+ printf(" You have captured %d pieces\n", mk);
+ }
+ /* row 10 */
+ printf("10");
+
+ for (j = 0; j < 3; j++)
+ if (p[9][j] == EMPTY)
+ printf(" -");
+ else if (p[9][j] == WHITE)
+ printf(" O");
+ else printf(" X");
+
+ if (p[9][3] == EMPTY)
+ printf(" +");
+ else if (p[9][3] == WHITE)
+ printf(" O");
+ else printf(" X");
+
+ for (j = 4; j < 9; j++)
+ if (p[9][j] == EMPTY)
+ printf(" -");
+ else if (p[9][j] == WHITE)
+ printf(" O");
+ else printf(" X");
+
+ if (p[9][9] == EMPTY)
+ printf(" +");
+ else if (p[9][9] == WHITE)
+ printf(" O");
+ else printf(" X");
+
+ for (j = 10; j < 15; j++)
+ if (p[9][j] == EMPTY)
+ printf(" -");
+ else if (p[9][j] == WHITE)
+ printf(" O");
+ else printf(" X");
+
+ if (p[9][15] == EMPTY)
+ printf(" +");
+ else if (p[9][15] == WHITE)
+ printf(" O");
+ else printf(" X");
+
+ for (j = 16; j < 19; j++)
+ if (p[9][j] == EMPTY)
+ printf(" -");
+ else if (p[9][j] == WHITE)
+ printf(" O");
+ else printf(" X");
+
+ printf("10");
+ printf(" I have captured %d pieces\n", uk);
+ /* row 9 to 5 */
+ for (i = 10; i < 15; i++)
+ {
+ ii = 19 - i;
+ printf("%2d",ii);
+
+ for (j = 0; j < 19; j++)
+ if (p[i][j] == EMPTY)
+ printf(" -");
+ else if (p[i][j] == WHITE)
+ printf(" O");
+ else printf(" X");
+
+ printf("%2d",ii);
+ printf("\n");
+ }
+ /* row 4 */
+ printf(" 4");
+
+ for (j = 0; j < 3; j++)
+ if (p[15][j] == EMPTY)
+ printf(" -");
+ else if (p[15][j] == WHITE)
+ printf(" O");
+ else printf(" X");
+
+ if (p[15][3] == EMPTY)
+ printf(" +");
+ else if (p[15][3] == WHITE)
+ printf(" O");
+ else printf(" X");
+
+ for (j = 4; j < 9; j++)
+ if (p[15][j] == EMPTY)
+ printf(" -");
+ else if (p[15][j] == WHITE)
+ printf(" O");
+ else printf(" X");
+
+ if (p[15][9] == EMPTY)
+ printf(" +");
+ else if (p[15][9] == WHITE)
+ printf(" O");
+ else printf(" X");
+
+ for (j = 10; j < 15; j++)
+ if (p[15][j] == EMPTY)
+ printf(" -");
+ else if (p[15][j] == WHITE)
+ printf(" O");
+ else printf(" X");
+
+ if (p[15][15] == EMPTY)
+ printf(" +");
+ else if (p[15][15] == WHITE)
+ printf(" O");
+ else printf(" X");
+
+ for (j = 16; j < 19; j++)
+ if (p[15][j] == EMPTY)
+ printf(" -");
+ else if (p[15][j] == WHITE)
+ printf(" O");
+ else printf(" X");
+
+ printf(" 4");
+ printf("\n");
+ /* row 3 to 1 */
+ for (i = 16; i < 19; i++)
+ {
+ ii = 19 - i;
+ printf("%2d",ii);
+
+ for (j = 0; j < 19; j++)
+ if (p[i][j] == EMPTY)
+ printf(" -");
+ else if (p[i][j] == WHITE)
+ printf(" O");
+ else printf(" X");
+
+ printf("%2d",ii);
+ printf("\n");
+ }
+ printf(" A B C D E F G H J K L M N O P Q R S T\n\n");
+ } /* end showboard */
Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/showinst.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/showinst.c:1.1
*** /dev/null Tue Oct 5 14:42:27 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/showinst.c Tue Oct 5 14:42:16 2004
***************
*** 0 ****
--- 1,96 ----
+ /*
+ GNU GO - the game of Go (Wei-Chi)
+ Version 1.1 last revised 3-1-89
+ Copyright (C) Free Software Foundation, Inc.
+ written by Man L. Li
+ modified by Wayne Iba
+ documented by Bob Webber
+ */
+ /*
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation - version 1.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License in file COPYING for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ Please report any bug/fix, modification, suggestion to
+
+ mail address: Man L. Li
+ Dept. of Computer Science
+ University of Houston
+ 4800 Calhoun Road
+ Houston, TX 77004
+
+ e-mail address: manli at cs.uh.edu (Internet)
+ coscgbn at uhvax1.bitnet (BITNET)
+ 70070,404 (CompuServe)
+ */
+
+ #define SUN 68000
+
+ #include <stdio.h>
+
+ void showinst(void)
+ /* show program instructions */
+ {
+ printf("XOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOX");
+ printf("OXOXOXOXOXOX\n");
+ printf("O ");
+ printf(" O\n");
+ printf("X GNU GO (Previously Hugo) ");
+ printf(" X\n");
+ printf("O the game of Go (Wei-Chi) ");
+ printf(" O\n");
+ printf("X ");
+ printf(" X\n");
+ printf("O version 1.1 3-1-89 ");
+ printf(" O\n");
+ printf("X Copyright (C) 1989 Free Software Foundation, Inc. ");
+ printf(" X\n");
+ printf("O Author: Man L. Li ");
+ printf(" O\n");
+ printf("X GNU GO comes with ABSOLUTELY NO WARRANTY; see COPYING for");
+ printf(" X\n");
+ printf("O detail. This is free software, and you are welcome to ");
+ printf(" O\n");
+ printf("X redistribute it; see COPYING for copying conditions. ");
+ printf(" X\n");
+ printf("O ");
+ printf(" O\n");
+
+ #ifdef SUN
+
+ printf("X Please report all bugs, modifications, suggestions ");
+ printf(" X\n");
+ printf("O to manli at cs.uh.edu (Internet) ");
+ printf(" O\n");
+
+ #endif
+
+ printf("X ");
+ printf(" X\n");
+ printf("OXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXO");
+ printf("XOXOXOXOXOXO\n");
+ printf("\n\n\n\n\n\n\n\nPress return to continue");
+ getchar();
+ printf("\n\nTo play this game first select number of handicap pieces (0 to");
+ printf(" 17) for the\nblack side. Next choose your color (black or white).");
+ printf(" To place your piece,\nenter your move as coordinate on the board");
+ printf(" in column and row. The column\nis from 'A' to 'T'(excluding 'I').");
+ printf(" The row is from 1 to 19.\n\nTo pass your move enter 'pass' for");
+ printf(" your turn. After both you and the computer\npassed the game will");
+ printf(" end. To save the board and exit enter 'save'. The game\nwill");
+ printf(" continue the next time you start the program. To stop the game in");
+ printf(" the\nmiddle of play enter 'stop' for your move. You will be");
+ printf(" asked whether you want\nto count the result of the game. If you");
+ printf(" answer 'y' then you need to remove the\nremaining dead pieces and");
+ printf(" fill up neutral turf on the board as instructed.\nFinally, the");
+ printf(" computer will count all pieces for both side and show the result.\n\n");
+ } /* end showinst */
Index: llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/suicide.c
diff -c /dev/null llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/suicide.c:1.1
*** /dev/null Tue Oct 5 14:42:27 2004
--- llvm-test/MultiSource/Benchmarks/Prolangs-C/gnugo/suicide.c Tue Oct 5 14:42:16 2004
***************
*** 0 ****
--- 1,84 ----
+ /*
+ GNU GO - the game of Go (Wei-Chi)
+ Version 1.1 last revised 3-1-89
+ Copyright (C) Free Software Foundation, Inc.
+ written by Man L. Li
+ modified by Wayne Iba
+ documented by Bob Webber
+ */
+ /*
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation - version 1.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License in file COPYING for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ Please report any bug/fix, modification, suggestion to
+
+ mail address: Man L. Li
+ Dept. of Computer Science
+ University of Houston
+ 4800 Calhoun Road
+ Houston, TX 77004
+
+ e-mail address: manli at cs.uh.edu (Internet)
+ coscgbn at uhvax1.bitnet (BITNET)
+ 70070,404 (CompuServe)
+ */
+
+ #include <stdio.h>
+
+ #define EMPTY 0
+
+ extern unsigned char p[19][19], l[19][19];
+ extern int mymove, umove;
+ extern int lib;
+ extern int uik, ujk; /* piece captured */
+
+ extern void countlib(int m, int n, int color);
+ extern void eval(int color);
+
+ int suicide(int i, int j)
+ /* check for suicide move of opponent at p[i][j] */
+ {
+ int m, n, k;
+
+ /* check liberty of new move */
+ lib = 0;
+ countlib(i, j, umove);
+ if (lib == 0)
+ /* new move is suicide then check if kill my pieces and Ko possibility */
+ {
+ /* assume alive */
+ p[i][j] = umove;
+
+ /* check my pieces */
+ eval(mymove);
+ k = 0;
+
+ for (m = 0; m < 19; m++)
+ for (n = 0; n < 19; n++)
+ /* count pieces will be killed */
+ if ((p[m][n] == mymove) && !l[m][n]) ++k;
+
+ if ((k == 0) || (k == 1 && ((i == uik) && (j == ujk))))
+ /* either no effect on my pieces or an illegal Ko take back */
+ {
+ p[i][j] = EMPTY; /* restore to open */
+ return 1;
+ }
+ else
+ /* good move */
+ return 0;
+ }
+ else
+ /* valid move */
+ return 0;
+ } /* end suicide */
More information about the llvm-commits
mailing list