summaryrefslogtreecommitdiff
path: root/games/knightcap/patches
diff options
context:
space:
mode:
authorjlam <jlam>2000-10-15 08:38:22 +0000
committerjlam <jlam>2000-10-15 08:38:22 +0000
commit18ba1d4d023009520e128f678d47c3e1787773f7 (patch)
treedf2bbe0f85fca4df31eb362eb912ec4837a70bb3 /games/knightcap/patches
parent5d780b64dda0af70662e9a55aafae5399adeb3aa (diff)
downloadpkgsrc-18ba1d4d023009520e128f678d47c3e1787773f7.tar.gz
KnightCap: chess engine with 3D OpenGL-rendered chessboard
Diffstat (limited to 'games/knightcap/patches')
-rw-r--r--games/knightcap/patches/patch-aa62
-rw-r--r--games/knightcap/patches/patch-ab13
-rw-r--r--games/knightcap/patches/patch-ac111
-rw-r--r--games/knightcap/patches/patch-ad58
-rw-r--r--games/knightcap/patches/patch-ae54
-rw-r--r--games/knightcap/patches/patch-af55
-rw-r--r--games/knightcap/patches/patch-ag22
7 files changed, 375 insertions, 0 deletions
diff --git a/games/knightcap/patches/patch-aa b/games/knightcap/patches/patch-aa
new file mode 100644
index 00000000000..a00ec0e593b
--- /dev/null
+++ b/games/knightcap/patches/patch-aa
@@ -0,0 +1,62 @@
+$NetBSD: patch-aa,v 1.1.1.1 2000/10/15 08:38:22 jlam Exp $
+
+--- Makefile.orig Sun May 17 19:09:21 1998
++++ Makefile
+@@ -5,8 +5,8 @@
+ CC = gcc
+
+ # What compiler switches do you want? These ones work well with gcc
+-#OPT = -O2 -fshort-enums -Wall
+-OPT = -g -fshort-enums -Wall
++OPT = -O2 -fshort-enums -Wall
++#OPT = -g -fshort-enums -Wall
+
+ # If you don't have gcc then perhaps try this instead. You only need
+ # the null definition for inline if your C compiler doesn't know about
+@@ -21,31 +21,36 @@
+ # display (or you don't have OpenGL and Glut libraries)
+ # If you do have these libs then make sure the first three
+ # lines point at the right places
+-MESA = /usr/local/Mesa-2.1
+-GLUT = /usr/local/Mesa-2.1/glut-3.2
+-X11 = /usr/X11R6
+-GLUT_LIBS = -L$(GLUT)/lib/glut -lglut
+-MESA_LIBS = -L$(MESA)/lib -lMesaGLU -lMesaGL -lm
+-XLIBS = -L$(X11)/lib -lXmu -lXt -lXext -lX11 -lXi
+-DISPLAYFLAGS = -I$(MESA)/include -I$(GLUT) -DRENDERED_DISPLAY=1
++MESA ?= ${X11BASE}
++GLUT = $(MESA)
++X11 = ${X11BASE}
++GLUT_LIBS = -L$(GLUT)/lib -Wl,-R$(GLUT)/lib -lglut
++MESA_LIBS = -L$(MESA)/lib -Wl,-R$(MESA)/lib -lGLU -lGL -lm
++XLIBS = -L$(X11)/lib -lXmu -lXt -lXext -lX11 -lXi -lICE -lSM
++DISPLAYFLAGS = -I$(MESA)/include -I$(GLUT)/include -DRENDERED_DISPLAY=1
+
+ # comment out the following line if you don't want KnightCap's
+ # evaluation function learning turned on.
+-LEARNFLAGS = -DLEARN_EVAL=1
++#
++# On NetBSD, this causes mysterious segfaults that GDB can't track down,
++# so disable the evaluation function learning.
++#
++# LEARNFLAGS = -DLEARN_EVAL=1
+
+ # you shouldn't need to edit anything below this line. Unless
+ # something goes wrong.
+
+ INCLUDE = $(DISPLAYFLAGS)
+-CFLAGS = $(OPT) $(INCLUDE) $(LEARNFLAGS)
++CFLAGS += $(OPT) $(DEFINES) $(INCLUDE) $(LEARNFLAGS)
+
+-LIBS = $(GLUT_LIBS) $(MESA_LIBS) $(XLIBS)
++LIBS = $(LDFLAGS) $(GLUT_LIBS) $(MESA_LIBS) $(XLIBS)
+
+ TARGET = KnightCap
+
+ OBJS = knightcap.o trackball.o move.o util.o generate.o eval.o movement.o \
+ ordering.o hash.o board.o log.o prog.o timer.o ics.o display.o \
+ testsuite.o brain.o td.o tactics.o
++OBJS+= epd.o epdglue.o
+
+ $(TARGET): $(OBJS)
+ -mv $@ $@.old
diff --git a/games/knightcap/patches/patch-ab b/games/knightcap/patches/patch-ab
new file mode 100644
index 00000000000..142b2fcd42e
--- /dev/null
+++ b/games/knightcap/patches/patch-ab
@@ -0,0 +1,13 @@
+$NetBSD: patch-ab,v 1.1.1.1 2000/10/15 08:38:22 jlam Exp $
+
+--- display.c.orig Sun May 17 19:09:21 1998
++++ display.c
+@@ -12,8 +12,6 @@
+ #include <GL/glut.h>
+ #include "trackball.h"
+
+-static int window_size = 500;
+-
+ #define SLEEP_TIME 100000 /* microseconds */
+
+
diff --git a/games/knightcap/patches/patch-ac b/games/knightcap/patches/patch-ac
new file mode 100644
index 00000000000..52e55d513b0
--- /dev/null
+++ b/games/knightcap/patches/patch-ac
@@ -0,0 +1,111 @@
+$NetBSD: patch-ac,v 1.1.1.1 2000/10/15 08:38:22 jlam Exp $
+
+--- knightcap.c.orig Sun May 17 19:09:21 1998
++++ knightcap.c
+@@ -6,7 +6,7 @@
+ #include "trackball.h"
+ #include "knightcap.h"
+
+-static int window_size = 500;
++int window_size = 500;
+
+ #define SLEEP_TIME 100000 /* microseconds */
+ #define REFRESH_TIME 20 /* in seconds */
+@@ -21,6 +21,7 @@
+ int seek_answering=0;
+ int demo_mode = 0;
+
++static int starts = 0; /* default to no computer play */
+ static int opponent;
+ static int always_think;
+ static int no_display;
+@@ -56,7 +57,7 @@
+ char *ics_master = NULL;
+ char *coeffs_file = NULL;
+ char *bad_eval_file = "bad_eval.dat";
+-char *tb_path = "../EGTB";
++char *tb_path = TB_DIR;
+
+ char play_target[100];
+
+@@ -82,7 +83,7 @@
+ void reset_board(void)
+ {
+ setup_board(&state->position);
+- state->computer = 0;
++ state->computer = starts;
+ state->moved = 0;
+ state->always_think = always_think;
+ state->use_mulling = use_mulling;
+@@ -945,7 +946,7 @@
+ reset_board();
+ init_movements();
+
+- signal(SIGCLD, SIG_IGN);
++ signal(SIGCHLD, SIG_IGN);
+
+ pid1 = getpid();
+
+@@ -1000,6 +1001,11 @@
+ "-T <name> target ICS opponent\n" \
+ "-G <file> endgame tablebsae directory\n" \
+ "-y don't mull\n" \
++"-1 Computer plays white\n" \
++"-2 Computer plays black\n" \
++"-0 Computer plays neither white nor black\n" \
++"\n" \
++"call xboard with: xboard -fcp 'KnightCap -n -X -A -2'\n" \
+ "\n");
+ }
+
+@@ -1010,7 +1016,11 @@
+ #ifdef SUNOS4
+ extern char *optarg;
+ #endif
+- char *opt = "c:s:w:nI:t:hXAD:l:aH:M:ezdm:f:g:ByEpT:";
++ /*
++ * Add support for specifying what colour the computer plays
++ * at start.
++ */
++ char *opt = "012c:s:w:nI:t:hXAD:l:aH:M:ezdm:f:g:ByEpT:";
+ int c;
+ int seed = getpid();
+
+@@ -1030,6 +1040,7 @@
+ if (getcid()) break;
+ #endif
+ window_size = atoi(optarg);
++ lprintf(0, "Window size: %d\n", window_size);
+ break;
+
+ case 'c':
+@@ -1151,6 +1162,15 @@
+ case 'g':
+ tb_path = optarg;
+ break;
++ case '0':
++ starts = 0;
++ break;
++ case '1':
++ starts = 1;
++ break;
++ case '2':
++ starts = -1;
++ break;
+ }
+ }
+
+@@ -1178,6 +1198,13 @@
+ parse_options(argc, argv);
+
+ create_threads();
++
++ /*
++ * Initialize colour the computer plays to what's specified,
++ * or default to playing neither side.
++ */
++ state->computer = starts;
++ state->colour = starts;
+
+ state->ics_robot = ics_mode;
+ state->autoplay = ics_mode;
diff --git a/games/knightcap/patches/patch-ad b/games/knightcap/patches/patch-ad
new file mode 100644
index 00000000000..309aa2d0d52
--- /dev/null
+++ b/games/knightcap/patches/patch-ad
@@ -0,0 +1,58 @@
+$NetBSD: patch-ad,v 1.1.1.1 2000/10/15 08:38:23 jlam Exp $
+
+--- knightcap.h.orig Sun May 17 19:09:21 1998
++++ knightcap.h
+@@ -92,7 +92,22 @@
+ #define USE_PBRAIN 1
+ #endif
+
+-#define BRAIN_FILE "brain.dat"
++/*
++ * Support finding brain.dat in another directory (BRAIN_DIR) determined
++ * at compile-time.
++ */
++#ifndef BRAIN_DIR
++#define BRAIN_DIR "./"
++#endif
++#define BRAIN_FILE BRAIN_DIR "brain.dat"
++
++/*
++ * Support finding endgame tables in another direcotry (TB_DIR) determined
++ * at compile-time.
++ */
++#ifndef TB_DIR
++#define TB_DIR "../EGTB"
++#endif
+
+ #ifndef RESIGN_VALUE
+ #define RESIGN_VALUE (ROOK_VALUE)
+@@ -296,10 +311,19 @@
+
+ #define INITIAL_MATERIAL (KING_VALUE + QUEEN_VALUE + 2*ROOK_VALUE + 2*BISHOP_VALUE + 2*KNIGHT_VALUE + 8*PAWN_VALUE)
+
++#if defined(__NetBSD__)
++#include <machine/types.h>
++
++typedef int16_t int16;
++typedef u_int16_t uint16;
++typedef u_int32_t uint32;
++typedef u_int64_t uint64;
++#else
+ typedef short int16;
+ typedef unsigned short uint16;
+ typedef unsigned uint32;
+ typedef unsigned long long uint64;
++#endif
+
+ typedef enum {B_KING = -6,B_QUEEN = -5,B_ROOK = -4,B_BISHOP = -3,
+ B_KNIGHT = -2,B_PAWN = -1,
+@@ -884,4 +908,8 @@
+ return pop_count16((x) & 0xFFFF) + pop_count16((x) >> 16);
+ }
+
+-
++/*
++ * Make window_size global so that the GL board can be displayed at
++ * correct initial size. window_size is defined in knightcap.c.
++ */
++extern int window_size;
diff --git a/games/knightcap/patches/patch-ae b/games/knightcap/patches/patch-ae
new file mode 100644
index 00000000000..6b9e7fa3102
--- /dev/null
+++ b/games/knightcap/patches/patch-ae
@@ -0,0 +1,54 @@
+$NetBSD: patch-ae,v 1.1.1.1 2000/10/15 08:38:23 jlam Exp $
+
+--- log.c.orig Sun May 17 19:09:21 1998
++++ log.c
+@@ -6,6 +6,9 @@
+ static FILE *cfile;
+ static FILE *dfile;
+
++/* Make this buffer big enough to print the help file. */
++#define FMT_SIZE (4096)
++
+ void log_close(void)
+ {
+ fclose(logfile);
+@@ -15,7 +18,7 @@
+ int lprintf(int level, char *format_str, ...)
+ {
+ va_list ap;
+- char fmt[1024];
++ char fmt[FMT_SIZE];
+ char *p;
+
+ if (!logfile) {
+@@ -29,7 +32,9 @@
+ va_start(ap, format_str);
+
+
+- strcpy(fmt, format_str);
++ /* Make this safer by using strncpy() instead of strcpy(). */
++ strncpy(fmt, format_str, FMT_SIZE - 1);
++ fmt[FMT_SIZE - 1] = '\0';
+ if (sizeof(short) == sizeof(etype)) {
+ while ((p = strstr(fmt, "%e"))) {
+ p[1] = 'd';
+@@ -63,7 +68,7 @@
+ int status_printf(int rew, char *format_str, ...)
+ {
+ va_list ap;
+- char fmt[1024];
++ char fmt[FMT_SIZE];
+ char *p;
+
+ if (!sfile) {
+@@ -80,7 +85,9 @@
+ va_start(ap, format_str);
+
+
+- strcpy(fmt, format_str);
++ /* Make this safer by using strncpy() instead of strcpy(). */
++ strncpy(fmt, format_str, FMT_SIZE - 1);
++ fmt[FMT_SIZE - 1] = '\0';
+ if (sizeof(short) == sizeof(etype)) {
+ while ((p = strstr(fmt, "%e"))) {
+ p[1] = 'd';
diff --git a/games/knightcap/patches/patch-af b/games/knightcap/patches/patch-af
new file mode 100644
index 00000000000..4894c4e7002
--- /dev/null
+++ b/games/knightcap/patches/patch-af
@@ -0,0 +1,55 @@
+$NetBSD: patch-af,v 1.1.1.1 2000/10/15 08:38:23 jlam Exp $
+
+--- movement.c.orig Sun May 17 19:09:21 1998
++++ movement.c
+@@ -258,33 +258,38 @@
+ }
+
+
++ /*
++ * There's some weird gcc codegen bug here when going NORTH_WEST,
++ * even with no optimization, but when it's re-written to go
++ * SOUTH_EAST, everything's fine. Ugh!
++ */
+ for (i=0;i<8;i++) {
+- dir = NORTH_WEST;
+- p1 = A1 + i*EAST;
+- p2 = A1 + i*NORTH;
++ dir = SOUTH_EAST;
++ p1 = A1 + i*NORTH;
++ p2 = A1 + i*EAST;
+
+ mask = 0;
+- for (s1=p1; s1>=p2; s1+=dir)
++ for (s1=p1; s1<p2; s1+=dir)
+ mask |= ((uint64)1<<s1);
+
+- for (s1=p1;s1>=p2;s1+=dir)
+- for (s2=p1;s2>=p2;s2+=dir)
++ for (s1=p1;s1<p2;s1+=dir)
++ for (s2=p1;s2<p2;s2+=dir)
+ if (s1 != s2) {
+ same_line_mask[s1][s2] = mask;
+ }
+ }
+
+ for (i=1;i<8;i++) {
+- dir = NORTH_WEST;
+- p1 = H1 + i*NORTH;
+- p2 = A8 + i*EAST;
++ dir = SOUTH_EAST;
++ p1 = A8 + i*EAST;
++ p2 = H1 + i*NORTH;
+
+ mask = 0;
+- for (s1=p1; s1>=p2; s1+=dir)
++ for (s1=p1; s1<p2; s1+=dir)
+ mask |= ((uint64)1<<s1);
+
+- for (s1=p1;s1>=p2;s1+=dir)
+- for (s2=p1;s2>=p2;s2+=dir)
++ for (s1=p1;s1<p2;s1+=dir)
++ for (s2=p1;s2<p2;s2+=dir)
+ if (s1 != s2) {
+ same_line_mask[s1][s2] = mask;
+ }
diff --git a/games/knightcap/patches/patch-ag b/games/knightcap/patches/patch-ag
new file mode 100644
index 00000000000..76b7aaa0260
--- /dev/null
+++ b/games/knightcap/patches/patch-ag
@@ -0,0 +1,22 @@
+$NetBSD: patch-ag,v 1.1.1.1 2000/10/15 08:38:23 jlam Exp $
+
+--- td.c.orig Sun May 17 19:09:21 1998
++++ td.c
+@@ -115,7 +115,7 @@
+
+ #if LARGE_ETYPE
+ if (round >= 0)
+- sprintf(fn, "/usr/local/chess/large_coeffs%d.h", round);
++ sprintf(fn, "large_coeffs%d.h", round);
+ else
+ sprintf(fn,"large_coeffs.h");
+ large = (FILE *)fopen(fn, "w");
+@@ -123,7 +123,7 @@
+ small = (FILE *)fopen(fn, "w");
+ #else
+ if (round >= 0)
+- sprintf(fn, "/usr/local/chess/small_coeffs%d.h", round);
++ sprintf(fn, "small_coeffs%d.h", round);
+ else
+ sprintf(fn, "small_coeffs.h");
+ large = (FILE *)fopen(fn, "w");