Answers.Body: <p>Although one may try to place the first row as the eighth, the second row as the seventh, etc., the board will appear flipped (as shown above).</p>
  
  <p>This is a horizontal flip (mirror-image over the x-axis) and does not look quite right. Switching the letters from lower-case to capital and vice-versa would switch the colors, but that's not the best solution. </p>
  
  <p>Upon closer examination, a vertical flip (or mirror over the y-axis) of this horizontal flip would solve the problem: Reverse each sub-string delimited by a slash until you hit the second field, then leave it as is.</p>
  
  <p><strong>The final product is the same FEN, except the first field is a reverse string of itself.</strong></p>
  
  <pre><code># r4rk1/p3ppbp/2n3p1/8/3q2n1/N1N5/PPQ2PPP/R1B1K2R w KQkq - 0 1
  </code></pre>
  
  <p>Board:</p>
  
  <pre><code>r4rk1/p3ppbp/2n3p1/8/3q2n1/N1N5/PPQ2PPP/R1B1K2R w KQkq - 0 1
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-10-16T02:19:41.517Z
Answers.LastActivityDate: 2017-10-16T02:19:41.517Z
Answers.UserDisplayName: Jossie Calderon
Answers.Body: <p>The free chess GUI Arena does what you are asking and many other useful things for creating or studying chess problems.</p>
  
  <p>It works with epd files, fen strings and pgn databases.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-10-16T20:14:24.227Z
Answers.LastActivityDate: 2017-10-16T20:14:24.227Z
Answers.UserDisplayName: Jess Ortiz
Answers.Body: <p>I disagree with Jossie's solution.  If you follow that method, and flip the initial game board, you'd end up with queens on the wrong colors.  Doing a vertical flip and switching the colors is the method I use.  </p>
  
  <p>Detailed efficient methods of performing these board flips (as well as rotations) can be found <a href="https://chessprogramming.wikispaces.com/Flipping+Mirroring+and+Rotating" rel="nofollow noreferrer">here</a>.</p>
  
  <p>UPDATE:
  As Jossie has since pointed out, his solution is correct for the question asked.  My solution is for when you need to transform a board (oriented with white at the bottom and black at the top) in which it's black's turn, to one in the same orientation, but seen as if it was white's turn.  An example of when you'd use my solution is converting a database of boards to one where they're all being represented with the same orientation, and same player to move.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-20T19:44:06.167Z
