MQ: Increase from 64 to 128; counter-atari check was overflowing
[pachi/json.git] / stats.h
blobcdc80dc6bc3497d005ddd06a0cc5e26eb4aa1d72
1 #ifndef ZZGO_STATS_H
2 #define ZZGO_STATS_H
4 /* Move statistics; we track how good value each move has. */
6 struct move_stats {
7 int playouts; // # of playouts
8 float value; // BLACK wins/playouts
9 };
11 /* Add a result to the stats. */
12 static void stats_add_result(struct move_stats *s, float result, int playouts);
14 /* Merge two stats together. */
15 static void stats_merge(struct move_stats *dest, struct move_stats *src);
17 /* Reverse stats parity. */
18 static void stats_reverse_parity(struct move_stats *s);
21 static inline void
22 stats_add_result(struct move_stats *s, float result, int playouts)
24 s->playouts += playouts;
25 s->value += (result - s->value) * playouts / s->playouts;
28 static inline void
29 stats_merge(struct move_stats *dest, struct move_stats *src)
31 if (src->playouts > 0)
32 stats_add_result(dest, src->value, src->playouts);
35 static inline void
36 stats_reverse_parity(struct move_stats *s)
38 s->value = 1 - s->value;
41 #endif