欧拉 发表于 2020-6-6 16:44

有大佬搞一个飞扬版发阳论吗?

最近找出来大本头的《发阳论研究》翻看,打算提高一下,但总觉得字图都偏小,看一会儿眼睛就累了,也许是我近视加老花的缘故,不知道大家是否有这样的感受?如果群里大佬搞一个飞扬版发阳论,排版和字都放大点,估计会有销路的吧:lol

欧拉 发表于 2020-6-6 17:54

15年前倒是自己用 python 2.写过一个程序,能把 sgf 文件的问题图 转换成 txt 文本,源代码分享给大家,
现在 用 python 3. 了,有些地方要改一下才能运行了。

import dircache
from os import *

m = map(None, 'abcdefghijklmnopqrs', range(1,20))
m2 = map(None, 'srqponmlkjihgfedcba', range(1,20))

EMPTY_ROW=2
EMPTY_COL=3

def convert(sgfGame,txtGame,prb):
      # x="ab" pos0=1,pos1=2
      moveList=[]
      # black or white stone list
      i=0
      whoMove='B'
      while (i<len(sgfGame)):
              while not (sgfGame=='A' and ( sgfGame=='B' or sgfGame=='W') ):
                        i=i+1
                      if i >len(sgfGame)-2:
                              break
                if i >= len(sgfGame)-2:
                        break
                color=sgfGame       
              i=i+2
              while(i<len(sgfGame)-3 and sgfGame=='[' and sgfGame==']' ):
                      moveList.append(sgfGame+color)
                      i=i+4
                      if sgfGame=='\x0d':
                              i=i+2
                if i >= len(sgfGame)-3:
                        break            
      i=0
      while (i<len(sgfGame)-3 and sgfGame<>';B' and sgfGame<>';W' ):
              i=i+1
      if sgfGame=='B':
                whoMove='B'
        elif sgfGame=='W':
                whoMove='W'
        else:
                print('error'+sgfGame+':'+prb)
      i=0
      while (i<len(sgfGame)-3 and sgfGame<>'AE' ):
              i=i+1
      if sgfGame=='AE':
              print ('errorAE AE AE _______:'+prb)
      emptyRow=1
      emptyCol=1
        mset='none'
      pos0_sum=0
      pos1_sum=0
      pos_count=0
      for x in moveList:               
              pos0 = filter(lambda z, x=x: z==x, m)
              pos1 = filter(lambda z, x=x: z==x, m)
                pos0_sum=pos0_sum+pos0
                pos1_sum=pos1_sum+pos1
                pos_count=pos_count+1
        pos0_avg=pos0_sum/pos_count
        pos1_avg=pos1_sum/pos_count
        if pos1_avg<10:
              if pos0_avg<10:
                      mset='tl'
              else:
                      mset='tr'       
      else:
              if pos0_avg<10:
                      mset='dl'
              else:
                      mset='dr'       
               if mset=='dr':
                pos1_avg=20-pos1_avg
                       pos0_avg=20-pos0_avg
        if mset=='dl':
                       pos1_avg=20-pos1_avg
        if mset=='tr':
                       pos0_avg=20-pos0_avg
      for x in moveList:               
              pos0 = filter(lambda z, x=x: z==x, m)
              pos1 = filter(lambda z, x=x: z==x, m)
              if mset=='dr':
                      pos1=20-pos1
                      pos0=20-pos0
                if mset=='dl':
                      pos1=20-pos1
                if mset=='tr':
                      pos0=20-pos0
                if pos0_avg<pos1_avg:
                        posp=pos0
                        pos0=pos1
                        pos1=posp
              if pos1>emptyRow:
                      emptyRow=pos1
              if pos0>emptyCol:
                      emptyCol=pos0
              pos=((pos1-1)*20+pos0-1)*2
                if (x == 'B' and whoMove =='B') or (x == 'W' and whoMove =='W'):
                      stone='\xa1\xf1'
              elif (x == 'B' and whoMove =='W') or (x == 'W' and whoMove =='B'):
                      stone='\xa1\xf0'
                else:
                        print 'error!!!!!'                             
              t=txtGame+stone+txtGame
              txtGame=t
      return (txtGame,emptyRow,emptyCol)
      
dir=dircache.listdir('tlt/')
emptyGame=file("board.txt","rb")
emptyBoard=emptyGame.read()
txtFile=file("tlt.txt","w+b")
for x in dir:
        txtGame=emptyBoard
        string_x=str(x)       
        sgfFile=file("tlt/"+str(x),"rb")
        sgfGame=sgfFile.read()
        #txtGame=convert(sgfGame,txtGame)       
        (txtGame,emptyRow,emptyCol)=convert(sgfGame,txtGame,x)       
        endRow=9
        emptyCol=14       
        for i_row in range(0,endRow):
                end=emptyCol*2               
                # txtFile.write(txtGame)
                if i_row==endRow-1:
                        txtFile.write(txtGame+string_x)
                else:
                        txtFile.write(txtGame)                       
                txtFile.write('\x20\x0d\x0a')
        txtFile.write('\x0d\x0a')
               
        sgfFile.close()

txtFile.close()

傻瓜 发表于 2020-6-6 17:13

淑贞自己搞
搞完成大佬

choufengzi 发表于 2020-6-6 17:29

欧拉:lol

欧拉 发表于 2020-6-6 17:30

傻瓜 发表于 2020-6-6 17:13
淑贞自己搞
搞完成大佬

当大佬太累,还是当小弟省心:lol

肥虎 发表于 2020-6-6 17:40

从来就没有什么救世主,一切只能自己靠自己。:lol

libai888 发表于 2020-6-6 18:05

厉害

czh300 发表于 2020-6-6 19:14

头像暴露年龄!

傻瓜 发表于 2020-6-6 19:33

新人帖!

libai888 发表于 2020-6-6 19:57

话说淑贞当年实在是令人食欲大增。

libai888 发表于 2020-6-6 19:58

等待吴诗人搞个傻瓜版发扬论,不然坚决远离。

阿扬 发表于 2020-6-6 21:23

发扬轮工程太巨大了

十月雨丝 发表于 2020-6-6 21:53

高手。

熠熠生辉 发表于 2020-6-6 22:11

论实用性前田陈尔系列更好些

熠熠生辉 发表于 2020-6-6 22:14

记得有职业说发阳论做过几遍,就看想不想出书,可万一有漏。面子上下不来
页: [1] 2 3
查看完整版本: 有大佬搞一个飞扬版发阳论吗?