Answers.Body: <p>Without reviewing the complete code (which is probably humongous), it is difficult to give a proven right answer.</p>
  <p>However, it should work if you replace the lines for the black castling possibilities by <code>BLACK_00 = 0, BLACK_000 = 0,</code> (or respectively for the white, if you want). This should lead to all tests in the code returning 'black castling not possible', which is the intention.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-07-04T14:20:59.010Z
Answers.LastActivityDate: 2020-07-04T14:20:59.010Z
Answers.UserDisplayName: Aganju
Answers.Body: <p>There is no need to compile your own version of Stockfish for this.  Instead you can just start from a position that omits castling rights for one side or the other. The FEN for the initial position without castling rights for White is</p>
  <p><code>rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w kq - 0 1</code></p>
  <p>and the FEN for the initial position without castling rights for Black is</p>
  <p><code>rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQ - 0 1</code></p>
  <p>The FEN can be entered into Stockfish using the UCI command</p>
  <p><code>position fen FEN</code></p>
  <p>where <code>FEN</code> should be replaced by the FEN in question.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-08-12T06:59:03.813Z
Answers.Text: Of course, this works for any UCI engine, not just Stockfish.
Answers.UserDisplayName: Stephen
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-07-04T15:45:51.523Z
Answers.LastActivityDate: 2020-07-04T15:53:29.177Z
Answers.LastEditDate: 2020-07-04T15:53:29.177Z
Answers.UserDisplayName: Stephen
Body: <p>For artistic purposes, I would like to create and study engine games in which only one side is able to castle.</p>
  <p>For this, I need to compile a version of Stockfish which never castles, and doesn't consider its own castling in its calculations, whereas calculates with castling for the opponent.</p>
  <p>I have gone through the <a href="https://github.com/official-stockfish/Stockfish/blob/master/src/types.h" rel="nofollow noreferrer">types.h</a> file and found the following:</p>
  <pre><code>enum MoveType {
    NORMAL,
    PROMOTION = 1 &lt;&lt; 14,
    ENPASSANT = 2 &lt;&lt; 14,
    CASTLING  = 3 &lt;&lt; 14
  };
  
  enum CastlingRights {
    NO_CASTLING,
    WHITE_OO,
    WHITE_OOO = WHITE_OO &lt;&lt; 1,
    BLACK_OO  = WHITE_OO &lt;&lt; 2,
    BLACK_OOO = WHITE_OO &lt;&lt; 3,
  
    KING_SIDE      = WHITE_OO  | BLACK_OO,
    QUEEN_SIDE     = WHITE_OOO | BLACK_OOO,
    WHITE_CASTLING = WHITE_OO  | WHITE_OOO,
    BLACK_CASTLING = BLACK_OO  | BLACK_OOO,
    ANY_CASTLING   = WHITE_CASTLING | BLACK_CASTLING,
  
    CASTLING_RIGHT_NB = 16
  };
  </code></pre>
  <p><strong>What can I do to disable castling in moves and calculations of Stockfish?</strong></p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-07-04T01:21:52.797Z
