src/chess/rules.h

changeset 25
3ab0c2e1a4e2
parent 23
824c9522ce66
child 26
e0a76ee1bb2b
equal deleted inserted replaced
24:4d030da07c88 25:3ab0c2e1a4e2
93 uint8_t mycolor; 93 uint8_t mycolor;
94 MoveList* movelist; 94 MoveList* movelist;
95 MoveList* lastmove; 95 MoveList* lastmove;
96 } GameState; 96 } GameState;
97 97
98 #define opponent_color(color) ((color)==WHITE?BLACK:WHITE)
99
98 #define POS_UNSPECIFIED UINT8_MAX 100 #define POS_UNSPECIFIED UINT8_MAX
99 #define mdst(b,m) b[(m)->torow][(m)->tofile] 101 #define mdst(b,m) b[(m)->torow][(m)->tofile]
100 #define msrc(b,m) b[(m)->fromrow][(m)->fromfile] 102 #define msrc(b,m) b[(m)->fromrow][(m)->fromfile]
101 103
102 #define isidx(idx) ((uint8_t)idx < 8) 104 #define isidx(idx) ((uint8_t)idx < 8)
138 * @return character value for the specified piece 140 * @return character value for the specified piece
139 */ 141 */
140 char getpiecechr(uint8_t piece); 142 char getpiecechr(uint8_t piece);
141 143
142 /** 144 /**
145 * Checks, if a specified field is covered by a piece of a certain color.
146 *
147 * @param gamestate the current game state
148 * @param row row of the field to check
149 * @param file file of the field to check
150 * @param color the color of the piece that should cover the field
151 * @return TRUE, if any piece of the specified color threatens the specified
152 * field (i.e. could capture an opponent piece)
153 */
154 _Bool is_covered(GameState *gamestate,uint8_t row,uint8_t file,uint8_t color);
155
156 /**
143 * Evaluates a move syntactically and stores the move data in the specified 157 * Evaluates a move syntactically and stores the move data in the specified
144 * object. 158 * object.
145 * 159 *
146 * @param gamestate the current game state 160 * @param gamestate the current game state
147 * @param mstr the input string to parse 161 * @param mstr the input string to parse

mercurial