src/chess/game-info.h

changeset 98
9cb41383540f
parent 80
b980a7192b5a
equal deleted inserted replaced
97:f87cad9445b4 98:9cb41383540f
79 struct movetimeval timestamp; 79 struct movetimeval timestamp;
80 struct movetimeval movetime; 80 struct movetimeval movetime;
81 char string[8]; 81 char string[8];
82 } Move; 82 } Move;
83 83
84 typedef struct MoveList MoveList;
85
86 struct MoveList {
87 Move move;
88 MoveList* next;
89 };
90
91 typedef struct { 84 typedef struct {
92 uint8_t servercolor; 85 uint8_t servercolor;
93 uint8_t timecontrol; 86 uint8_t timecontrol;
94 uint16_t time; 87 uint16_t time;
95 uint16_t addtime; 88 uint16_t addtime;
96 } GameInfo; 89 } GameInfo;
97 90
98 typedef struct { 91 typedef struct {
99 Board board; 92 Board board;
100 MoveList* movelist; 93 Move* moves;
101 MoveList* lastmove; 94 /** capacity of the move array */
102 unsigned int movecount; /* number of (half-)moves (counting BOTH colors) */ 95 unsigned movecapacity;
96 /** number of (half-)moves (counting BOTH colors) */
97 unsigned int movecount;
103 bool checkmate; 98 bool checkmate;
104 bool stalemate; 99 bool stalemate;
105 bool remis; 100 bool remis;
106 bool resign; 101 bool resign;
107 } GameState; 102 } GameState;
108 103
109 104
110 #define is_game_running(gamestate) !((gamestate)->checkmate || \ 105 #define is_game_running(gamestate) !((gamestate)->checkmate || \
111 (gamestate)->resign || (gamestate)->stalemate || (gamestate)->remis) 106 (gamestate)->resign || (gamestate)->stalemate || (gamestate)->remis)
107
108 #define last_move(gamestate) \
109 ((gamestate)->moves[(gamestate)->movecount-1])
112 110
113 /** 111 /**
114 * Initializes a game state and prepares the chess board. 112 * Initializes a game state and prepares the chess board.
115 * @param gamestate the game state to initialize 113 * @param gamestate the game state to initialize
116 */ 114 */

mercurial