###### VB五子棋问题，请高手赐教

Option Explicit
Dim comable   As Boolean
Dim comturn   As Boolean
Dim blackturn   As Boolean
Dim whiteturn   As Boolean
Dim comcolor   As Long
Dim black   As Long
Dim white   As Long
Dim i   As Single
Dim j   As Single
Dim table(-5 To 20, -5 To 20)        As Integer '用此二维数组表示棋盘’

Private Sub restart()
Form_Paint
For i = 0 To 15
For j = 0 To 15
table(i, j) = 0
Next j
Next i
black = RGB(0, 0, 0)
white = RGB(255, 255, 255)
If comturn = True Then Call goes(7, 7)
End Sub

Private Sub goes(i As Single, j As Single)         '电脑将子走到table(i,j)’
If comturn = True And table(i, j) = 0 Then
FillColor = comcolor
FillStyle = 0
Dim x   As Single
Dim y   As Single
x = i * 300 + 100
y = j * 300 + 100
Circle (x, y), 100
comturn = False
table(i, j) = 2
End If
End Sub

Private Sub about_Click()
frmAbout.Show
End Sub

Private Sub doubleman_Click()  '双人’
blackturn = True
whiteturn = False
comable = False
comturn = False
restart
End Sub

Private Sub 退出_Click()
Dim i As Integer
i = MsgBox("你想退出游戏吗？", vbOKCancel + vbExclamation, "提示")
If i = vbOK Then
Unload Me
End If
End Sub

Private Sub Form_Load()
Form_Paint
comturn = True
End Sub

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)               '人走’
Dim a   As Single
Dim b   As Single
Dim m   As Single
Dim n   As Single
If (x - 100) Mod 300 < 150 Then
a = x - (x - 100) Mod 300
ElseIf (x - 100) Mod 300 > 150 Then
a = x + 300 - (x - 100) Mod 300
End If
If (y - 100) Mod 300 < 150 Then
b = y - (y - 100) Mod 300
ElseIf (y - 100) Mod 300 > 150 Then
b = y + 300 - (y - 100) Mod 300
End If

i = (a - 100) / 300
j = (b - 100) / 300
If (comturn = False) And (table(i, j) = 0) Then
If blackturn = True Then
FillColor = black
Else
FillColor = white
End If
FillStyle = 0
Circle (a, b), 100
table(i, j) = 1

If comable = False Then
blackturn = blackturn Xor True
End If   '双人

If comable = True Then
comturn = True
judgeman
comdo
judgecom
End If   '人机对战

End If
End Sub
Private Sub judgeman()  '判断人是否获胜’
Dim i   As Single
Dim j   As Single
For i = 0 To 15
For j = 0 To 15
If table(i, j) * table(i, j + 1) * table(i, j + 2) * table(i, j + 3) * table(i, j + 4) = 1 Then
MsgBox "你赢了，真棒！"
ElseIf table(i, j) * table(i + 1, j) * table(i + 2, j) * table(i + 3, j) * table(i + 4, j) = 1 Then
MsgBox "你赢了，真棒！"
ElseIf table(i, j) * table(i + 1, j + 1) * table(i + 2, j + 2) * table(i + 3, j + 3) * table(i + 4, j + 4) = 1 Then
MsgBox "你赢了，真棒！"
ElseIf table(i, j) * table(i - 1, j + 1) * table(i - 2, j + 2) * table(i - 3, j + 3) * table(i - 4, j + 4) = 1 Then
MsgBox "你赢了，真棒！"
End If
Next j
Next i
End Sub
Private Sub judgecom()  '判断电脑是否获胜’
Dim i   As Single
Dim j   As Single
For i = 0 To 15
For j = 0 To 15
If table(i, j) * table(i, j + 1) * table(i, j + 2) * table(i, j + 3) * table(i, j + 4) = 32 Then
MsgBox "你输了，继续努力哦！"
ElseIf table(i, j) * table(i + 1, j) * table(i + 2, j) * table(i + 3, j) * table(i + 4, j) = 32 Then
MsgBox "你输了，继续努力哦！"
ElseIf table(i, j) * table(i + 1, j + 1) * table(i + 2, j + 2) * table(i + 3, j + 3) * table(i + 4, j + 4) = 32 Then
MsgBox "你输了，继续努力哦！"
ElseIf table(i, j) * table(i - 1, j + 1) * table(i - 2, j + 2) * table(i - 3, j + 3) * table(i - 4, j + 4) = 32 Then
MsgBox "你输了，继续努力哦！"
End If
Next j
Next i
End Sub

