VB.net 自编围棋程序
vb.net吧
全部回复
仅看楼主
level 3
script_1934 楼主
发个截图,和我爸下的:
2012年07月12日 03点07分 1
level 3
script_1934 楼主
我是白的,我爸是黑的,我边角上的多,应该是我赢了,废话少说,发源代码。
2012年07月12日 03点07分 2
level 3
script_1934 楼主
添加一个模块,命名为WeiqiModule.vb,然后添加如下代码:
Module WeiqiModule
Public Structure Weiqi
Dim X, Y As Byte
Dim IsBlack As Boolean
End Structure
Public Structure WeiqiHistory
Dim X() As String 'X为X(18)
Dim Y() As String
Dim IsBlack As Boolean
End Structure Public QiPan As Graphics '创建棋盘画布
Public QiKuan, BianKuan, ShouShu As Integer '定义每个棋格和边界的宽度,手数
Public myPen As Pen '钢笔
Public myBrush As Brush '刷子
Public QiJu(18, 18) As String '定义堆集
Public YesNo, IsBlack, isDiYiCi, isLive As Boolean '是否最大化,下棋的颜色,是不是第一次测量是否有气
Public XuanZi() As Weiqi '选中要去的死子
Public Jie, ShunXuQiZi() As Weiqi '劫,顺序
Public JieIs As Boolean '是否为劫
Public img As Image
Public SiZi() As String
Public QijuH(,,) As String ' Dim WeiqiFile As New FileInfo("E:\abc.txt")
' Dim WeiqiStream As FileStream
' If Not WeiqiFile.Exists Then
'WeiqiStream = WeiqiFile.Create
' WeiqiStream.Close()
' Exit Sub
' End If
' If WeiqiFile.Length = 0 Then
' MsgBox("没有内容,请输入内容")
' Exit Sub
' End If
'
' WeiqiStream = WeiqiFile.Open(FileMode.Open)
' Dim WeiqiReader As New StreamReader(WeiqiStream, System.Text.Encoding.Default)
' Try
'
' '
' Dim Ws As String
' Dim i, j As Byte
' Dim X1, Y1 As Byte
' ReDim ShunXuQiZi(0)
' Ws = WeiqiReader.ReadLine
'
' For i = 0 To 18
' For j = 0 To 18
'If QiJu(i, j) <> "N" Then
'QiJu(i, j) = "N"
' Call ClsQiZi(i, j)
' End If
' Next j
' Next i
' i = Ws.Length / 5
' ShouShu = i
'
' For j = 1 To i
' X1 = Val(Ws.Chars(j * 5 - 4)) * 10 + Val(Ws.Chars(j * 5 - 3))
' Y1 = Val(Ws.Chars(j * 5 - 2)) * 10 + Val(Ws.Chars(j * 5 - 1))
' QiJu(X1, Y1) = Ws.Chars(j * 5 - 5)
' If Ws.Chars(j * 5 - 5) = "B" Then
' IsBlack = True
' Else : IsBlack = False
' End If
' ReDim Preserve ShunXuQiZi(UBound(ShunXuQiZi) + 1)
' With ShunXuQiZi(UBound(ShunXuQiZi))
' .IsBlack = IsBlack : .X = X1 : .Y = Y1 ' End With
' Call DrawQiZi(IsBlack, X1, Y1, QiPan)
' Next ' WeiqiStream.Close()
' WeiqiReader.Close()
' Catch ex As Exception
'MsgBox(ex.Message.ToString & Chr(13) & Chr(13) & "(产生原因:文件损坏),请修复文件。")
' Dim i, j As Byte ' For i = 0 To 18
'For j = 0 To 18
'If QiJu(i, j) <> "N" Then
'QiJu(i, j) = "N"
' Call ClsQiZi(i, j)
' End If
'
'
' Next j
' Next i
' WeiqiStream.Close()
' WeiqiReader.Close()
' End Try End Module

2012年07月12日 03点07分 3
level 3
script_1934 楼主
楼上末尾少了"End Module"
在工程的属性中添加两个图片文件分别为"black.png"和"white.png"。
图片:


