⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mathods.bas

📁 机器人程序
💻 BAS
字号:
Attribute VB_Name = "Mathods"
'Mathods.bas
'包含常用方法
'Contine Some Functions

'- - - - - - - - - - - - - - - - - - - - - - - - - -

'保存为 Sgf (Smart Go File)格式文件
Public Sub SaveSgfFile(ByVal fn As String)
  Dim i As Integer
  Open fn For Output As #2
  Print #2, "(;AP[GoRo围棋机器人:1.0.0]SZ[13];"
  For i = 1 To GNUGO_GetMoveNumber
    Print #2, SgfNode(i);
  Next
  Print #2, ")"
  Close #2
End Sub

'从Position.ini中读取信息
'Read Positions form txt file
Public Sub Read_Pos(shw As Boolean)
  Dim st, t As String
  Dim i, j, a, b As Integer
 
  Open App.Path & "\position.ini" For Input As #1
  
  st = ""
  t = "[640&13]"
  
  While st <> t
    If EOF(1) Then Close #1: Exit Sub
    Input #1, st
  Wend
  
  For i = 1 To BSize
    For j = 1 To BSize
      If EOF(1) Then
        Close #1
        Call MsgBox("The position file is wrong.", , "ERROR")
        Exit Sub
      End If
      Input #1, Pos(i, j).X, Pos(i, j).Y
      
      'When CamWidth is not 320
      'If CamWidth <> 320 Then
        Pos(i, j).X = Pos(i, j).X / kCam
        Pos(i, j).Y = Pos(i, j).Y / kCam
      'End If
      
      'If you want show them in LIST box
      If shw = True Then GRVBMain.List.AddItem "(" & str$(i) & "," & str$(j) & " ) -> (" & str$(Pos(i, j).X) & "," & str$(Pos(i, j).Y) & ")"
   Next j
  Next i
  
  Input #1, stdPWhite.X, stdPWhite.Y
  Input #1, stdPBlack.X, stdPBlack.Y
  Input #1, stdPNone.X, stdPNone.Y
  'set value & initialize

  Close #1
End Sub

'在ListBox中显示 State
'Show a list about the position of each point in GRVBMain.List box
Public Sub ListState()
  GRVBMain.List.AddItem "-----------------"
  GRVBMain.List.AddItem "Board Size =" & str$(BSize)
  For i = 1 To BSize
    For j = 1 To BSize
      GRVBMain.List.AddItem "(" & str$(i) & "," & str$(j) & "->" & str$(State(i, j)) & ")"
    Next
  Next
  
  GRVBMain.List.AddItem "-----------------"
End Sub

'在ListBox中显示信息
'Show something in ListBox
Public Sub ToList(ByVal words As String)
  GRVBMain.List.AddItem words
End Sub

'interface ,表达一个信息
Public Sub GRSpeak(ByVal words As String)
  If RobbyCanSee = False Then Exit Sub
  Robby.Speak words
End Sub

'数字转字符
Public Function PosStr(ByVal numx As Integer, ByVal numy As Integer) As String
  If numy > 10 Then
    PosStr = Chr$(numx + 64) & str$(numy)
  Else
    PosStr = Chr$(numx + 64) & str$(numy)
  End If
End Function

'计算分数
Public Sub CalcScore()
  Dim s As Single
  Dim str As String
  
  s = GNUGO_EstimateScore
  
  If (s > 0) Then
    str = "黑胜"
  Else
    str = "白胜"
  End If
  
  GRSpeak str & Abs(s) & "子"
End Sub


'- - - - - - - - - - - - - - - - - - - - - - - - - -

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -