src/chess/fen.c

changeset 195
27d02ccb0cef
parent 194
619f07c95894
equal deleted inserted replaced
194:619f07c95894 195:27d02ccb0cef
41 if (gamestate->board[rank][file]) { 41 if (gamestate->board[rank][file]) {
42 if (skip > 0) { 42 if (skip > 0) {
43 str[i++] = '0'+skip; 43 str[i++] = '0'+skip;
44 skip = 0; 44 skip = 0;
45 } 45 }
46 switch (piece_at(gamestate, rank, file)) { 46 switch (piece_at(gamestate, file, rank)) {
47 case WHITE|KING: str[i++] = 'K'; break; 47 case WHITE|KING: str[i++] = 'K'; break;
48 case WHITE|QUEEN: str[i++] = 'Q'; break; 48 case WHITE|QUEEN: str[i++] = 'Q'; break;
49 case WHITE|BISHOP: str[i++] = 'B'; break; 49 case WHITE|BISHOP: str[i++] = 'B'; break;
50 case WHITE|KNIGHT: str[i++] = 'N'; break; 50 case WHITE|KNIGHT: str[i++] = 'N'; break;
51 case WHITE|ROOK: str[i++] = 'R'; break; 51 case WHITE|ROOK: str[i++] = 'R'; break;
119 static size_t fen_enpassant(char *str, GameState *gamestate) { 119 static size_t fen_enpassant(char *str, GameState *gamestate) {
120 120
121 str[0] = '-'; 121 str[0] = '-';
122 122
123 for (int file = 0 ; file < 8 ; file++) { 123 for (int file = 0 ; file < 8 ; file++) {
124 if (enpassant_threat_exists(gamestate, 3, file)) { 124 if (enpassant_threat_exists(gamestate, file, 3)) {
125 str[0] = filechr(file); 125 str[0] = filechr(file);
126 str[1] = rankchr(2); 126 str[1] = rankchr(2);
127 } 127 }
128 if (enpassant_threat_exists(gamestate, 4, file)) { 128 if (enpassant_threat_exists(gamestate, file, 4)) {
129 str[0] = filechr(file); 129 str[0] = filechr(file);
130 str[1] = rankchr(5); 130 str[1] = rankchr(5);
131 } 131 }
132 } 132 }
133 133

mercurial