title: Is there a way to convert a python chess board into a list of integers?
body: <p>I am trying to create a neural network to play chess, but first, I need to convert the chess board to a list of integers. I am using the <a href="https://pypi.org/project/python-chess/" rel="nofollow noreferrer">python-chess</a> module for the chess board and game. I currently have a chess board class, but cannot find a method to convert it into a list.</p>
  
  <p>I have tried to use the <code>chess_board.epd()</code> method, but that returns a formatting scheme that is hard to convert.</p>
  
  <p>Here is the code that I need:</p>
  
  <pre class="lang-py prettyprint-override"><code>board = chess.Board()  # Define board object
  board.convert_to_int()  # Method I need
  </code></pre>
  
  <p>Right now, with the <code>.epd()</code> method I get <code>"rnbqkbnr/pppppppp/8/8/8/5P2/PPPPP1PP/RNBQKBNR b KQkq -"</code></p>
  
  <p>As you can see, it is very difficult to parse and convert to a list of integers as there are <code>/8/</code>'s and <code>/5P2/</code>.</p>
  
  <p>The expected output is something like this (goes row by row):</p>
  
  <p><code>[4, 2, 3, 5, 6, 3, 2, 4, 1, 1, 1, 1, 1, 1, 1, 1, ... -1, -1, -1, -1,-1, -1,-1, -1, -4, -2, -3, -5, -6, -3, -2, -4]</code></p>
  
  <p>For example, these can be what integers map to the peices:</p>
  
  <pre><code>pawn - 1
  knight - 2
  bishop - 3
  rook - 4
  queen - 5
  king - 6
  </code></pre>
  
  <p>And white can be positive integers and black can be negative integers.</p>