Comments.Text: replace two lines with `BLACK_00 = 0, BLACK_000 = 0,` might work. Depends on how all the other code is written.
Comments.UserDisplayName: Aganju
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-07-04T03:15:52.410Z
Comments.Text: @Aganju This works, thank you! Could you please post your comment as an answer so that I can accept it?
Comments.UserDisplayName: Ritesh Singh
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-07-04T03:43:05.677Z
Comments.Text: Can you use an opening book that allows one side to castle, but not the other? E.g. 1. Nf3 Nf6 2. Rg1 Ng8 3. Rh1 Nf6 4. Ng1 Ng8 disables White kingside castling, but not Black, and the game starts from the opening position.
Comments.UserDisplayName: Allure
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-07-04T04:18:50.333Z
Comments.Text: @Allure Good idea, thank you!
Comments.UserDisplayName: Ritesh Singh
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-07-04T06:53:03.720Z
Comments.Text: You could just set the initial position from a FEN in which the castling rights have been removed from one side (that is, the usual starting position FEN but with KQkq changed to KQ or kq). This will give the correct move numbering (whereas Allure’s suggestion would number the first real move as move 5).
Comments.UserDisplayName: Stephen
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-07-04T14:44:48.223Z
Comments.Text: @Stephen That should probably be an answer.
Comments.UserDisplayName: D M
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-07-04T15:46:12.003Z
Comments.Text: @DM: OK, I’ve posted this as an answer now.
Comments.UserDisplayName: Stephen
Tags: <engines><stockfish><programming><computer-chess><castling>
Title: Compiling Stockfish to disable own castling while allowing opponent castling
ThreadText: # Compiling Stockfish to disable own castling while allowing opponent castling
  
  (Asked by: username_0 on 2020-07-04)
  
  For artistic purposes, I would like to create and study engine games in which only one side is able to castle.
  For this, I need to compile a version of Stockfish which never castles, and doesn't consider its own castling in its calculations, whereas calculates with castling for the opponent.
  I have gone through the types.h file and found the following:
  enum MoveType {
    NORMAL,
    PROMOTION = 1 << 14,
    ENPASSANT = 2 << 14,
    CASTLING  = 3 << 14
  };
  
  enum CastlingRights {
    NO_CASTLING,
    WHITE_OO,
    WHITE_OOO = WHITE_OO << 1,
    BLACK_OO  = WHITE_OO << 2,
    BLACK_OOO = WHITE_OO << 3,
  
    KING_SIDE      = WHITE_OO  | BLACK_OO,
    QUEEN_SIDE     = WHITE_OOO | BLACK_OOO,
    WHITE_CASTLING = WHITE_OO  | WHITE_OOO,
    BLACK_CASTLING = BLACK_OO  | BLACK_OOO,
    ANY_CASTLING   = WHITE_CASTLING | BLACK_CASTLING,
  
    CASTLING_RIGHT_NB = 16
  };
  
  What can I do to disable castling in moves and calculations of Stockfish?
  
  **Tags:** engines, stockfish, programming, computer-chess, castling
  
  > **Comments:**
  > **username_1**: replace two lines with `BLACK_00 = 0, BLACK_000 = 0,` might work. Depends on how all the other code is written.  
  > **username_0**: @username_1 This works, thank you! Could you please post your comment as an answer so that I can accept it?  
  > **username_2**: Can you use an opening book that allows one side to castle, but not the other? E.g. 1. Nf3 Nf6 2. Rg1 Ng8 3. Rh1 Nf6 4. Ng1 Ng8 disables White kingside castling, but not Black, and the game starts from the opening position.  
  > **username_0**: @username_2 Good idea, thank you!  
  > **username_3**: You could just set the initial position from a FEN in which the castling rights have been removed from one side (that is, the usual starting position FEN but with KQkq changed to KQ or kq). This will give the correct move numbering (whereas username_2’s suggestion would number the first real move as move 5).  
  > **username_4**: @username_3 That should probably be an answer.  
  > **username_3**: @DM: OK, I’ve posted this as an answer now.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_3 on 2020-07-04. Score: 10 | Accepted answer
  
  There is no need to compile your own version of Stockfish for this. Instead you can just start from a position that omits castling rights for one side or the other. The FEN for the initial position without castling rights for White is
  
  `rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w kq - 0 1`
  
  and the FEN for the initial position without castling rights for Black is
  
  `rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQ - 0 1`
  
  The FEN can be entered into Stockfish using the UCI command
  
  `position fen FEN`
  
  where `FEN` should be replaced by the FEN in question.
  
  > **Comments:**
  > **username_3**: Of course, this works for any UCI engine, not just Stockfish.  
  
  ---
  
  ### Answer by username_1 on 2020-07-04. Score: 2
  
  Without reviewing the complete code (which is probably humongous), it is difficult to give a proven right answer.
  
  However, it should work if you replace the lines for the black castling possibilities by `BLACK_00 = 0, BLACK_000 = 0,` (or respectively for the white, if you want). This should lead to all tests in the code returning 'black castling not possible', which is the intention.
  
  
  ---
  
  