• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

UTILS/H17-May-1998-410344

MakefileH A D03-May-20221.8 KiB6022

Makefile.aplinuxH A D17-May-1998858 3919

Makefile.avagoH A D17-May-1998788 3824

Makefile.jokkmokkH A D17-May-1998759 3716

Makefile.silverH A D17-May-1998792 3817

READMEH A D17-May-19989.7 KiB248181

board.cH A D17-May-199814.7 KiB640492

brain.cH A D17-May-199842.3 KiB1,7941,362

difficult.finH A D17-May-19983.4 KiB4948

display.cH A D17-May-199816.1 KiB807615

epd.cH A D17-May-1998141.8 KiB8,0555,687

epd.hH A D17-May-19985.4 KiB151125

epddefs.hH A D17-May-199826.5 KiB1,014726

epdglue.cH A D17-May-19988.8 KiB546334

epdglue.hH A D17-May-19981.1 KiB354

eval.cH A D17-May-199863.8 KiB2,5851,979

eval.hH A D17-May-19982.7 KiB8076

generate.cH A D17-May-199829 KiB1,3791,028

hash.cH A D17-May-19989.8 KiB506400

ics.cH A D17-May-199814.3 KiB571412

includes.hH A D17-May-1998432 2522

knightcap.cH A D03-May-202224 KiB1,211994

knightcap.hH A D03-May-202219.6 KiB881698

large_coeffs.hH A D17-May-199852.8 KiB991794

local.hH A D17-May-1998592 2419

log.cH A D17-May-19982 KiB152110

makefileH A D17-May-19981.7 KiB5716

mkproto.awkH A D17-May-1998622 4231

move.cH A D17-May-199847.5 KiB2,3961,868

movement.cH A D17-May-19986.4 KiB339275

names.hH A D17-May-19982 KiB7877

ordering.cH A D17-May-19982 KiB11281

prog.cH A D17-May-19982.5 KiB169127

proto.hH A D17-May-19985.2 KiB150147

small_coeffs.hH A D17-May-199852.5 KiB991794

starticsH A D17-May-199887 31

startics.solarisH A D17-May-1998167 105

tactics.cH A D17-May-199812.7 KiB579455

td.cH A D17-May-199812.2 KiB555455

testsuite.cH A D17-May-19983.4 KiB190144

timer.cH A D17-May-19983.1 KiB184140

trackball.cH A D17-May-19988.3 KiB330171

trackball.hH A D17-May-19983.2 KiB798

util.cH A D17-May-199813.4 KiB792643

README

