Are you able to use this new AI phenomenon? What have you used it for?
Everything that has a computer in will fail. Everything in your life, from a watch to a car to, you know, a radio, to an iPhone, it will fail if it has a computer in it. They should kill the people who made those things.- 'Woz' save a blobFileStreamDataTable To Text Filemy blog
I tried it and while the answers aren't always perfect, I am impressed. Here's a Connect Four game in vb it produced with only a few prompts:
Code:
Module Module1
Sub Main()
PlayConnectFour()
End Sub
Sub PlayConnectFour()
' Create the game board as a two-dimensional array
Dim rows As Integer = 6
Dim columns As Integer = 7
Dim board(rows, columns) As Integer
' Initialize the game board with empty cells
For r = 0 To rows
For c = 0 To columns
board(r, c) = 0
Next
Next
' Play the game until someone wins or the board is full
Dim player As Integer = 1
Dim gameOver As Boolean = False
While Not gameOver
' Prompt the current player to select a column
Console.WriteLine("Player " & player & ", select a column:")
Dim column As Integer = Console.ReadLine()
' Check if the selected column is valid
If column < 0 Or column >= columns Then
Console.WriteLine("Invalid column. Please try again.")
Continue While
End If
' Check if the selected column is full
If board(0, column) <> 0 Then
Console.WriteLine("Column is full. Please try again.")
Continue While
End If
' Place the player's token in the lowest empty cell in the selected column
For r = rows - 1 To 0 Step -1
If board(r, column) = 0 Then
board(r, column) = player
Exit For
End If
Next
' Check if the player has won
If CheckForWin(board, player) Then
Console.WriteLine("Player " & player & " wins!")
gameOver = True
End If
' Display the updated game board
DisplayBoard(board)
' Check if the board is full
If IsBoardFull(board) Then
Console.WriteLine("The game is a draw.")
gameOver = True
End If
' Switch to the other player
If player = 1 Then player = 2 Else player = 1
End While
End Sub
Function CheckForWin(board(,) As Integer, player As Integer) As Boolean
Dim rows As Integer = board.GetLength(0)
Dim columns As Integer = board.GetLength(1)
' Check for horizontal wins
For r = 0 To rows - 1
For c = 0 To columns - 4
If board(r, c) = player AndAlso board(r, c + 1) = player AndAlso board(r, c + 2) = player AndAlso board(r, c + 3) = player Then
Return True
End If
Next
Next
' Check for vertical wins
For r = 0 To rows - 4
For c = 0 To columns - 1
If board(r, c) = player AndAlso board(r + 1, c) = player AndAlso board(r + 2, c) = player AndAlso board(r + 3, c) = player Then
Return True
End If
Next
Next
' Check for diagonal wins (top-left to bottom-right)
For r = 0 To rows - 4
For c = 0 To columns - 4
If board(r, c) = player AndAlso board(r + 1, c + 1) = player AndAlso board(r + 2, c + 2) = player AndAlso board(r + 3, c + 3) = player Then
Return True
End If
Next
Next
' Check for diagonal wins (top-right to bottom-left)
For r = 0 To rows - 4
For c = columns - 1 To 3 Step -1
If board(r, c) = player AndAlso board(r + 1, c - 1) = player AndAlso board(r + 2, c - 2) = player AndAlso board(r + 3, c - 3) = player Then
Return True
End If
Next
Next
Return False
End Function
Function IsBoardFull(board(,) As Integer) As Boolean
Dim rows As Integer = board.GetLength(0)
Dim columns As Integer = board.GetLength(1)
For r = 0 To rows - 1
For c = 0 To columns - 1
If board(r, c) = 0 Then
Return False
End If
Next
Next
Return True
End Function
Sub DisplayBoard(board(,) As Integer)
Dim rows As Integer = board.GetLength(0)
Dim columns As Integer = board.GetLength(1)
' Print the column numbers at the top of the board
Console.Write(" ")
For c = 0 To columns - 1
Console.Write(c & " ")
Next
Console.WriteLine()
' Print each row of the board
For r = 0 To rows - 1
Console.Write(r & " ")
For c = 0 To columns - 1
If board(r, c) = 0 Then
Console.Write(". ")
Else
Console.Write(board(r, c) & " ")
End If
Next
Console.WriteLine()
Next
End Sub
End Module
It's not perfect but could be made into a passable program with little effort.
I tried it and while the answers aren't always perfect, I am impressed. Here's a Connect Four game in vb it produced with only a few prompts:
Code:
Module Module1
Sub Main()
PlayConnectFour()
End Sub
Sub PlayConnectFour()
' Create the game board as a two-dimensional array
Dim rows As Integer = 6
Dim columns As Integer = 7
Dim board(rows, columns) As Integer
' Initialize the game board with empty cells
For r = 0 To rows
For c = 0 To columns
board(r, c) = 0
Next
Next
' Play the game until someone wins or the board is full
Dim player As Integer = 1
Dim gameOver As Boolean = False
While Not gameOver
' Prompt the current player to select a column
Console.WriteLine("Player " & player & ", select a column:")
Dim column As Integer = Console.ReadLine()
' Check if the selected column is valid
If column < 0 Or column >= columns Then
Console.WriteLine("Invalid column. Please try again.")
Continue While
End If
' Check if the selected column is full
If board(0, column) <> 0 Then
Console.WriteLine("Column is full. Please try again.")
Continue While
End If
' Place the player's token in the lowest empty cell in the selected column
For r = rows - 1 To 0 Step -1
If board(r, column) = 0 Then
board(r, column) = player
Exit For
End If
Next
' Check if the player has won
If CheckForWin(board, player) Then
Console.WriteLine("Player " & player & " wins!")
gameOver = True
End If
' Display the updated game board
DisplayBoard(board)
' Check if the board is full
If IsBoardFull(board) Then
Console.WriteLine("The game is a draw.")
gameOver = True
End If
' Switch to the other player
If player = 1 Then player = 2 Else player = 1
End While
End Sub
Function CheckForWin(board(,) As Integer, player As Integer) As Boolean
Dim rows As Integer = board.GetLength(0)
Dim columns As Integer = board.GetLength(1)
' Check for horizontal wins
For r = 0 To rows - 1
For c = 0 To columns - 4
If board(r, c) = player AndAlso board(r, c + 1) = player AndAlso board(r, c + 2) = player AndAlso board(r, c + 3) = player Then
Return True
End If
Next
Next
' Check for vertical wins
For r = 0 To rows - 4
For c = 0 To columns - 1
If board(r, c) = player AndAlso board(r + 1, c) = player AndAlso board(r + 2, c) = player AndAlso board(r + 3, c) = player Then
Return True
End If
Next
Next
' Check for diagonal wins (top-left to bottom-right)
For r = 0 To rows - 4
For c = 0 To columns - 4
If board(r, c) = player AndAlso board(r + 1, c + 1) = player AndAlso board(r + 2, c + 2) = player AndAlso board(r + 3, c + 3) = player Then
Return True
End If
Next
Next
' Check for diagonal wins (top-right to bottom-left)
For r = 0 To rows - 4
For c = columns - 1 To 3 Step -1
If board(r, c) = player AndAlso board(r + 1, c - 1) = player AndAlso board(r + 2, c - 2) = player AndAlso board(r + 3, c - 3) = player Then
Return True
End If
Next
Next
Return False
End Function
Function IsBoardFull(board(,) As Integer) As Boolean
Dim rows As Integer = board.GetLength(0)
Dim columns As Integer = board.GetLength(1)
For r = 0 To rows - 1
For c = 0 To columns - 1
If board(r, c) = 0 Then
Return False
End If
Next
Next
Return True
End Function
Sub DisplayBoard(board(,) As Integer)
Dim rows As Integer = board.GetLength(0)
Dim columns As Integer = board.GetLength(1)
' Print the column numbers at the top of the board
Console.Write(" ")
For c = 0 To columns - 1
Console.Write(c & " ")
Next
Console.WriteLine()
' Print each row of the board
For r = 0 To rows - 1
Console.Write(r & " ")
For c = 0 To columns - 1
If board(r, c) = 0 Then
Console.Write(". ")
Else
Console.Write(board(r, c) & " ")
End If
Next
Console.WriteLine()
Next
End Sub
End Module
It's not perfect but could be made into a passable program with little effort.
I'm impressed!
Maybe it can help me solve some programming issues.
Here's a fun one I just had. Sometimes getting it to do something right is like pulling teeth. I had to condescend to it before it got it right:-
It seems you don't know how to draw a cube. Let me teach you. You can draw a cube by drawing two overlapping squares that are slightly offset from each other. You then draw lines that connect the corresponding corners of each square. Using this information, I want you to write some GDI+ code in VB.Net that draws a cube on a Form.
C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter
There's just no reason to use garbage like InputBox. - jmcilhinney
The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber
I use it to get information about specific topics or questions. And I am impressed by how well it gives you the exact answers to a question. But as it is AI software still doesn't answer some of the questions, but as per the performance, it is very useful.
I have tried it personally but it has a lot of attention. For years there were debates about using AI and the implications of that. Go slow was the mantra. ChatGPT blew that right out of the water. It can write college papers and pass top quality medical exams. It is amazing and will only get better.
Yeah. Of course, that makes it far harder for teachers. Having ChatGPT do your homework is just too easy.
Things like that and the internet in general must make it a nightmare for teachers. Grading homework isn't valid anymore so your sort of left with in class work and in person testing. with a lot of higher education classes now available online, it seems ripe for abuse.
Though they do try. My daughter is a nurse but only has an Associates degree. She has been doing an online program to get her BS. When they test she has to setup a webcam an show the test giver a scan of the room, then she is monitored via the webcam during the test. I imagine you could cheat but at least they don't make it easy.