2012年07月12日 03点07分 4
level 3
script_1934 楼主
Me.PanelRight.SuspendLayout()
Me.ToolStrip1.SuspendLayout()
Me.WeiqiStatusStrip.SuspendLayout()
Me.SuspendLayout()
'
'SplitterRight
'
Me.SplitterRight.Dock = System.Windows.Forms.DockStyle.Right
Me.SplitterRight.Location = New System.Drawing.Point(663, 0)
Me.SplitterRight.Name = "SplitterRight"
Me.SplitterRight.Size = New System.Drawing.Size(3, 413)
Me.SplitterRight.TabIndex = 3
Me.SplitterRight.TabStop = False
'
'SplitterLeft
'
Me.SplitterLeft.Location = New System.Drawing.Point(0, 0)
Me.SplitterLeft.Name = "SplitterLeft"
Me.SplitterLeft.Size = New System.Drawing.Size(3, 413)
Me.SplitterLeft.TabIndex = 1
Me.SplitterLeft.TabStop = False
'
'WeiqiToolStripContainer
'
'
'WeiqiToolStripContainer.ContentPanel
'
Me.WeiqiToolStripContainer.ContentPanel.AutoScroll = True
Me.WeiqiToolStripContainer.ContentPanel.Controls.Add(Me.PanelMain)
Me.WeiqiToolStripContainer.ContentPanel.Controls.Add(Me.SplitterRight)
Me.WeiqiToolStripContainer.ContentPanel.Controls.Add(Me.PanelRight)
Me.WeiqiToolStripContainer.ContentPanel.Controls.Add(Me.SplitterLeft)
Me.WeiqiToolStripContainer.ContentPanel.Size = New System.Drawing.Size(880, 413)
Me.WeiqiToolStripContainer.Dock = System.Windows.Forms.DockStyle.Fill
Me.WeiqiToolStripContainer.Location = New System.Drawing.Point(0, 0)
Me.WeiqiToolStripContainer.Name = "WeiqiToolStripContainer"
Me.WeiqiToolStripContainer.Size = New System.Drawing.Size(880, 438)
Me.WeiqiToolStripContainer.TabIndex = 3
Me.WeiqiToolStripContainer.Text = "ToolStripContainer1"
'
'WeiqiToolStripContainer.TopToolStripPanel
'
Me.WeiqiToolStripContainer.TopToolStripPanel.Controls.Add(Me.WeiqiMainToolStrip)
Me.WeiqiToolStripContainer.TopToolStripPanel.Controls.Add(Me.ToolStrip1)
'
'WeiqiMainToolStrip
'
Me.WeiqiMainToolStrip.Dock = System.Windows.Forms.DockStyle.None
Me.WeiqiMainToolStrip.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.打开DToolStripButton, Me.保存BToolStripButton})
Me.WeiqiMainToolStrip.Location = New System.Drawing.Point(3, 0)
Me.WeiqiMainToolStrip.Name = "WeiqiMainToolStrip"
Me.WeiqiMainToolStrip.Size = New System.Drawing.Size(149, 25)
Me.WeiqiMainToolStrip.TabIndex = 1
'
'打开DToolStripButton
'
Me.打开DToolStripButton.Image = CType(resources.GetObject("打开DToolStripButton.Image"), System.Drawing.Image)
Me.打开DToolStripButton.ImageTransparentColor = System.Drawing.Color.Magenta
Me.打开DToolStripButton.Name = "打开DToolStripButton"

2012年07月12日 03点07分 6
level 3
script_1934 楼主
Me.打开DToolStripButton.Size = New System.Drawing.Size(69, 22)
Me.打开DToolStripButton.Text = "打开(&D)"
'
'保存BToolStripButton
'
Me.保存BToolStripButton.Image = CType(resources.GetObject("保存BToolStripButton.Image"), System.Drawing.Image)
Me.保存BToolStripButton.ImageTransparentColor = System.Drawing.Color.Magenta
Me.保存BToolStripButton.Name = "保存BToolStripButton"
Me.保存BToolStripButton.Size = New System.Drawing.Size(68, 22)
Me.保存BToolStripButton.Text = "保存(&B)"
'
'PanelMain
'
Me.PanelMain.BackColor = System.Drawing.SystemColors.GradientInactiveCaption
Me.PanelMain.Controls.Add(Me.QiPanPic)
Me.PanelMain.Dock = System.Windows.Forms.DockStyle.Fill
Me.PanelMain.Location = New System.Drawing.Point(3, 0)
Me.PanelMain.Name = "PanelMain"
Me.PanelMain.Size = New System.Drawing.Size(660, 413)
Me.PanelMain.TabIndex = 4
'
'QiPanPic
'
Me.QiPanPic.BackColor = System.Drawing.SystemColors.Window
Me.QiPanPic.Location = New System.Drawing.Point(102, 94)
Me.QiPanPic.Name = "QiPanPic"
Me.QiPanPic.Size = New System.Drawing.Size(328, 242)
Me.QiPanPic.TabIndex = 0
Me.QiPanPic.TabStop = False
'
'PanelRight
'
Me.PanelRight.BackColor = System.Drawing.SystemColors.GradientInactiveCaption
Me.PanelRight.Controls.Add(Me.WeiqiTreeView)
Me.PanelRight.Dock = System.Windows.Forms.DockStyle.Right
Me.PanelRight.Location = New System.Drawing.Point(666, 0)
Me.PanelRight.Name = "PanelRight"
Me.PanelRight.Size = New System.Drawing.Size(214, 413)
Me.PanelRight.TabIndex = 2
'
'WeiqiTreeView
'
Me.WeiqiTreeView.Dock = System.Windows.Forms.DockStyle.Fill
Me.WeiqiTreeView.ImageIndex = 0
Me.WeiqiTreeView.ImageList = Me.WeiqiImageList
Me.WeiqiTreeView.Location = New System.Drawing.Point(0, 0)
Me.WeiqiTreeView.Name = "WeiqiTreeView"
TreeNode1.ImageIndex = 2
TreeNode1.Name = "棋局"
TreeNode1.SelectedImageIndex = 2
TreeNode1.Text = "棋局"
Me.WeiqiTreeView.Nodes.AddRange(New System.Windows.Forms.TreeNode() {TreeNode1})
Me.WeiqiTreeView.SelectedImageIndex = 0
Me.WeiqiTreeView.ShowRootLines = False
Me.WeiqiTreeView.Size = New System.Drawing.Size(214, 413)
Me.WeiqiTreeView.TabIndex = 2
'
'WeiqiImageList
'
Me.WeiqiImageList.ImageStream = CType(resources.GetObject("WeiqiImageList.ImageStream"), System.Windows.Forms.ImageListStreamer)
Me.WeiqiImageList.TransparentColor = System.Drawing.Color.Transparent
Me.WeiqiImageList.Images.SetKeyName(0, "black.png")

