1.1 --- a/src/chess/rules.h Thu Apr 17 12:16:14 2014 +0200 1.2 +++ b/src/chess/rules.h Wed May 28 15:47:57 2014 +0200 1.3 @@ -38,6 +38,8 @@ 1.4 #define INVALID_POSITION 2 1.5 #define AMBIGUOUS_MOVE 3 1.6 #define NEED_PROMOTION 4 1.7 +#define PIECE_PINNED 5 1.8 +#define KING_IN_CHECK 6 1.9 1.10 1.11 #define PIECE_MASK 0x0F 1.12 @@ -167,9 +169,10 @@ 1.13 * @param row row of the field to check 1.14 * @param file file of the field to check 1.15 * @param color the color of the piece that should threaten the field 1.16 - * @param threats the array where to store the threats (should be able to the 1.17 - * rare maximum of 16 elements) 1.18 - * @param threatcount a pointer to an uint8_t where to store the amount of threats 1.19 + * @param threats the array where to store the threats (should be able to hold 1.20 + * the rare maximum of 16 elements) 1.21 + * @param threatcount a pointer to an uint8_t where the count of threats is 1.22 + * stored 1.23 * @return TRUE, if any piece of the specified color threatens the specified 1.24 * field (i.e. could capture an opponent piece) 1.25 */ 1.26 @@ -187,9 +190,10 @@ 1.27 * @param row row of the field to check 1.28 * @param file file of the field to check 1.29 * @param color the color of the piece that should threaten the field 1.30 - * @param threats the array where to store the threats (should be able to the 1.31 - * rare maximum of 16 elements) 1.32 - * @param threatcount a pointer to an uint8_t where to store the amount of threats 1.33 + * @param threats the array where to store the threats (should be able to hold 1.34 + * the rare maximum of 16 elements) 1.35 + * @param threatcount a pointer to an uint8_t where the count of threats is 1.36 + * stored 1.37 * @return TRUE, if any piece of the specified color threatens the specified 1.38 * field (i.e. could capture an opponent piece) 1.39 */ 1.40 @@ -242,6 +246,22 @@ 1.41 uint8_t color); 1.42 1.43 /** 1.44 + * Checks, if the specified move cannot be performed, because the piece is 1.45 + * either pinned or cannot remove the check. 1.46 + * 1.47 + * Note: in chess a piece is pinned, when it can't be moved because the move 1.48 + * would result in a check position. But this function <u>also</u> returns true, 1.49 + * if the king is already in check position and the specified move does not 1.50 + * protect the king. 1.51 + * 1.52 + * @param gamestate the current game state 1.53 + * @param move the move to check 1.54 + * @return TRUE, if the move cannot be performed because the king would be in 1.55 + * check after the move 1.56 + */ 1.57 +_Bool is_pinned(GameState *gamestate, Move *move); 1.58 + 1.59 +/** 1.60 * Evaluates a move syntactically and stores the move data in the specified 1.61 * object. 1.62 *