<p>将您的表示转换为标准表示并不困难。例如,可以使用如下函数将其转换为FEN:</p>
<pre><code>import io
def board_to_fen(board):
# Use StringIO to build string more efficiently than concatenating
with io.StringIO() as s:
for row in board:
empty = 0
for cell in row:
c = cell[0]
if c in ('w', 'b'):
if empty > 0:
s.write(str(empty))
empty = 0
s.write(cell[1].upper() if c == 'w' else cell[1].lower())
else:
empty += 1
if empty > 0:
s.write(str(empty))
s.write('/')
# Move one position back to overwrite last '/'
s.seek(s.tell() - 1)
# If you do not have the additional information choose what to put
s.write(' w KQkq - 0 1')
return s.getvalue()
</code></pre>
<p>在一些线路板数据上进行测试:</p>
^{pr2}$
<p>在<a href="https://www.chess.com/analysis" rel="nofollow noreferrer">Chess.com</a>中可视化分字符串会产生:</p>
<p><a href="https://i.stack.imgur.com/Ac420.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ac420.png" alt="Board"/></a></p>