10 #include "tactics/util.h"
14 group_to_libmap(struct board
*b
, group_t group
)
17 #define hbits (sizeof(hash_t)*CHAR_BIT)
19 enum stone color
= board_at(b
, group
);
20 struct group
*gi
= &board_group_info(b
, group
);
21 int libs
= gi
->libs
< GROUP_REFILL_LIBS
? gi
->libs
: GROUP_REFILL_LIBS
;
23 for (int i
= 0; i
< libs
; i
++) {
24 hash_t hlib
= hash_at(b
, gi
->lib
[i
], color
);
25 /* Rotate the hash based on prospects of the liberty. */
26 int p
= immediate_liberty_count(b
, gi
->lib
[i
]) +
27 4 * neighbor_count_at(b
, gi
->lib
[i
], color
);
28 hlib
= (hlib
<< p
) | ((hlib
>> (hbits
- p
)) & ((1<<p
) - 1));