9 #include "joseki/base.h"
13 joseki_init(int bsize
)
15 struct joseki_dict
*jd
= calloc(1, sizeof(*jd
));
17 jd
->patterns
= calloc(1 << joseki_hash_bits
, sizeof(jd
->patterns
[0]));
22 joseki_load(int bsize
)
24 FILE *f
= fopen("pachijoseki.dat", "r"); // XXX: size-dependent
27 perror("pachijoseki.dat");
30 struct joseki_dict
*jd
= joseki_init(bsize
);
33 while (fgets(linebuf
, 1024, f
)) {
36 hash_t h
= strtoull(line
, &line
, 16);
37 while (isspace(*line
)) line
++;
38 enum stone color
= *line
++ == 'b' ? S_BLACK
: S_WHITE
;
39 while (isspace(*line
)) line
++;
42 char *cs
= strrchr(line
, ' '); assert(cs
);
46 coord_t
**ccp
= &jd
->patterns
[h
].moves
[color
- 1];
48 *ccp
= calloc2(count
+ 1, sizeof(coord_t
));
51 assert(cc
- *ccp
< count
);
52 coord_t
*c
= str2coord(line
, bsize
);
55 line
+= strcspn(line
, " ");
56 line
+= strspn(line
, " ");
63 fprintf(stderr
, "Joseki dictionary for board size %d loaded.\n", bsize
- 2);
68 joseki_done(struct joseki_dict
*jd
)