Валерий Алексеевич Жарков

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


Скачать книгу

If

      While i < tempi + temp * 8

      If MPBoxes(i).MPIndex = type Then

      endpos += 8

      count = (endpos – startpos) \ 8

      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 + j * 8).Destroy()

      Next

      Return count

      End If

      If i >= pos + 32 Then

      Return count

      End If

      startpos = i + 8

      endpos = i + 8

      End If

      i += 8

      End While

      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 + j * 8).Destroy()

      Next

      Return count

      End If

      End Function

      Private Function CalWin(ByVal pos As Integer) As Integer

      Dim point As Integer = CheckHor(pos)

      If point < 4 Then

      point = CheckVer(pos)

      End If

      If point < 4 Then

      point = CheckLR(pos)

      End If

      If point < 4 Then

      point = CheckRL(pos)

      End If

      If point > 4 Then

      Dim dpoint As Double = point * 100 + (dpoint \ 6) * 100

      Dim n As Double = DDScore.number + dpoint

      For i As Double = DDScore.number To n Step 10

      DDScore.number = i

      lblScore.Refresh()

      Next

      DDScore.number = n

      Return point

      Else

      Return 0

      End If

      End Function

      '#Region "Ball Event And Paint Board"

      Private Sub Ball_Click(ByVal sender As System.Object, _

      ByVal e As System.EventArgs)

      CType(sender, MotionPic).Jump()

      If CType(sender, MotionPic).MPState <> _

      BallState.NO_BALL Then

      If intFlag <> -1 Then

      MPBoxes(intFlag).Jump()

      End If

      'intFlag = MPBoxes.IndexOf(MPBoxes, sender)

      'Исправляем предупреждение:

      intFlag = Array.IndexOf(MPBoxes, sender)

      ElseIf intFlag <> -1 Then

      Dim tempS As String = MPBoxes(intFlag).Tag

      MPBoxes(intFlag).Tag = ""

      FindSol(intFlag)

      If sender.tag = "Here" Then

      'posMoveTo = MPBoxes.IndexOf(MPBoxes, sender)

      'Исправляем предупреждение:

      posMoveTo = Array.IndexOf(MPBoxes, sender)

      If posMoveTo = ThreeBP(0) Then

      prePic(0).SendToBack()

      ElseIf posMoveTo = ThreeBP(1) Then

      prePic(1).SendToBack()

      ElseIf posMoveTo = ThreeBP(2) Then

      prePic(2).SendToBack()

      End If

      CType(sender, MotionPic).Init(MPBoxes(intFlag). _

      MPIndex)

      MPBoxes(intFlag).Destroy()

      While MPBoxes(intFlag).MPState = _

      BallState.DESTROYING_BALL

      Application.DoEvents()

      End While

      If CalWin(posMoveTo) = 0 Then

      If GiveThreeBalls() = False Then

      playerScore = DDScore.number

      Dim frm As Form2 = New Form2

      frm.AddPlayer() = _

      New Player(playerName, playerScore)

      frm.Show()

      frm.PlashScreen()

      frm.drawTable()

      ResetBoard()

      End If

      End If

      PreShow()

      intFlag = -1

      Else

      MPBoxes(intFlag).Tag = tempS

      End If

      ResetAllTag()

      End If

      End Sub

      Private Sub ResetBoard()

      ThreeBI(0) = -1

      tmr1.Enabled = False

      tmr2.Enabled = False

      playerScore = 0

      playerTime = 0

      DDScore.number = 0

      DDTime.number = 0

      Me.Refresh()

      PreShow()

      lblNameShow.Text = ""

      picBallPre1.Image = Nothing

      For i As Integer = 0 To 80

      MPBoxes(i).Reset()

      Next

      End Sub

      Private Sub DrawBoard(ByVal sender As Object, _

      ByVal e As System.Windows.Forms.PaintEventArgs) _

      Handles MyBase.Paint

      Dim g As Graphics = e.Graphics

      'Рисуем сетку линиями красного (Red) цвета:

      Dim p1 As New Pen(Color.Red)

      Dim p2 As New Pen(Color.Black)

      For i As Integer = 0 To 9

      g.DrawLine(p1, intBaseX + 45 * i – 4, intBaseY – 5, _

      intBaseX + 45 * i – 4, intBaseY + 45 * 9 – 5)

      g.DrawLine(p2, intBaseX + 45 * i – 3, intBaseY – 4, _

      intBaseX + 45 * i – 3, intBaseY + 45 * 9 – 4)

      g.DrawLine(p1, intBaseX – 4, intBaseY + 45 * i – 5, _

      intBaseX + 45 * 9 – 4, intBaseY + 45 * i – 5)

      g.DrawLine(p2, intBaseX – 3, intBaseY + 45 * i – 4, _

      intBaseX + 45 * 9 – 3, intBaseY + 45 * i – 4)

      Next

      End Sub

      Private