extern "C" void Referee_init_game() // unsigned char board[10][9] = NULL { const char side = 'w'; // NOTE: Hard-coded starting side. srand((DWORD) time(NULL)); InitZobrist(); pos.Startup(NULL); if ( side == 'b' ) { pos.ChangeSide(); } }
int ReadFEN(const char *sFEN, BOARD *board) { /*TODO: check FEN validity.*/ int fen_pos = 0; SQUARE square = 0x70; board->wk_castle = 0; board->bk_castle = 0; board->wq_castle = 0; board->bq_castle = 0; board->w_castled = 0; board->b_castled = 0; for (char on_board = 1; on_board; fen_pos++) { char empty = 0; switch (sFEN[fen_pos]) { case ' ': on_board = 0; break; case '/': square -= 0x18; break; case '1': empty = 1; break; case '2': empty = 2; break; case '3': empty = 3; break; case '4': empty = 4; break; case '5': empty = 5; break; case '6': empty = 6; break; case '7': empty = 7; break; case '8': empty = 8; break; default: board->squares[square] = CharToPiece(sFEN[fen_pos]); if (board->squares[square] == W_KING) board->wking_pos = square; else if (board->squares[square] == B_KING) board->bking_pos = square; square++; break; } for (int i = 0; i < empty; i++) board->squares[square+i] = EMPTY; square += empty; } board->white_to_move = (sFEN[fen_pos] == 'w'); fen_pos+=2; for (char on_board = 1; on_board; fen_pos++) { /*Castle rights loop.*/ switch (sFEN[fen_pos]) { case 'K': board->wk_castle = 1; break; case 'k': board->bk_castle = 1; break; case 'Q': board->wq_castle = 1; break; case 'q': board->bq_castle = 1; break; case '-': break; default: on_board = 0; break; } } /*Store En Passant coordinates. TODO: check.*/ board->en_passant = 0x00; for (char on_board = 1; on_board; fen_pos++) { switch (sFEN[fen_pos]) { case ' ': on_board = 0; break; default: board->en_passant += CharToCoordinate(sFEN[fen_pos]); break; } } /*halfmoves and moves.*/ int rev = atoi(&sFEN[fen_pos]); while (sFEN[++fen_pos] != ' '); board->ply = 2*atoi(&sFEN[fen_pos]) - board->white_to_move - 1; board->rev_plies[board->ply] = rev; InitZobrist(board); board->zobrist_history[board->ply] = board->zobrist_key; InitMaterial(board); return fen_pos; }