2012年07月12日 03点07分 7
level 3
script_1934 楼主
Me.WeiqiImageList.Images.SetKeyName(1, "white.png")
'
'ToolStrip1
'
Me.ToolStrip1.Dock = System.Windows.Forms.DockStyle.None
Me.ToolStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.前一步QToolStripButton, Me.后一步HToolStripButton})
Me.ToolStrip1.Location = New System.Drawing.Point(153, 0)
Me.ToolStrip1.Name = "ToolStrip1"
Me.ToolStrip1.Size = New System.Drawing.Size(178, 25)
Me.ToolStrip1.TabIndex = 1
'
'前一步QToolStripButton
'
Me.前一步QToolStripButton.Image = CType(resources.GetObject("前一步QToolStripButton.Image"), System.Drawing.Image)
Me.前一步QToolStripButton.ImageTransparentColor = System.Drawing.Color.Magenta
Me.前一步QToolStripButton.Name = "前一步QToolStripButton"
Me.前一步QToolStripButton.Size = New System.Drawing.Size(83, 22)
Me.前一步QToolStripButton.Text = "前一步(&Q)"
'
'后一步HToolStripButton
'
Me.后一步HToolStripButton.Image = CType(resources.GetObject("后一步HToolStripButton.Image"), System.Drawing.Image)
Me.后一步HToolStripButton.ImageTransparentColor = System.Drawing.Color.Magenta
Me.后一步HToolStripButton.Name = "后一步HToolStripButton"
Me.后一步HToolStripButton.Size = New System.Drawing.Size(83, 22)
Me.后一步HToolStripButton.Text = "后一步(&H)"
'
'WeiqiStatusStrip
'
Me.WeiqiStatusStrip.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.ToolStripStatusLabel1, Me.ToolStripStatusLabel3, Me.ToolStripSplitButton1})
Me.WeiqiStatusStrip.Location = New System.Drawing.Point(0, 438)
Me.WeiqiStatusStrip.Name = "WeiqiStatusStrip"
Me.WeiqiStatusStrip.Size = New System.Drawing.Size(880, 24)
Me.WeiqiStatusStrip.TabIndex = 4
Me.WeiqiStatusStrip.Text = "WeiqiStatusStrip"
'
'ToolStripStatusLabel1
'
Me.ToolStripStatusLabel1.BorderSides = System.Windows.Forms.ToolStripStatusLabelBorderSides.Right
Me.ToolStripStatusLabel1.Name = "ToolStripStatusLabel1"
Me.ToolStripStatusLabel1.Size = New System.Drawing.Size(788, 19)
Me.ToolStripStatusLabel1.Spring = True
Me.ToolStripStatusLabel1.Text = "欢迎使用 Weighty Weiqi 5.0 (中文版)"
Me.ToolStripStatusLabel1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
'
'ToolStripSplitButton1
'
Me.ToolStripSplitButton1.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image
Me.ToolStripSplitButton1.Image = CType(resources.GetObject("ToolStripSplitButton1.Image"), System.Drawing.Image)
Me.ToolStripSplitButton1.ImageTransparentColor = System.Drawing.Color.Magenta
Me.ToolStripSplitButton1.Name = "ToolStripSplitButton1"
Me.ToolStripSplitButton1.Size = New System.Drawing.Size(32, 22)