Private Function wantfive(i, j, k) As Boolean        '定式1’
If table(i, j) = 0 And (table(i - 4, j) * table(i - 3, j) * table(i - 2, j) * table(i - 1, j) = k * k * k * k _
Or table(i - 4, j - 4) * table(i - 3, j - 3) * table(i - 2, j - 2) * table(i - 1, j - 1) = k * k * k * k _
Or table(i, j - 4) * table(i, j - 3) * table(i, j - 2) * table(i, j - 1) = k * k * k * k _
Or table(i + 1, j - 1) * table(i + 2, j - 2) * table(i + 3, j - 3) * table(i + 4, j - 4) = k * k * k * k _
Or table(i + 1, j) * table(i + 2, j) * table(i + 3, j) * table(i + 4, j) = k * k * k * k _
Or table(i + 1, j + 1) * table(i + 2, j + 2) * table(i + 3, j + 3) * table(i + 4, j + 4) = k * k * k * k _
Or table(i, j + 1) * table(i, j + 2) * table(i, j + 3) * table(i, j + 4) = k * k * k * k _
Or table(i - 1, j + 1) * table(i - 2, j + 2) * table(i - 3, j + 3) * table(i - 4, j + 4) = k * k * k * k _
Or table(i - 3, i) * table(i - 2, j) * table(i - 1, j) * table(i + 1, j) = k * k * k * k _
Or table(i - 3, j - 3) * table(i - 2, j - 2) * table(i - 1, j - 1) * table(i + 1, j + 1) = k * k * k * k _
Or table(i, j - 3) * table(i, j - 2) * table(i, j - 1) * table(i, j + 1) = k * k * k * k _
Or table(i + 1, j - 1) * table(i + 2, j - 2) * table(i + 3, j - 3) * table(i - 1, j + 1) = k * k * k * k _
Or table(i + 1, j) * table(i + 2, j) * table(i + 3, j) * table(i - 1, j) = k * k * k * k _
Or table(i + 1, j + 1) * table(i + 2, j + 2) * table(i + 3, j + 3) * table(i - 1, j - 1) = k * k * k * k _
Or table(i, j + 1) * table(i, j + 2) * table(i, j + 3) * table(i, j - 1) = k * k * k * k _
Or table(i - 1, j + 1) * table(i - 2, j + 2) * table(i - 3, j + 3) * table(i + 1, j - 1) = k * k * k * k _
Or table(i - 2, j) * table(i - 1, j) * table(i + 1, j) * table(i + 2, j) = k * k * k * k _
Or table(i - 1, j - 1) * table(i - 2, j - 2) * table(i + 1, j + 1) * table(i - 2, j - 2) = k * k * k * k _
Or table(i, j - 2) * table(i, j - 1) * table(i, j + 1) * table(i, j + 2) = k * k * k * k _
Or table(i + 1, j - 1) * table(i + 2, j - 2) * table(i - 1, j + 1) * table(i - 2, j + 2) = k * k * k * k _
) Then wantfive = True

