2003-08-22 09:44:59 +00:00
|
|
|
# file fen2ascii.py
|
|
|
|
# This file is part of LyX, the document processor.
|
|
|
|
# Licence details can be found in the file COPYING.
|
|
|
|
|
|
|
|
# author Kayvan A. Sylvan
|
|
|
|
|
|
|
|
# Full author contact details are available in file CREDITS.
|
|
|
|
|
2001-10-31 15:19:49 +00:00
|
|
|
# This script will convert a chess position in the FEN
|
|
|
|
# format to an ascii representation of the position.
|
|
|
|
|
2007-01-10 04:24:36 +00:00
|
|
|
import sys,string,os
|
2001-10-31 15:19:49 +00:00
|
|
|
|
|
|
|
os.close(0)
|
|
|
|
os.close(1)
|
2024-06-10 10:29:56 +00:00
|
|
|
sys.stdin = open(sys.argv[1])
|
2007-01-10 04:24:36 +00:00
|
|
|
sys.stdout = open(sys.argv[2],"w")
|
2001-10-31 15:19:49 +00:00
|
|
|
|
|
|
|
line = sys.stdin.readline()
|
|
|
|
if line[-1] == '\n':
|
|
|
|
line = line[:-1]
|
|
|
|
|
|
|
|
line=string.split(line,' ')[0]
|
|
|
|
comp=string.split(line,'/')
|
|
|
|
|
|
|
|
cont=1
|
|
|
|
margin= " "*6
|
|
|
|
|
2018-04-28 09:51:35 +00:00
|
|
|
print (margin+' +'+"-"*15+'+')
|
2001-10-31 15:19:49 +00:00
|
|
|
for i in range(8):
|
|
|
|
cont = cont + 1
|
|
|
|
tmp=""
|
|
|
|
for j in comp[i]:
|
2016-07-31 03:17:30 +00:00
|
|
|
if j>='0' and j <= '9':
|
|
|
|
for k in range(int(j)):
|
|
|
|
cont = cont + 1
|
|
|
|
x, mod = divmod(cont,2)
|
|
|
|
if mod : tmp = tmp + '| '
|
|
|
|
else : tmp = tmp + '|*'
|
|
|
|
else :
|
|
|
|
tmp = tmp + '|' + j
|
|
|
|
cont = cont + 1
|
2001-10-31 15:19:49 +00:00
|
|
|
|
|
|
|
row = 8 - i
|
2018-04-28 09:51:35 +00:00
|
|
|
print (margin, row, tmp+"|")
|
2001-10-31 15:19:49 +00:00
|
|
|
|
2018-04-28 09:51:35 +00:00
|
|
|
print (margin+' +'+"-"*15+'+')
|
|
|
|
print (margin+' a b c d e f g h ')
|