2012年07月12日 03点07分 8
level 3
script_1934 楼主
Me.ToolStripSplitButton1.Text = "ToolStripSplitButton1"
'
'ToolStripStatusLabel3
'
Me.ToolStripStatusLabel3.BorderSides = System.Windows.Forms.ToolStripStatusLabelBorderSides.Right
Me.ToolStripStatusLabel3.Name = "ToolStripStatusLabel3"
Me.ToolStripStatusLabel3.Size = New System.Drawing.Size(45, 19)
Me.ToolStripStatusLabel3.Text = "Label3"
'
'WeiqiMain
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(880, 462)
Me.Controls.Add(Me.WeiqiToolStripContainer)
Me.Controls.Add(Me.WeiqiStatusStrip)
Me.Name = "WeiqiMain"
Me.Text = "E:\THINGS\程序\Weighty Weiqi 5.0\Weighty Weiqi 5.0\WeiqiMain.vb"
Me.WeiqiToolStripContainer.ContentPanel.ResumeLayout(False)
Me.WeiqiToolStripContainer.TopToolStripPanel.ResumeLayout(False)
Me.WeiqiToolStripContainer.TopToolStripPanel.PerformLayout()
Me.WeiqiToolStripContainer.ResumeLayout(False)
Me.WeiqiToolStripContainer.PerformLayout()
Me.WeiqiMainToolStrip.ResumeLayout(False)
Me.WeiqiMainToolStrip.PerformLayout()
Me.PanelMain.ResumeLayout(False)
CType(Me.QiPanPic, System.ComponentModel.ISupportInitialize).EndInit()
Me.PanelRight.ResumeLayout(False)
Me.ToolStrip1.ResumeLayout(False)
Me.ToolStrip1.PerformLayout()
Me.WeiqiStatusStrip.ResumeLayout(False)
Me.WeiqiStatusStrip.PerformLayout()
Me.ResumeLayout(False)
Me.PerformLayout() End Sub
Friend WithEvents PanelMain As System.Windows.Forms.Panel
Friend WithEvents QiPanPic As System.Windows.Forms.PictureBox
Friend WithEvents SplitterRight As System.Windows.Forms.Splitter
Friend WithEvents SplitterLeft As System.Windows.Forms.Splitter
Friend WithEvents WeiqiToolStripContainer As System.Windows.Forms.ToolStripContainer
Friend WithEvents WeiqiMainToolStrip As System.Windows.Forms.ToolStrip
Friend WithEvents 打开DToolStripButton As System.Windows.Forms.ToolStripButton
Friend WithEvents PanelRight As System.Windows.Forms.Panel
Friend WithEvents 保存BToolStripButton As System.Windows.Forms.ToolStripButton
Friend WithEvents WeiqiStatusStrip As System.Windows.Forms.StatusStrip
Friend WithEvents ToolStripStatusLabel1 As System.Windows.Forms.ToolStripStatusLabel
Friend WithEvents ToolStrip1 As System.Windows.Forms.ToolStrip
Friend WithEvents 前一步QToolStripButton As System.Windows.Forms.ToolStripButton
Friend WithEvents 后一步HToolStripButton As System.Windows.Forms.ToolStripButton
Friend WithEvents WeiqiImageList As System.Windows.Forms.ImageList
Friend WithEvents WeiqiTreeView As System.Windows.Forms.TreeView
Friend WithEvents ToolStripSplitButton1 As System.Windows.Forms.ToolStripSplitButton
Friend WithEvents ToolStripStatusLabel3 As System.Windows.Forms.ToolStripStatusLabel
End Class

2012年07月12日 03点07分 9
level 3
script_1934 楼主
算了,度娘不和谐,直接发下·载地址
文件名: Weightysoft Weiqi 5.0.rar
下·载地址: http://www.rayfile.com/files/be22c861-cbd6-11e1-a192-0015c55db73d/

2012年07月12日 04点07分 10
下不成。能发个百度网盘链接吗?
2012年10月04日 01点10分
level 12
支持原创
2012年07月12日 04点07分 11
level 1
支持原创
2012年07月12日 05点07分 12
level 6
这东西看着真不错,看来LZ很努力
2012年07月15日 10点07分 13
level 3
好东西,先顶贴再研究
2012年09月23日 18点09分 14
level 3
有劫的地方,不管黑白双方走了多少步,都不能在下子了?
2012年09月23日 19点09分 15
level 4
厉害啊啊啊啊
2012年09月30日 13点09分 20
1