End Function
Private Function wantfour(i, j, k) As Boolean      '定式2’
If table(i, j) = 0 And ((table(i - 3, j) = 0 And table(i + 2, j) = 0 And table(i - 2, j) * table(i - 1, j) * table(i + 1, j) = k * k * k) _
Or (table(i - 3, j - 3) = 0 And table(i + 2, j + 2) = 0 And table(i - 2, j - 2) * table(i - 1, j - 1) * table(i + 1, j + 1) = k * k * k) _
Or (table(i, j - 3) = 0 And table(i, j + 2) = 0 And table(i, j - 2) * table(i, j - 1) * table(i, j + 1) = k * k * k) _
Or (table(i + 3, j - 3) = 0 And table(i - 2, j + 2) = 0 And table(i + 2, j - 2) * table(i + 1, j - 1) * table(i - 1, j + 1) = k * k * k) _
Or (table(i + 3, j) = 0 And table(i - 2, j) = 0 And table(i + 2, j) * table(i + 1, j) * table(i - 1, j) = k * k * k) _
Or (table(i + 3, j + 3) = 0 And table(i - 2, j - 2) = 0 And table(i + 2, j + 2) * table(i + 1, j + 1) * table(i - 1, j - 1) = k * k * k) _
Or (table(i, j + 3) = 0 And table(i, j - 2) = 0 And table(i, j + 1) * table(i, j + 2) * table(i, j - 1) = k * k * k) _
Or (table(i - 3, j + 3) = 0 And table(i + 2, j - 2) = 0 And table(i - 2, j + 2) * table(i - 1, j + 1) * table(i + 1, j - 1) = k * k * k) _
) Then wantfour = True

End Function
Private Function wantfour1(i, j, k) As Boolean      '定式3’
Dim a(0 To 7)     As Single
Dim n   As Single
a(0) = table(i - 3, j) * table(i - 2, j) * table(i - 1, j)
a(1) = table(i - 3, j - 3) * table(i - 2, j - 2) * table(i - 1, j - 1)
a(2) = table(i, j - 3) * table(i, j - 2) * table(i, j - 1)
a(3) = table(i + 3, j - 3) * table(i + 2, j - 2) * table(i + 1, j - 1)
a(4) = table(i + 3, j) * table(i + 2, j) * table(i + 1, j)
a(5) = table(i + 1, j + 1) * table(i + 2, j + 2) * table(i + 3, j + 3)
a(6) = table(i, j + 1) * table(i, j + 2) * table(i, j + 3)
a(7) = table(i - 1, j + 1) * table(i - 2, j + 2) * table(i - 3, j + 3)
Dim b(0 To 7)     As Single
b(0) = table(i + 1, j)
b(1) = table(i + 1, j + 1)
b(2) = table(i, j + 1)
b(3) = table(i - 1, j + 1)
b(4) = table(i - 1, j)
b(5) = table(i - 1, j - 1)
b(6) = table(i, j - 1)
b(7) = table(i + 1, j - 1)
For n = 0 To 7
If table(i, j) = 0 And b(n) = 0 And a(n) = k * k * k Then
wantfour1 = True
End If
Next n

End Function
Private Function want231(i, j, k) As Boolean      '定式4’
Dim a(0 To 7)     As Single
a(0) = table(i - 2, j) * table(i - 1, j)
a(1) = table(i - 2, j - 2) * table(i - 1, j - 1)
a(2) = table(i, j - 2) * table(i, j - 1)
a(3) = table(i + 2, j - 2) * table(i + 1, j - 1)
a(4) = table(i + 1, j) * table(i + 2, j)
a(5) = table(i + 1, j + 1) * table(i + 2, j + 2)
a(6) = table(i, j + 1) * table(i, j + 2)
a(7) = table(i - 1, j + 1) * table(i - 2, j + 2)

