Справочник Жаркова по проектированию и программированию искусственного интеллекта. Том 6: Программирование на Visual Basic искусственного интеллекта. Продолжение 2. Валерий Алексеевич Жарков
Чтение книги онлайн.

Читать онлайн книгу Справочник Жаркова по проектированию и программированию искусственного интеллекта. Том 6: Программирование на Visual Basic искусственного интеллекта. Продолжение 2 - Валерий Алексеевич Жарков страница 21

СКАЧАТЬ – 1)

      FindSol(i + 9)

      Case 7

      FindSol(i – 1)

      FindSol(i – 9)

      FindSol(i + 1)

      Case 8

      FindSol(i – 9)

      FindSol(i + 1)

      FindSol(i + 9)

      Case Else

      FindSol(i – 9)

      FindSol(i + 9)

      FindSol(i + 1)

      FindSol(i – 1)

      End Select

      End Sub

      Private Sub ResetAllTag()

      For Each Pic As MotionPic In MPBoxes

      If Pic.Tag = "Here" Then

      Pic.Tag = ""

      End If

      Next

      End Sub

      Private Function TestABox(ByVal val As Integer)

      Select Case val

      Case 0 : Return 1

      Case 8 : Return 2

      Case 80 : Return 3

      Case 72 : Return 4

      Case 1 To 7 : Return 5

      Case 73 To 79 : Return 7

      Case 17, 26, 35, 44, 53, 62, 71 : Return 6

      Case 9, 18, 27, 36, 45, 54, 63 : Return 8

      Case Else : Return 0

      End Select

      End Function

      'Serious trouble happened – think more

      Private Function GiveThreeBalls() As Boolean

      If ThreeBI(1) = -1 Then 'Review for Game over

      Return False

      Else

      For i As Integer = 0 To 2

      If ThreeBI(i) = -1 Then

      Exit For

      Else

      If MPBoxes(ThreeBP(i)).MPState = BallState. _

      NO_BALL And ThreeBP(i) <> posMoveTo Then

      MPBoxes(ThreeBP(i)).Init(ThreeBI(i))

      CalWin(ThreeBP(i))

      End If

      End If

      Next

      End If

      RandomThreeBalls()

      PreShow()

      Return True

      End Function

      Private Function IsFullBoard() As Boolean

      Dim i As Integer

      For Each Pic As PictureBox In MPBoxes

      If MPBoxes(i).MPState <> BallState.NO_BALL Then

      i += 1

      End If

      Next

      If i = 81 Then

      Return True

      Else

      Return False

      End If

      End Function

      Private Sub RandomThreeBalls()

      Dim ArrL As New ArrayList

      Dim i As Integer

      Dim pos As Integer

      Dim ind As Integer

      For i = 0 To 80

      If MPBoxes(i).MPState = BallState.NO_BALL Or _

      MPBoxes(i).MPState = BallState.DESTROYING_BALL Then

      ArrL.Add(i)

      End If

      Next

      For i = 0 To IIf(ArrL.Count > 2, 2, ArrL.Count – 1)

      pos = Rand.Next(0, ArrL.Count)

      pos = CInt(ArrL(pos))

      ArrL.Remove(pos)

      ThreeBP(i) = pos

      ind = Rand.Next(0, 12)

      ind = (ind \ 2) * 2

      ThreeBI(i) = ind

      Next

      For j As Integer = i To 2

      ThreeBI(j) = -1

      ThreeBP(j) = -1

      Next

      End Sub

      '#Region "Check for Calculate Score"

      Private Function CheckHor(ByVal pos As Integer) As Integer

      Dim type As Integer = MPBoxes(pos).MPIndex

      Dim i As Integer = (pos \ 9) * 9

      Dim count As Integer

      Dim startpos As Integer = i

      Dim endpos As Integer = i

      While i < (pos \ 9) * 9 + 9

      If MPBoxes(i).MPIndex = type Then

      endpos += 1

      count = endpos – startpos

      Else

      If count > 4 Then

      While MPBoxes(pos).MPState = _

      BallState.ZOOMING_BALL

      Application.DoEvents()

      End While

      For j As Integer = 0 To count – 1

      MPBoxes(startpos СКАЧАТЬ