Distributed engine: Define board_bits2 and path2sstr
[pachi.git] / distributed / distributed.h
blobd436306402d531a3e8762a318f2745279db6a370
1 #ifndef ZZGO_DISTRIBUTED_DISTRIBUTED_H
2 #define ZZGO_DISTRIBUTED_DISTRIBUTED_H
4 #include <limits.h>
6 #include "engine.h"
7 #include "stats.h"
9 /* A coord path encodes coordinates from root child to a given node:
10 * A1->B2->C3 is encoded as coord(A1)<<18 + coord(B2)<<9 + coord(C3)
11 * for 19x19. In this version the table is not a transposition table
12 * so A1->B2->C3 and C3->B2->A1 are different.
13 * The depth is limited to 7 for 19x19 (9 for 9x9) to fit in 64 bits.
14 * path_t is signed to include pass and resign. */
15 typedef int64_t path_t;
16 #define PRIpath PRIx64
17 #define PATH_T_MAX INT64_MAX
19 #define hash_mask(bits) ((1<<(bits))-1)
21 /* parent_path() must never be used if path might be pass or resign. */
22 #define parent_path(path, board) ((path) >> board_bits2(board))
23 #define leaf_coord(path, board) ((path) & hash_mask(board_bits2(board)))
24 #define append_child(path, c, board) (((path) << board_bits2(board)) | (c))
27 /* Stats exchanged between master and slave. They are always
28 * incremental values to be added to what was last sent. */
29 struct incr_stats {
30 path_t coord_path;
31 struct move_stats incr;
34 #define DIST_GAMELEN 1000
36 #define force_reply(id) ((id) + DIST_GAMELEN)
37 #define prevent_reply(id) ((id) % DIST_GAMELEN)
38 #define move_number(id) ((id) % DIST_GAMELEN)
39 #define reply_disabled(id) ((id) < DIST_GAMELEN)
41 struct move_stats2 {
42 struct move_stats u;
43 struct move_stats amaf;
46 char *path2sstr(path_t path, struct board *b);
47 struct engine *engine_distributed_init(char *arg, struct board *b);
49 #endif