If table(i, j) = 0 And ((table(i - 3, j) <> 3 - k And table(i - 3, j - 3) <> 3 - k And a(0) * a(1) = k * k * k * k) _
Or (table(i - 3, j) <> 3 - k And table(i, j - 3) <> 3 - k And a(0) * a(2) = k * k * k * k) _
Or (table(i - 3, j) <> 3 - k And table(i + 3, j - 3) <> 3 - k And a(0) * a(3) = k * k * k * k) _
Or (table(i - 3, j) <> 3 - k And table(i + 3, j + 3) <> 3 - k And a(0) * a(5) = k * k * k * k) _
Or (table(i - 3, j) <> 3 - k And table(i, j + 3) <> 3 - k And a(0) * a(6) = k * k * k * k) _
Or (table(i - 3, j) <> 3 - k And table(i - 3, j + 3) <> 3 - k And a(0) * a(7) = k * k * k * k) _
Or (table(i - 3, j - 3) <> 3 - k And table(i, j - 3) <> 3 - k And a(1) * a(2) = k * k * k * k) _
Or (table(i - 3, j - 3) <> 3 - k And table(i + 3, j - 3) <> 3 - k And a(1) * a(3) = k * k * k * k) _
Or (table(i - 3, j - 3) <> 3 - k And table(i + 3, j) <> 3 - k And a(1) * a(4) = k * k * k * k) _
Or (table(i - 3, j - 3) <> 3 - k And table(i, j + 3) <> 3 - k And a(1) * a(6) = k * k * k * k) _
Or (table(i - 3, j - 3) <> 3 - k And table(i - 3, j + 3) <> 3 - k And a(1) * a(7) = k * k * k * k) _
Or (table(i, j - 3) <> 3 - k And table(i + 3, j - 3) <> 3 - k And a(2) * a(3) = k * k * k * k) _
Or (table(i, j - 3) <> 3 - k And table(i + 3, j) <> 3 - k And a(2) * a(4) = k * k * k * k) _
Or (table(i, j - 3) <> 3 - k And table(i + 3, j + 3) <> 3 - k And a(2) * a(5) = k * k * k * k) _
Or (table(i, j - 3) <> 3 - k And table(i - 3, j + 3) <> 3 - k And a(2) * a(7) = k * k * k * k) _
Or (table(i + 3, j - 3) <> 3 - k And table(i + 3, j) <> 3 - k And a(3) * a(4) = k * k * k * k) _
Or (table(i + 3, j - 3) <> 3 - k And table(i + 3, j + 3) <> 3 - k And a(3) * a(5) = k * k * k * k) _
Or (table(i + 3, j - 3) <> 3 - k And table(i, j + 3) <> 3 - k And a(3) * a(6) = k * k * k * k) _
Or (table(i + 3, j) <> 3 - k And table(i + 3, j + 3) <> 3 - k And a(4) * a(5) = k * k * k * k) _
Or (table(i + 3, j) <> 3 - k And table(i, j + 3) <> 3 - k And a(4) * a(6) = k * k * k * k) _
Or (table(i + 3, j) <> 3 - k And table(i - 3, j + 3) <> 3 - k And a(4) * a(7) = k * k * k * k) _
Or (table(i + 3, j + 3) <> 3 - k And table(i, j + 3) <> 3 - k And a(5) * a(6) = k * k * k * k) _
Or (table(i + 3, j + 3) <> 3 - k And table(i - 3, j + 3) <> 3 - k And a(5) * a(7) = k * k * k * k) _
Or (table(i, j + 3) <> 3 - k And table(i - 3, j + 3) <> 3 - k And a(6) * a(7) = k * k * k * k) _
) Then want231 = True
End Function
Private Function want232(i, j, k) As Boolean      '定式5’
Dim b(0 To 3)     As Single
b(0) = table(i - 1, j) * table(i + 1, j)
b(1) = table(i - 1, j - 1) * table(i + 1, j + 1)
b(2) = table(i, j - 1) * table(i, j + 1)
b(3) = table(i + 1, j - 1) * table(i - 1, j + 1)