1This is version 3.3 of KnightCap. There have been substantial changes
2since version 2.4, hence the new major number. The main difference is
3KnightCap now learns its eval. See below for details.
4
5General info
6------------
7
8KnightCap is a chess program written for the Fujitsu AP1000+ parallel
9computer (running AP/Linux). It will also run on most unixes, although
10you may need to tweak the includes.h file and Makefile.
11
12The principal differences between KnightCap and other chess programs
13are:
14
15 - KnightCap has an optional fully rendered 3D interface, giving a feel much
16   more like an "over the board" game.
17
18 - KnightCap was developed to run on a parallel distributed memory
19   machine, although it also runs on normal unix boxes.
20
21 - KnightCap does not have an opening book---instead it keeps a file
22   (brain.dat) of losing moves and inserts them in the hash table at the
23   start of each search. At present it has about 1500 entries, and
24   this makes it a pretty competitive opening player.
25
26 - KnightCap learns the parameters of its evaluation function as it
27   plays. The most dramatic example of how this helps is an experiment
28   we conducted on FICS in which KnightCap learnt from a 1650 player
29   to a 2100 player in just 300 games. See
30   http://keating.anu.edu.au/~jon/papers/knigtcap.ps.gz for more info on
31   its learning algorithm.
32
33KnightCap now beats gnuchess consistently and is within "coo-ee" of
34crafty, although I think it needs deeper search or some more dramatic
35selective search to be truly competitive with the best micro
36programs.
37
38If you have comments/suggestions etc then send them to
39Andrew.Tridgell@anu.edu.au or Jon.Baxter@anu.edu.au. Andrew gets tons
40of email about some other bits of software he's written so please be
41patient if he is  very slow in replying.
42
43KnightCap is available under the GNU public license.
44
45The original chess engine and 3-D interface was written by Andrew
46Tridgell. Jonathan Baxter added the learning and patches to the eval, move
47generation, and various other bits and pieces.
48
49KnightCap currently plays on FICS (ics.onenet.net/5000) under the
50pseudonyms KnightCap and WimpKnight (experimental version), and on ICC
51(chessclub.com) under the pseudonym KnightC. It currently has a rating
52of around 2300 on FICS and 2500 on ICC (they are quite different
53versions---this README referes to the current ICC version).
54
55
56Building KnightCap
57------------------
58
59If you want the fancy graphics display then you will need an OpenGL
60graphics library and the SGI Glut toolkit. The free Mesa library is
61fine.
62
63Edit the Makefile, following the comments.
64
65Then type "make". When it doesn't work fix the problems or call on
66a local C programming guru.
67
68The code currently assumes you have a 32 bit machine and that "long
69long" is a 64 bit quantity. We'll probably fix this sometime.
70
71
72Running KnightCap
73-----------------
74
75After you start it up use the right button to access the main
76menu. Its obvious from there.
77
78You can rotate the board by dragging with the left mouse button. Move
79pieces by dragging on the piece, also with the left mouse button.
80
81If you don't compile with the fancy graphics then your get a simple
82color ascii display. If you have a mono terminal then start with the
83-B option.
84
85You should also try the "help" command once you start it up, and the
86-h switch on the command line when you run it. There are lots of
87options you can set.
88
89For "normal" play I recommend at least the -A switch (so that it
90thinks on opponents time) and the -H switch, which is used to specify
91how much memory to use for the hash tables.
92
93KnightCap needs heaps of memory for hash tables. It uses a memory
94intensive varient of alpha-beta so it will be much more affected by
95lack of memory than other programs. Try to give it at least 16MB,
96preferably more, but don't specify so much that it begins to swap!
97
98KnightCap's Learning
99--------------------
100
101KnightCap currently has two different kinds of learning: opening book
102and evaluation function learning. The opening learning works as
103follows. After each game KnightCap loses, it inserts the losing move
104(see analyse_game in brain.c for how this is calculated) in a
105permanent brain file (brain.dat). These entries are inserted into
106KnightCap's hash table at the start of each search. This means
107KnightCap will avoid playing the same losing line again.
108
109The evaluation function learning is also applied at the end of each
110game, although updates only occur every 10 games at the moment (You
111can alter this with the MAX_GAMES constant in td.c). It works on the
112principle of temporal differences, that is, it updates the
113coefficients in such a way as to try to keep the evaluation function
114constant throughout the game.  See td.c for details. You can turn this on
115or off in the Makefile. The hash table is much smaller with it on, and
116this can affect performance. Three files are written out at the end of
117each game: large_coeffs.h, small_coeffs.h and coeffs.dat. These files
118all contain the same information: the value of KnightCap's evaluation
119function coefficients. The two .h files are included by eval.c
120("large_coeffs.h" contains the coefficients in units where 1 pawn =
12110000, small_coeffs.h has 1 pawn = 100). coeffs.dat is a binary file
122that gets read when KnightCap starts up, and overwrites the values
123specified in the .h files. If you have a favourite coefficients file,
124make sure you save it in a different directory so KnightCap doesn't
125overwrite it.
126
127Note that KnightCap has 4 different stages in its eval: OPENING,
128MIDDLE, ENDING and MATING. MATING stage coefficients are never
129altered---most of them are ignored as the mating stage code is
130designed mostly to drive the opponent's king into the corners. All the
131other coefficients can change if you have evaluation learning turned
132on.
133
134At present, KnightCap uses a couple of scratch files to store
135coefficient update information during and between games: update.dat,
136grad.dat and rounds.dat. You can look in wnorm.dat to see the L1 norm
137between KnightCap's current coefficient vector  and the one it was
138compiled with, and angle.dat to see the change in angle (in radians)
139between KnightCap's current coefficient vector and the one at the last
140update.
141
142Modifying the Eval
143------------------
144
145Perhaps the easiest and most fun place to start modifying KnightCap is
146in its evaluation function. With the learning, you can add new
147features and corresponding coefficients, set the new coefficients to
148plausible values (remembering that 1 pawn = 10000) or just 0, and then
149set KnightCap playing on ICS or against some other program and watch
150it learn the coefficient values. You can control the learning rate
151with the TD_ALPHA constant in td.c. You can also vary the TD_LAMBDA
152parameter which controls whether the evaluation function is adjusted
153to predict only the eval at the next move (TD_LAMBDA = 0) or the
154outcome of the game (TD_LAMBDA = 1). Values in between interpolate
155these two behaviours.
156
157Adding new coefficients is particularly easy. Just edit large_coeffs.h
158and insert the new coefficients wherever you want, remembering to add
159a comment with the name in it, and also to add the same coefficients
160in each of the four stages (stages are delimited by /* %OPENING% */ ,
161/* %MIDDLE% */, etc). Then compile "extract.c" (in UTILS) and run it
162in the directory where the new large_coeffs.h is. This will
163automatically generate eval.h and names.h which contain the new names
164and ordering for the coefficients (you might want to save backups of
165these). Once you have generated these, you can compile KnightCap and
166away you go.
167
168
169
170
171Using with XBoard
172-----------------
173
174Yes, KnightCap can be used with XBoard. Start KnightCap with the -n
175and -X options on the command line. For example
176
177	  xboard -fcp 'KnightCap -n -X -A'
178
179then play as usual. KnightCap doesn't yet support editing
180positions (except when connected to FICS). It does understand time
181controls etc and most other stuff that XBoard throws at it.
182
183
184
185Playing against other programs (e.g Crafty).
186--------------------------------------------
187
188You can use xboard  to run matches between Knigtcap and other programs
189like crafty (or even KnightCap itself). This is particularly useful if
190you have introduced new coefficients and want to look at how they get
191learnt, or if you mess with other areas of the program and want to
192test it. In the Test subdirectory you'll see a script "matchN" which
193tells you how to do it.
194
195
196
197Playing on ICS
198--------------
199
200Yes, KnightCap can be used as an interface to ICS. Its a bit
201rudimentary at the moment, and is not really intended for general
202consumption but it does work.
203
204To start it up use the -c option like this:
205
206	KnightCap -c 'telnet ics.onenet.net 5000'
207
208Make sure you use board style 12 (use "set style 12" once logged in).
209
210The ICS interface was designed to let KnightCap play unattended, not
211as a general ICS interface, so you may find bugs.
212
213We have also provided two Bourne shell scripts "startics" and
214"startfics" to give you an idea of how to run KnightCap automatically
215on ICS.
216
217
218Mesa and Glut
219-------------
220
221To build KnightCap with the 3D display you need a OpenGL complient
222graphics library and the Glut toolkit from SGI. Both of these are
223avaiable freely on the net. To help make things a bit easier for some
224people I have included pre-compiled versions of these libraries on the
225KnightCap ftp site for Linux-intel and Solaris2-sparc systems. Use
226these pre-compiled packages only if you are lazy and short on time.
227
228You may also need to set your LD_LIBRARY_PATH environment variable to
229point at the Mesa-2.1/lib directory so that the dynamic loader can
230find the libraries when KnightCap starts up.
231
232
233
234Source code
235-----------
236
237The source code for KnightCap is available from
238http://syseng.anu.edu.au/lsg/KnightCap or
239ftp://samba.anu.edu.au/pub/KnightCap
240
241Feedback and patches are welcome.
242
243
244Last modified 25/11/97
245
246Andrew.Tridgell@anu.edu.au
247Jon.Baxter@anu.edu.au
248