TESTS: a1267 more tests
[pachi.git] / stats.h
blob78d463ef6e6b85164ce63f303426b5eca76933fc
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 stats_add_result(dest, src->value, src->playouts);
34 static inline void
35 stats_reverse_parity(struct move_stats *s)
37 s->value = 1 - s->value;
40 #endif