If table(i, j) = 0 And ((table(i - 2, j) <> 3 - k And table(i + 2, j) <> 3 - k And table(i - 2, j - 2) <> 3 - k And table(i + 2, j + 2) <> 3 - k And b(0) * b(1) = k * k) _
Or (table(i - 2, j) <> 3 - k And table(i + 2, j) <> 3 - k And table(i, j - 2) <> 3 - k And table(i, j + 2) <> 3 - k And b(0) * b(2) = k * k) _
Or (table(i - 2, j) <> 3 - k And table(i + 2, j) <> 3 - k And table(i + 2, j - 2) <> 3 - k And table(i - 2, j + 2) <> 3 - k And b(0) * b(3) = k * k) _
Or (table(i - 2, j - 2) <> 3 - k And table(i + 2, j + 2) <> 3 - k And table(i, j - 2) <> 3 - k And table(i, j + 2) <> 3 - k And b(1) * b(2) = k * k) _
Or (table(i - 2, j - 2) <> 3 - k And table(i + 2, j + 2) <> 3 - k And table(i + 2, j - 2) <> 3 - k And table(i - 2, j + 2) <> 3 - k And b(1) * b(3) = k * k) _
Or (table(i, j - 2) <> 3 - k And table(i, j + 2) <> 3 - k And table(i + 2, j - 2) <> 3 - k And table(i - 2, j + 2) <> 3 - k And b(2) * b(3) = k * k) _
) Then want232 = True
End Function
Function want233(i, j, k) As Boolean     '定式6’
Dim m   As Single
Dim n   As Single
Dim b(0 To 7)     As Single
Dim b1(0 To 7)     As Single
Dim a(0 To 7)     As Single
Dim a1(0 To 7)     As Single
b(0) = table(i - 1, j)
b(1) = table(i - 1, j - 1)
b(2) = table(i, j - 1)
b(3) = table(i + 1, j - 1)
b(4) = table(i + 1, j)
b(5) = table(i + 1, j + 1)
b(6) = table(i, j + 1)
b(7) = table(i - 1, j + 1)
b1(0) = table(i - 2, j)
b1(1) = table(i - 2, j - 2)
b1(2) = table(i, j - 2)
b1(3) = table(i + 2, j - 2)
b1(4) = table(i + 2, j)
b1(5) = table(i + 2, j + 2)
b1(6) = table(i, j + 2)
b1(7) = table(i - 2, j + 2)
a(0) = table(i - 2, j) * table(i - 1, j)
a(1) = table(i - 2, j - 2) * table(i - 1, j - 1)
a(2) = table(i, j - 2) * table(i, j - 1)
a(3) = table(i + 1, j - 1) * table(i + 2, j - 2)
a(4) = table(i + 1, j) * table(i + 2, j)
a(5) = table(i + 1, j + 1) * table(i + 2, j + 2)
a(6) = table(i, j + 1) * table(i, j + 2)
a(7) = table(i - 1, j + 1) * table(i - 2, j + 2)
a1(0) = table(i - 3, j)
a1(1) = table(i - 3, j - 3)
a1(2) = table(i, j - 3)
a1(3) = table(i + 3, j - 3)
a1(4) = table(i + 3, j)
a1(5) = table(i + 3, j + 3)
a1(6) = table(i, j + 3)
a1(7) = table(i - 3, j + 3)
For m = 0 To 3
For n = 0 To 7
If (b1(m) <> 3 - k And b1(m + 4) <> 3 - k And a1(n) <> 3 - k And b(m) * b(m + 4) = k * k) And n <> m And n <> m + 4 And a(n) = k * k Then
want233 = True
End If
Next n
Next m

End Function
Private Function wantthree(i As Single, j As Single, k As Single) As Boolean            '定式7’
Dim a(0 To 7)     As Single
Dim n   As Single
a(0) = table(i - 2, j) * table(i - 1, j)
a(1) = table(i - 2, j - 2) * table(i - 1, j - 1)
a(2) = table(i, j - 2) * table(i, j - 1)
a(3) = table(i + 1, j - 1) * table(i + 2, j - 2)
a(4) = table(i + 1, j) * table(i + 2, j)
a(5) = table(i + 1, j + 1) * table(i + 2, j + 2)
a(6) = table(i, j + 1) * table(i, j + 2)
a(7) = table(i - 1, j + 1) * table(i - 2, j + 2)
For n = 0 To 7
If table(i, j) = 0 And a(n) = k * k Then
wantthree = True
End If
Next n
End Function

