Added some investigations of another game. Move 61 seems to yield rather random...
[pachi/pachi-r6144.git] / stone.h
blob4afb3dc806368f52945aa21f9cd3e8fa7338f3e5
1 #ifndef PACHI_STONE_H
2 #define PACHI_STONE_H
4 enum stone {
5 S_NONE,
6 S_BLACK,
7 S_WHITE,
8 S_OFFBOARD,
9 S_MAX,
12 static char stone2char(enum stone s);
13 static enum stone char2stone(char s);
14 char *stone2str(enum stone s); /* static string */
15 enum stone str2stone(char *str);
17 static enum stone stone_other(enum stone s);
20 static inline char
21 stone2char(enum stone s)
23 return ".XO#"[s];
26 static inline enum stone
27 char2stone(char s)
29 switch (s) {
30 case '.': return S_NONE;
31 case 'X': return S_BLACK;
32 case 'O': return S_WHITE;
33 case '#': return S_OFFBOARD;
35 return S_NONE; // XXX
38 /* Curiously, gcc is reluctant to inline this; I have cofirmed
39 * there is performance benefit. */
40 static inline enum stone __attribute__((always_inline))
41 stone_other(enum stone s)
43 static const enum stone o[S_MAX] = { S_NONE, S_WHITE, S_BLACK, S_OFFBOARD };
44 return o[s];
47 #endif