欧卡2中文社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

需要三步,才能开始

只需两步,慢速开始

玩欧卡就用莱仕达V10方向盘欧卡2入门方向盘选莱仕达V9莱仕达折叠便携游戏方向盘支架欢迎地图Mod入驻
查看: 5466|回复: 0
收起左侧

qq游戏中的围棋格式wgs格式到sgf通用格式的转换

[复制链接]
起名字最烦了 发表于 2012-7-13 00:02 | 显示全部楼层 |阅读模式
目前因为没有安装vb,所以是在excel中弄的。打开excel,按Alt + F11进入vb编辑器,双击左边的thisworkbook,在右边的空白处粘贴下面的代码,改路径,然后F5,或者一直F8,运行完成(提示success to transform)。文件保存在D:\23Out.sgf。在xp,office2003下成功运行。

代码如下:

'实现qq围棋的wgs格式转为sgf通用格式可以被multigo3.5打开
'还存在一个问题:如果最后一手是黑下,那么将不转换最后一手,有空再改
'sgf的前后竟然有引号,不过也可以被打开,呵呵
Sub ReadWgs()
Dim fileName As String
Dim outputName As String
Dim allWgsContent() As Byte '用来读取文件的数组,每次读取前要重定义
Dim outputContent As String

fileName = "D:\test.wgs"   '被转换的wgs文件
outputName = "D:\23Out.sgf"   '生成的sgf文件
outputC

Open fileName For Binary As #2
Open outputName For Output As #1

ReDim allWgsContent(LOF(2) - 1) '重定义数组,为读取文件做准备
Get #2, , allWgsContent() 'allWgsContent(120)=23,总手数
For i = 122 To LOF(2) - 4 Step 4

       Dim bX As String '水平的x,向右为正,单位为4Deg black
       Dim bY As String '垂直的y,向下为正,单位为1Deg
       Dim wX As String 'white
       Dim wY As String
       Dim tempbwXY As String
   
       bX = Chr(Int(allWgsContent(i)) / 4 + 97)
       bY = Chr(Int(allWgsContent(i + 1)) + 97)
       wX = Chr(Int(allWgsContent(i + 2)) / 4 + 97)
       wY = Chr(Int(allWgsContent(i + 3)) + 97)
       tempbwXY = " ;B[" & bX & bY & "] ;W[" & wX & wY & "]"
       outputContent = outputContent & tempbwXY
   
Next i

outputContent = outputContent & ")"
Write #1, outputContent

Close #2
Close #1

MsgBox ("success to tranform")

End Sub

联系我们|手机版|欧卡2中国 ( 湘ICP备11020288号-1 )

GMT+8, 2024-4-19 18:39 , Processed in 0.047444 second(s), 10 queries , Redis On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表