Private Sub comdo()
Dim a   As Single
Dim b   As Single
For a = -5 To 20
For b = -5 To 20
If (a < 0) Or (b < 0) Or (a > 15) Or (b > 15) Then
table(a, b) = 10
End If
Next b
Next a

For i = 0 To 15
For j = 0 To 15
If comturn = True And wantfive(i, j, 2) = True Then
Call goes(i, j)
End If
Next j
Next i   '连五子

For i = 0 To 15
For j = 0 To 15
If comturn = True And wantfive(i, j, 1) = True Then
Call goes(i, j)
End If
Next j
Next i   '阻止对方连五子

For i = 0 To 15
For j = 0 To 15
If comturn = True And table(i, j) * table(i, j + 1) * table(i, j + 2) = 8 And (table(i, j - 1) = 0 And table(i, j + 3) = 0) Then
If table(i, j - 2) = 2 Or table(i - 1, j - 1) = 2 Or table(i - 1, j) = 2 Or table(i - 1, j + 1) = 2 Or table(i + 1, j - 1) = 2 Or table(i + 1, j) = 2 Or table(i + 1, j + 1) = 2 Then
Call goes(i, j - 1)
Else
Call goes(i, j + 3)
End If
ElseIf comturn = True And table(i, j) * table(i + 1, j) * table(i + 2, j) = 8 And (table(i - 1, j) = 0 And table(i + 3, j)) = 0 Then
If table(i - 2, j) = 2 Or table(i - 1, j - 1) = 2 Or table(i, j - 1) = 2 Or table(i + 1, j - 1) = 2 Or table(i - 1, j + 1) = 2 Or table(i, j + 1) = 2 Or table(i + 1, j + 1) = 2 Then
Call goes(i - 1, j)
Else
Call goes(i + 3, j)
End If
ElseIf comturn = True And table(i, j) * table(i + 1, j + 1) * table(i + 2, j + 2) = 8 And (table(i - 1, j - 1) = 0 And table(i + 3, j + 3) = 0) Then
If table(i - 2, j - 2) = 2 Or table(i - 1, j) = 2 Or table(i - 1, j + 1) = 2 Or table(i, j - 1) = 2 Or table(i, j + 1) = 2 Or table(i + 1, j - 1) = 2 Or table(i + 1, j) = 2 Then
Call goes(i - 1, j - 1)
Else
Call goes(i + 3, j + 3)
End If
ElseIf comturn = True And table(i, j) * table(i - 1, j + 1) * table(i - 2, j + 2) = 8 And (table(i + 1, j - 1) = 0 And table(i - 3, j + 3) = 0) Then
If table(i + 2, j - 2) = 2 Or table(i - 1, j - 1) = 2 Or table(i, j - 1) = 2 Or table(i - 1, j) = 2 Or table(i + 1, j) = 2 Or table(i + 1, j + 1) = 2 Or table(i, j + 1) = 2 Then
Call goes(i + 1, j - 1)
Else
Call goes(i - 3, j + 3)
End If
End If
Next j
Next i   '将自己连成四点一线

For i = 0 To 15
For j = 0 To 15
If comturn = True And wantfour(i, j, 2) = True Then
Call goes(i, j)
End If
Next j
Next i   '将自己连成四点一线

For i = 0 To 15
For j = 0 To 15
If comturn = True And wantfour1(i, j, 2) = True Then
Call goes(i, j)
End If
Next j
Next i   '叫吃