Answers.Text: The queens are on the right colors (black queen on e1, white queen on e8). Doing a vertical flip (white queen is now on e1) and then switching the colors (black queen on e1) is exactly what my solution does.
Answers.UserDisplayName: Jossie Calderon
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-21T17:53:50.930Z
Answers.Text: Ah, I see now that the question was not to change the board to one where it was the perspective of black's turn to the perspective of white's turn, but instead literally flip where the pieces are located.     My solution is for making a board where it appears as blacks turn (with the pieces in the correct locations), to a board where it appears to be white's turn.
Answers.UserDisplayName: Sam Ragusa
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-05-19T13:01:03.693Z
Answers.LastActivityDate: 2018-05-21T20:43:13.540Z
Answers.LastEditDate: 2018-05-21T20:43:13.540Z
Answers.UserDisplayName: Sam Ragusa
Answers.Body: <p>If (and only if) you need such a tool constantly, consider writing a Python snippet. This one (just an example) I did in five minutes. It only switches the right to move. It is neither debugged nor optimized! Honk and I add subroutines for switching board (horizontal or vertical) and switching colors, and I edit this post.</p>
  <pre><code>flong=&quot;R2K1B1R/PPP2QPP/5N1N/1n2q3/8/1p3n2/pbpp3p/1kr4r w KQkq - 0 1&quot;
  fshort=&quot;R2K1B1R/PPP2QPP/5N1N/1n2q3/8/1p3n2/pbpp3p/1kr4r&quot;
  fbad=&quot;T2K1L1T/BBB2DBB/5S1S/1s2d3/8/1b3s2/blbb3b/1kt4t s KDkd - 0 1&quot;
  
  def righttomove(fen):
      # locate first blank, add 1
      try:
          loc = fen.index(&quot; &quot;)+1
          char = fen[loc]
          if char == &quot;w&quot;:
              char2 = &quot;b&quot;
          elif char == &quot;b&quot;:
              char2 = &quot;w&quot;
          else:
              print(&quot;Malformed FEN&quot;)
          fen2 = fen[:loc]+char2+fen[loc+1:]
          print(fen2)
      except:
          print(&quot;Can't do, short FEN&quot;)
  
  print(&quot;LONG&quot;)
  righttomove(flong)
  print(&quot;SHORT&quot;)
  righttomove(fshort)
  print(&quot;BAD&quot;)
  righttomove(fbad)
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-12-07T09:55:04.670Z
Answers.LastActivityDate: 2024-12-07T09:55:04.670Z
Answers.UserDisplayName: Hauke Reddmann
Body: <p>This board shows the black pieces on the bottom, but the white pieces are supposed to be there; I accidentally set up the board so that white's pieces are on the black side. I am looking to flip the board with the following FEN:</p>
  
  <pre><code># R2K1B1R/PPP2QPP/5N1N/1n2q3/8/1p3n2/pbpp3p/1kr4r w KQkq - 0 1
  </code></pre>
  
  <p>Board:</p>
  
  <pre><code>R2K1B1R/PPP2QPP/5N1N/1n2q3/8/1p3n2/pbpp3p/1kr4r w KQkq - 0 1
  </code></pre>
  
  <p>How may I accomplish this without re-setting the pieces manually? I tried switching the rows, but I got:</p>
  
  <pre><code># 1kr4r/pbpp3p/1p3n2/8/1n2q3/5N1N/PPP2QPP/R2K1B1R w KQkq - 0 1
  </code></pre>
  
  <p>Board:</p>
  
  <pre><code>1kr4r/pbpp3p/1p3n2/8/1n2q3/5N1N/PPP2QPP/R2K1B1R w KQkq - 0 1
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-10-18T13:04:15.107Z
Comments.Text: Unless you accidentally switch black and white pieces on a regular basis, this seems like a.problem which takes much longer to "automate" than to just solve it manually this one time.
Comments.UserDisplayName: TMM
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-05-21T22:54:28.350Z
Comments.Text: Switch the rows and then switch the columns, or vice versa.
Comments.UserDisplayName: Wais Kamal
Tags: <programming><fen><mathematics>
Title: FEN inverter website/page?
ThreadText: # FEN inverter website/page?
  
  (Asked by: username_0 on 2017-10-16)
  
  This board shows the black pieces on the bottom, but the white pieces are supposed to be there; I accidentally set up the board so that white's pieces are on the black side. I am looking to flip the board with the following FEN:
  
  ```
  # R2K1B1R/PPP2QPP/5N1N/1n2q3/8/1p3n2/pbpp3p/1kr4r w KQkq - 0 1
  
  ```
  
  Board:
  
  ```
  R2K1B1R/PPP2QPP/5N1N/1n2q3/8/1p3n2/pbpp3p/1kr4r w KQkq - 0 1
  
  ```
  
  How may I accomplish this without re-setting the pieces manually? I tried switching the rows, but I got:
  
  ```
  # 1kr4r/pbpp3p/1p3n2/8/1n2q3/5N1N/PPP2QPP/R2K1B1R w KQkq - 0 1
  
  ```
  
  Board:
  
  ```
  1kr4r/pbpp3p/1p3n2/8/1n2q3/5N1N/PPP2QPP/R2K1B1R w KQkq - 0 1
  
  ```
  
  **Tags:** programming, fen, mathematics
  
  > **Comments:**
  > **username_1**: Unless you accidentally switch black and white pieces on a regular basis, this seems like a.problem which takes much longer to "automate" than to just solve it manually this one time.  
  > **username_2**: Switch the rows and then switch the columns, or vice versa.  
  
  ---
  
  ## 4 answers
  
  ### Answer by username_0 on 2017-10-16. Score: 3
  
  Although one may try to place the first row as the eighth, the second row as the seventh, etc., the board will appear flipped (as shown above).
  
  This is a horizontal flip (mirror-image over the x-axis) and does not look quite right. Switching the letters from lower-case to capital and vice-versa would switch the colors, but that's not the best solution.
  
  Upon closer examination, a vertical flip (or mirror over the y-axis) of this horizontal flip would solve the problem: Reverse each sub-string delimited by a slash until you hit the second field, then leave it as is.
  
  **The final product is the same FEN, except the first field is a reverse string of itself.**
  
  ```
  # r4rk1/p3ppbp/2n3p1/8/3q2n1/N1N5/PPQ2PPP/R1B1K2R w KQkq - 0 1
  
  ```
  
  Board:
  
  ```
  r4rk1/p3ppbp/2n3p1/8/3q2n1/N1N5/PPQ2PPP/R1B1K2R w KQkq - 0 1
  
  ```
  
  
  ---
  
  ### Answer by username_3 on 2017-10-16. Score: 2
  
  The free chess GUI Arena does what you are asking and many other useful things for creating or studying chess problems.
  
  It works with epd files, fen strings and pgn databases.
  
  
  ---
  
  ### Answer by username_4 on 2018-05-19. Score: 1
  
  I disagree with username_0's solution. If you follow that method, and flip the initial game board, you'd end up with queens on the wrong colors. Doing a vertical flip and switching the colors is the method I use.
  
  Detailed efficient methods of performing these board flips (as well as rotations) can be found [here](https://chessprogramming.wikispaces.com/Flipping+Mirroring+and+Rotating).
  
  UPDATE:
  As username_0 has since pointed out, his solution is correct for the question asked. My solution is for when you need to transform a board (oriented with white at the bottom and black at the top) in which it's black's turn, to one in the same orientation, but seen as if it was white's turn. An example of when you'd use my solution is converting a database of boards to one where they're all being represented with the same orientation, and same player to move.
  
  > **Comments:**
  > **username_0**: The queens are on the right colors (black queen on e1, white queen on e8). Doing a vertical flip (white queen is now on e1) and then switching the colors (black queen on e1) is exactly what my solution does.  
  > **username_4**: Ah, I see now that the question was not to change the board to one where it was the perspective of black's turn to the perspective of white's turn, but instead literally flip where the pieces are located.     My solution is for making a board where it appears as blacks turn (with the pieces in the correct locations), to a board where it appears to be white's turn.  
  
  ---
  
  ### Answer by username_5 on 2024-12-07. Score: 0
  
  If (and only if) you need such a tool constantly, consider writing a Python snippet. This one (just an example) I did in five minutes. It only switches the right to move. It is neither debugged nor optimized! Honk and I add subroutines for switching board (horizontal or vertical) and switching colors, and I edit this post.
  
  ```
  flong="R2K1B1R/PPP2QPP/5N1N/1n2q3/8/1p3n2/pbpp3p/1kr4r w KQkq - 0 1"
  fshort="R2K1B1R/PPP2QPP/5N1N/1n2q3/8/1p3n2/pbpp3p/1kr4r"
  fbad="T2K1L1T/BBB2DBB/5S1S/1s2d3/8/1b3s2/blbb3b/1kt4t s KDkd - 0 1"
  
  def righttomove(fen):
      # locate first blank, add 1
      try:
          loc = fen.index(" ")+1
          char = fen[loc]
          if char == "w":
              char2 = "b"
          elif char == "b":
              char2 = "w"
          else:
              print("Malformed FEN")
          fen2 = fen[:loc]+char2+fen[loc+1:]
          print(fen2)
      except:
          print("Can't do, short FEN")
  
  print("LONG")
  righttomove(flong)
  print("SHORT")
  righttomove(fshort)
  print("BAD")
  righttomove(fbad)
  
  ```
  
  
  ---
  
  