- rank = RANK_8;
- file = FILE_A;
- for(i = 0; fen[i] != ' '; i++) {
- if(isdigit(fen[i]))
- // Skip the given number of files
- file += (fen[i] - '1' + 1);
- else {
- Square square = make_square(file, rank);
- switch(fen[i]) {
- case 'K': this->put_piece(WK, square); file++; break;
- case 'Q': this->put_piece(WQ, square); file++; break;
- case 'R': this->put_piece(WR, square); file++; break;
- case 'B': this->put_piece(WB, square); file++; break;
- case 'N': this->put_piece(WN, square); file++; break;
- case 'P': this->put_piece(WP, square); file++; break;
- case 'k': this->put_piece(BK, square); file++; break;
- case 'q': this->put_piece(BQ, square); file++; break;
- case 'r': this->put_piece(BR, square); file++; break;
- case 'b': this->put_piece(BB, square); file++; break;
- case 'n': this->put_piece(BN, square); file++; break;
- case 'p': this->put_piece(BP, square); file++; break;
- case '/': file = FILE_A; rank--; break;
- case ' ': break;
- default:
- std::cout << "Error in FEN at character " << i << std::endl;
- return;