For i = 0 To 15
For j = 0 To 15
If comturn = True And table(i, j) * table(i, j + 1) * table(i, j + 2) = 1 And (table(i, j - 1) = 0 And table(i, j + 3) = 0) Then
If table(i, j - 2) = 1 Or table(i - 1, j - 1) = 1 Or table(i - 1, j) = 1 Or table(i - 1, j + 1) = 1 Or table(i + 1, j - 1) = 1 Or table(i + 1, j) = 1 Or table(i + 1, j + 1) = 1 Then
Call goes(i, j - 1)
Else
Call goes(i, j + 3)
End If
ElseIf comturn = True And table(i, j) * table(i + 1, j) * table(i + 2, j) = 1 And (table(i - 1, j) = 0 And table(i + 3, j) = 0) Then
If table(i - 2, j) = 1 Or table(i - 1, j - 1) = 1 Or table(i, j - 1) = 1 Or table(i + 1, j - 1) = 1 Or table(i - 1, j + 1) = 1 Or table(i, j + 1) = 1 Or table(i + 1, j + 1) = 1 Then
Call goes(i - 1, j)
Else
Call goes(i + 3, j)
End If
ElseIf comturn = True And table(i, j) * table(i + 1, j + 1) * table(i + 2, j + 2) = 1 And (table(i - 1, j - 1) = 0 And table(i + 3, j + 3) = 0) Then
If table(i - 2, j - 2) = 1 Or table(i - 1, j) = 1 Or table(i - 1, j + 1) = 1 Or table(i, j - 1) = 1 Or table(i, j + 1) = 1 Or table(i + 1, j - 1) = 1 Or table(i + 1, j) = 1 Then
Call goes(i - 1, j - 1)
Else
Call goes(i + 3, j + 3)
End If
ElseIf comturn = True And table(i, j) * table(i - 1, j + 1) * table(i - 2, j + 2) = 1 And (table(i + 1, j - 1) = 0 And table(i - 3, j + 3) = 0) Then
If table(i + 2, j - 2) = 1 Or table(i - 1, j - 1) = 1 Or table(i, j - 1) = 1 Or table(i - 1, j) = 1 Or table(i + 1, j) = 1 Or table(i + 1, j + 1) = 1 Or table(i, j + 1) = 1 Then
Call goes(i + 1, j - 1)
Else
Call goes(i - 3, j + 3)
End If
End If
Next j
Next i   '阻止对方四点一线

For i = 0 To 15
For j = 0 To 15
If comturn = True And wantfour(i, j, 1) = True Then
Call goes(i, j)
End If
Next j
Next i   '阻止对方四点一线

For i = 0 To 15
For j = 0 To 15
If comturn = True And (want231(i, j, 1) = True _
Or want232(i, j, 1) = True _
Or want233(i, j, 1) = True) Then
Call goes(i, j)
End If
Next j
Next i   '阻止对方走双飞燕

For i = 0 To 15
For j = 0 To 15
If comturn = True And (want231(i, j, 2) = True _
Or want232(i, j, 2) = True _
Or want233(i, j, 2) = True) Then
Call goes(i, j)
End If
Next j
Next i   '走双飞燕

For i = 0 To 15
For j = 0 To 15
If comturn = True And wantfour1(i, j, 1) = True Then
Call goes(i, j)
End If
Next j
Next i   '防止叫吃

For i = 0 To 15
For j = 0 To 15
If comturn = True And wantthree(i, j, 1) = True Then
Call goes(i, j)
End If
Next j
Next i   '挡对方两子一线的

For i = 0 To 15
For j = 0 To 15
If comturn = True And wantthree(i, j, 2) = True Then
Call goes(i, j)
End If
Next j
Next i   '连自己两点一线的

For i = 0 To 15
For j = 0 To 15
If comturn = True And table(i, j) = 0 And (table(i - 1, j) * table(i + 1, j) = 1 _
Or table(i - 1, j + 1) * table(i + 1, j + 1) = 1 _
Or table(i, j - 1) * table(i, j + 1) = 1 _
Or table(i + 1, j - 1) * table(i - 1, j + 1) = 1 _
) Then
Call goes(i, j)
End If
Next j
Next i   '断

