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

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

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

Dim matrix(11, 14) As Block

''' <summary>

''' Creates a few rows of blocks to start the game.

''' Game starts with Red, Blue, and Green blocks.

''' </summary>

''' <param name="nrows">Number of rows of blocks to create

''' to start the game.</param>

''' <remarks></remarks>

Public Sub New(ByVal nrows As Integer)

If nrows > matrix.GetLength(0) Then

Throw New Exception("Must start with " & _

matrix.GetLength(0) & " or fewer rows.")

End If

Dim row As Integer

Dim column As Integer

For row = 0 To nrows – 1

For column = 0 To matrix.GetLength(1) – 1

matrix(row, column) = New Block( _

New Color() {Color.Red, Color.Blue, Color.Green})

Next

Next

For row = nrows To matrix.GetLength(0) – 1

For column = 0 To matrix.GetLength(1) – 1

matrix(row, column) = Nothing

Next

Next

End Sub

''' <summary>

''' A new row may be added at any time. New rows have Gray

''' blocks in addition

''' to Red, Blue, and Green. This makes the game more difficult.

''' </summary>

''' <remarks></remarks>

Public Sub AddRow()

Dim column As Integer

' Add a new block to each column.

For column = 0 To matrix.GetLength(1) – 1

Dim newBlock As New Block(New Color() _

{Color.Red, Color.Blue, Color.Green, Color.Gray})

' Add the new block at the botttom of the column,

' and push the rest of the

' blocks up one column.

For row As Integer = matrix.GetLength(0) – 1 To 1 Step -1

matrix(row, column) = matrix(row – 1, column)

Next

matrix(0, column) = newBlock

Next

End Sub

''' <summary>

''' Draw the grid of blocks
<< 1 ... 5 6 7 8 9 10 11 12 13 ... 57 >>
На страницу:
9 из 57

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