i = 0: WriteChessManual = False '用来保存棋局信息
Open FileName For Output As #1
Do While i < SearchNode(PieceRec)
i = i + 1
tmpx = DToH(Val(IIf(PieceRec(i) Mod 15 = 0, 15, PieceRec(i) Mod 15))): tmpy = DToH(Val(IIf(PieceRec(i) \ 15 = 0, PieceRec(i) \ 15, PieceRec(i) \ 15 + 1)))
Print #1, tmpx; tmpy; IIf(i Mod 2 = 0, 2, 1)
Loop
Close #1 '关闭文件并将缓存中内容写到硬盘
WriteChessManual = True
End Function
与写棋谱函数对应,参数与写棋谱函数相同。
Public Function ReadChessManual(ByVal FileName As String, ByRef PieceTar() As Integer) As Boolean '用户取消或失败返回假
Dim i%, j%, S$, tmpx%, tmpy%, Flag As Byte: ReadChessManual = False
Open FileName For Input As #1
Do While Not EOF(1)
Line Input #1, S
For i = 1 To Len(S)
If Mid(S, i, 1) <> " " Then
j = j + 1
Select Case j
Case 1
tmpx = HToD(Mid(S, i, 1))
Case 2
tmpy = HToD(Mid(S, i, 1))
Case 3
Flag = HToD(Mid(S, i, 1))
End Select
End If
Next i
LayPiece Piece, tmpx, tmpy, Flag
DrawPiece Form1, tmpx, tmpy, Flag
j = 0
Loop
Close #1 '文件打开后要关闭以释放缓存
GameOrNot = True: ActiveDisp Form1.mnuModeAI, Form1.mnuModeDouble, AIOrNot
Form1.mnuFileEndCurrentGame.Enabled = True
ReadChessManual = True
End Function
|