For i = 0 To 15
For j = 0 To 15
If comturn = True And table(i, j) = 0 And (table(i - 1, j) * table(i + 1, j) = 4 _
Or table(i - 1, j + 1) * table(i + 1, j + 1) = 4 _
Or table(i, j - 1) * table(i, j + 1) = 4 _
Or table(i + 1, j - 1) * table(i - 1, j + 1) = 4 _
) Then
Call goes(i, j)
End If
Next j
Next i   '粘

For i = 0 To 15
For j = 0 To 15
If comturn = True And table(i, j) = 1 And (table(i - 1, j - 1) = 0 Or table(i, j - 1) = 0 Or table(i + 1, j - 1) = 0 Or table(i - 1, j) = 0 Or table(i + 1, j) = 0 Or table(i - 1, j + 1) = 0 Or table(i, j + 1) = 0 Or table(i + 1, j + 1) = 0) Then
If table(i - 1, j - 1) = 0 Then
Call goes(i - 1, j - 1)
ElseIf table(i + 1, j + 1) = 0 Then
Call goes(i + 1, j + 1)
ElseIf table(i, j - 1) = 0 Then
Call goes(i, j - 1)
ElseIf table(i, j + 1) = 0 Then
Call goes(i, j + 1)
ElseIf table(i + 1, j - 1) = 0 Then
Call goes(i + 1, j - 1)
ElseIf table(i - 1, j + 1) = 0 Then
Call goes(i - 1, j + 1)
ElseIf table(i - 1, j) = 0 Then
Call goes(i - 1, j)
ElseIf table(i + 1, j) = 0 Then
Call goes(i + 1, j)
End If
End If
Next j
Next i   '随意走一步
End Sub

Private Sub Form_Paint()  '以(100,100)为左上角坐标画一个16*16,每格边长为300的棋盘’
Cls
Dim x   As Single
Dim y   As Single
x = 100
y = 100
While x < 4300
x = x + 300
Line (x, 100)-(x, 4600)
Wend
While y < 4300
y = y + 300
Line (100, y)-(4600, y)
Wend
Line (50, 50)-(50, 4650)
Line (50, 50)-(4650, 50)
Line (50, 4650)-(4650, 4650)
Line (4650, 50)-(4650, 4650)
Line (100, 100)-(4600, 100)
Line (100, 100)-(100, 4600)
Line (4600, 100)-(4600, 4600)
Line (100, 4600)-(4600, 4600)
End Sub

Private Sub 规则_Click()
MsgBox "双方轮流出子，最先五子连成一线者胜"
End Sub

Private Sub 人先_Click()
blackturn = True
whiteturn = False
comable = True
comturn = False
comcolor = RGB(255, 255, 255)
restart
End Sub

Private Sub 机先_Click()
blackturn = False
whiteturn = True
comable = True
comturn = True
comcolor = RGB(0, 0, 0)
restart
End Sub

#### 五子棋游戏开发

1970年01月01日 08:00

#### 无线网络问题##高手请赐教

2008-05-11 20:06:00

#### VB制作五子棋程序，十分的有趣有用

2010年12月09日 2.6MB 下载

#### 简单五子棋游戏VB版

2013年05月16日 16KB 下载

#### 五子棋vb源代码-完整注释-绝对原创

2009年12月20日 345KB 下载

#### 五子棋 VB6.0

2005-03-12 15:30:00

#### MFC猜数字游戏

2011年12月28日 1.52MB 下载

#### 这是一个用vb编写的五子棋程序，对初学者非常有用

2011年04月20日 52KB 下载

#### 高手赐教

2007-05-17 22:28:00

#### VB五子棋程序

2012年06月21日 606KB 下载

VB五子棋问题，请高手赐教