forked from tridge/KnightCap
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdump.c
More file actions
77 lines (65 loc) · 1.51 KB
/
dump.c
File metadata and controls
77 lines (65 loc) · 1.51 KB
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
#include "includes.h"
#include "knightcap.h"
#include "names.h"
static void p_coeff_vector(struct coefficient_name *cn, FILE *fd,float scale)
{
int x;
fprintf(fd,"/* %s */\n", cn->name);
for (x=0; x<(cn+1)->index - cn->index; x++) {
fprintf(fd,"%7d,",
(int)rint(coefficients[cn->index + x]*scale));
}
fprintf(fd,"\n");
}
static void p_coeff_board(struct coefficient_name *cn, FILE *fd,float scale)
{
int x, y;
fprintf(fd,"/* %s */\n", cn->name);
for (y=0; y<8; y++) {
for (x=0; x<8; x++) {
fprintf(fd,"%7d,",
(int)rint(coefficients[cn->index + x + y*8]*scale));
}
fprintf(fd,"\n");
}
}
static void p_coeff_half_board(struct coefficient_name *cn, FILE *fd,float scale)
{
int x, y;
fprintf(fd,"/* %s */\n", cn->name);
for (y=0; y<8; y++) {
for (x=0; x<4; x++) {
fprintf(fd,"%7d,",
(int)rint(coefficients[cn->index + x + y*4]*scale));
}
fprintf(fd,"\n");
}
}
void dump_coeffs(char *fname, float scale)
{
struct coefficient_name *cn;
FILE *fd = fopen(fname, "w");
if (fd == NULL) {
perror(fname);
return;
}
fprintf(fd, "CONST_EVAL etype coefficients[] = {\n");
cn = &coefficient_names[0];
while (cn->name) {
int n = cn[1].index - cn[0].index;
if (n == 1) {
fprintf(fd, "/* %s */ %d,\n",
cn[0].name,
(int)rint(coefficients[cn[0].index]*scale));
} else if (n == 64) {
p_coeff_board(cn,fd,scale);
} else if (n == 32) {
p_coeff_half_board(cn,fd,scale);
} else {
p_coeff_vector(cn,fd,scale);
}
cn++;
}
fprintf(fd, "};\n");
fclose(fd);
}