1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
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;
|