Оценить:
 Рейтинг: 0

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

Год написания книги
2023
Теги
<< 1 ... 10 11 12 13 14 15 16 17 18 ... 57 >>
На страницу:
14 из 57
Настройки чтения
Размер шрифта
Высота строк
Поля

Dim location As Point = CType(blocksToExamine(0), Point)

Dim currentBlock As Block = matrix(location.X, location.Y)

Dim row As Integer = location.X

Dim column As Integer = location.Y

blocksToExamine.RemoveAt(0)

Dim nextRow As Integer

Dim nextCol As Integer

Dim selected As Block

' look up

If row < matrix.GetLength(0) – 1 Then

nextRow = row + 1

selected = matrix(nextRow, column)

ExamineNeighbor(selected, nextRow, column, _

currentBlock.Color)

End If

' look down

If row > 0 Then

nextRow = row – 1

selected = matrix(nextRow, column)

ExamineNeighbor(selected, nextRow, column, _

currentBlock.Color)

End If

' look left

If column > 0 Then

nextCol = column – 1

selected = matrix(row, nextCol)

ExamineNeighbor(selected, row, nextCol, _

currentBlock.Color)

End If

' look right

If column < matrix.GetLength(1) – 1 Then

nextCol = column + 1

selected = matrix(row, nextCol)

ExamineNeighbor(selected, row, nextCol, _

currentBlock.Color)

End If

End Sub

''' <summary>

''' If the neighbor is the same color, add it to the blocks

''' to examine.

''' </summary>

''' <param name="selected"></param>

''' <param name="row"></param>

''' <param name="column"></param>

''' <param name="color"></param>

''' <remarks></remarks>

Private Sub ExamineNeighbor(ByVal selected As Block, _

ByVal row As Integer, ByVal column As Integer, _

ByVal color As Color)

If Not selected Is Nothing Then
<< 1 ... 10 11 12 13 14 15 16 17 18 ... 57 >>
На страницу:
14 из 57

Другие электронные книги автора Валерий Алексеевич Жарков