Does anyone have a copy of the source code for KnightCap, or can point me to a link? I've found a couple that purport to point to the source code, but the links don't work for me.
On a related note, are there other engines (besides Giraffe) with source code that have a functional TD-leaf implementation built into them? I tried implementing this in my engine based on the formulas in the KnightCap paper and it didn't work at all for me, so I'd like to look at an actual implementation for comparison.
KnightCap source code
Moderators: hgm, Rebel, chrisw
-
- Posts: 1383
- Joined: Fri Jul 14, 2006 7:56 am
- Location: London, England
- Full name: Jim Ablett
-
- Posts: 558
- Joined: Sat Mar 25, 2006 8:27 pm
Re: KnightCap source code
Thanks! I think the link I was trying to follow had ftp: instead of https:, and my browser was choking on it.
-
- Posts: 142
- Joined: Wed Jul 08, 2015 12:30 pm
Re: KnightCap source code
Did anyone manage to compile it under linux? My computer chokes soon after giving the make command:
Code: Select all
giovanni@giovanni-System-Product-Name:~/Downloads/Export$ make
gcc -O -Dinline="" -c -o knightcap.o knightcap.c
In file included from knightcap.c:7:0:
knightcap.h:635:21: error: conflicting types for ‘fmin’
static inline float fmin(float i1, float i2)
^
knightcap.h:640:21: error: conflicting types for ‘fmax’
static inline float fmax(float i1, float i2)
^
knightcap.c: In function ‘idle_func’:
knightcap.c:674:9: warning: ignoring return value of ‘system’, declared with attribute warn_unused_result [-Wunused-result]
system("killall sleep");
^
knightcap.c:676:9: warning: ignoring return value of ‘system’, declared with attribute warn_unused_result [-Wunused-result]
system("killall sleep");
^
knightcap.c: In function ‘save_game’:
knightcap.c:750:7: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
write(fd, state, sizeof(*state));
^
knightcap.c: In function ‘restore_game’:
knightcap.c:761:6: warning: ignoring return value of ‘read’, declared with attribute warn_unused_result [-Wunused-result]
read(fd, state, sizeof(*state));
^
knightcap.c: In function ‘parse_options’:
knightcap.c:1078:11: warning: ignoring return value of ‘fscanf’, declared with attribute warn_unused_result [-Wunused-result]
fscanf(f, "%s", opponents_list);
^
knightcap.c:1084:11: warning: ignoring return value of ‘fscanf’, declared with attribute warn_unused_result [-Wunused-result]
fscanf(f,"%s", noplay_list);
^
make: *** [knightcap.o] Error 1
Re: KnightCap source code
giovanni wrote: Did anyone manage to compile it under linux? My computer chokes soon after giving the make command:
Just remove those functions; they're in glibc.Code: Select all
giovanni@giovanni-System-Product-Name:~/Downloads/Export$ make gcc -O -Dinline="" -c -o knightcap.o knightcap.c In file included from knightcap.c:7:0: knightcap.h:635:21: error: conflicting types for ‘fmin’ static inline float fmin(float i1, float i2) ^ knightcap.h:640:21: error: conflicting types for ‘fmax’ static inline float fmax(float i1, float i2) ^
-
- Posts: 27796
- Joined: Fri Mar 10, 2006 10:06 am
- Location: Amsterdam
- Full name: H G Muller
Re: KnightCap source code
A general method to solve such problems when you are not sure if the functions in the library do exactly the same as those the program defines, would be to just alter their name through a macro. Just before their definition write
That should solve the name clash.
Code: Select all
#define fmin my_fmin
#define fmax my_fmax
-
- Posts: 142
- Joined: Wed Jul 08, 2015 12:30 pm
Re: KnightCap source code
flok wrote:Thanks. I commented those lines out, but now I get a different error:giovanni wrote: Did anyone manage to compile it under linux? My computer chokes soon after giving the make command:
Just remove those functions; they're in glibc.Code: Select all
giovanni@giovanni-System-Product-Name:~/Downloads/Export$ make gcc -O -Dinline="" -c -o knightcap.o knightcap.c In file included from knightcap.c:7:0: knightcap.h:635:21: error: conflicting types for ‘fmin’ static inline float fmin(float i1, float i2) ^ knightcap.h:640:21: error: conflicting types for ‘fmax’ static inline float fmax(float i1, float i2) ^
Code: Select all
giovanni@giovanni-System-Product-Name:~/Downloads/Export$ make gcc -O3 -fomit-frame-pointer -fshort-enums -Wall -DCPU=686 -c -o knightcap.o knightcap.c In file included from knightcap.c:7:0: knightcap.h:219:0: warning: "INFINITY" redefined [enabled by default] #define INFINITY (40.50*STATIC_PAWN_VALUE) ^ In file included from /usr/include/math.h:38:0, from includes.h:8, from knightcap.c:5: /usr/include/x86_64-linux-gnu/bits/inf.h:26:0: note: this is the location of the previous definition # define INFINITY (__builtin_inff()) ^ In file included from knightcap.c:7:0: knightcap.h:635:2: error: invalid preprocessing directive #static #static inline float fmin(float i1, float i2) ^ knightcap.h:636:1: error: expected identifier or ‘(’ before ‘{’ token { ^ knightcap.h:640:2: error: invalid preprocessing directive #static #static inline float fmax(float i1, float i2) ^ knightcap.h:641:1: error: expected identifier or ‘(’ before ‘{’ token { ^ knightcap.c: In function ‘parse_stdin’: knightcap.c:358:7: warning: suggest explicit braces to avoid ambiguous ‘else’ [-Wparentheses] if (opponent == CRAFTY) ^ knightcap.c: In function ‘idle_func’: knightcap.c:674:9: warning: ignoring return value of ‘system’, declared with attribute warn_unused_result [-Wunused-result] system("killall sleep"); ^ knightcap.c:676:9: warning: ignoring return value of ‘system’, declared with attribute warn_unused_result [-Wunused-result] system("killall sleep"); ^ knightcap.c: In function ‘save_game’: knightcap.c:750:7: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result] write(fd, state, sizeof(*state)); ^ knightcap.c: In function ‘restore_game’: knightcap.c:761:6: warning: ignoring return value of ‘read’, declared with attribute warn_unused_result [-Wunused-result] read(fd, state, sizeof(*state)); ^ knightcap.c: In function ‘parse_options’: knightcap.c:1078:11: warning: ignoring return value of ‘fscanf’, declared with attribute warn_unused_result [-Wunused-result] fscanf(f, "%s", opponents_list); ^ knightcap.c:1084:11: warning: ignoring return value of ‘fscanf’, declared with attribute warn_unused_result [-Wunused-result] fscanf(f,"%s", noplay_list); ^ make: *** [knightcap.o] Error 1
-
- Posts: 2555
- Joined: Fri Nov 26, 2010 2:00 pm
- Location: Czech Republic
- Full name: Martin Sedlak
Re: KnightCap source code
Yes, standardized in C99.flok wrote:Just remove those functions; they're in glibc.
Using -std=c89 might work.
Alternatively you can only define those functions only
Code: Select all
#if __STDC_VERSION__ >= 199901L
-
- Posts: 142
- Joined: Wed Jul 08, 2015 12:30 pm
Re: KnightCap source code
The compiler still complains, but this did the trick. Thanks a lot.hgm wrote:A general method to solve such problems when you are not sure if the functions in the library do exactly the same as those the program defines, would be to just alter their name through a macro. Just before their definition write
That should solve the name clash.Code: Select all
#define fmin my_fmin #define fmax my_fmax
-
- Posts: 27796
- Joined: Fri Mar 10, 2006 10:06 am
- Location: Amsterdam
- Full name: H G Muller
Re: KnightCap source code
Well, the other complaints were just warnings against other things, so they would not get away by this. This attribute "warn_unused_result" is actually a very pedantic pest.