Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
QB64 GPT now available
#1
I am working on a QB64 GPT. I have been training it on the Wiki as well as some sample programs. Doesn't always produce ready-to-use code, especially when it comes to OpenGL or Windows API. Otherwise, most things it makes should be good. If anyone is willing to concatenate all their samples or libraries into single files, I'd be happy to use them as training data for the GPT. It also has InForm as training data, though I can't say it does too well. I plan on making another GPT that is strictly for helping with making changes to the IDE/compiler.

https://chatgpt.com/g/g-Cufiyami0-qb64-gpt
Tread on those who tread on you

Reply
#2
Here is some code that it wrote when I asked for a game. Doesn't work, but it is syntactically correct and does compile:

Code: (Select All)
DECLARE SUB InitializeGame ()
DECLARE SUB HandleInput ()
DECLARE SUB UpdateGame ()
DECLARE SUB RenderGame ()
DECLARE SUB CheckPlatformCollision ()
DECLARE SUB CreatePlatforms ()
DECLARE SUB CreateEnemies ()
DECLARE SUB UpdateEnemies ()
DECLARE SUB CheckEnemyCollision ()

Const SCREEN_WIDTH = 800
Const SCREEN_HEIGHT = 600

Type Platform
    x As Single
    y As Single
    width As Single
    height As Single
End Type

Type Enemy
    x As Single
    y As Single
    width As Single
    height As Single
    velX As Single
End Type

Dim Shared playerX As Single, playerY As Single
Dim Shared playerVelX As Single, playerVelY As Single
Dim Shared gravity As Single
Dim Shared isJumping As Integer
Dim Shared platforms(10) As Platform
Dim Shared enemies(5) As Enemy

Screen _NewImage(SCREEN_WIDTH, SCREEN_HEIGHT, 32)
InitializeGame

Do
    HandleInput
    UpdateGame
    RenderGame
    _Limit 60
Loop Until InKey$ = Chr$(27) ' Esc key to exit

Sub InitializeGame
    playerX = SCREEN_WIDTH / 2
    playerY = SCREEN_HEIGHT - 50
    playerVelX = 0
    playerVelY = 0
    gravity = 0.5
    isJumping = 0
    CreatePlatforms
    CreateEnemies
End Sub

Sub HandleInput
    playerVelX = 0
    If _KeyDown(203) Then playerVelX = -5 ' Left arrow key
    If _KeyDown(205) Then playerVelX = 5 ' Right arrow key
    If _KeyDown(57) And isJumping = 0 Then ' Space bar
        playerVelY = -10
        isJumping = 1
    End If
End Sub

Sub UpdateGame
    playerY = playerY + playerVelY
    playerX = playerX + playerVelX
    playerVelY = playerVelY + gravity

    ' Simulate ground
    If playerY >= SCREEN_HEIGHT - 50 Then
        playerY = SCREEN_HEIGHT - 50
        playerVelY = 0
        isJumping = 0
    End If

    ' Check collision with platforms
    CheckPlatformCollision

    ' Update enemies
    UpdateEnemies

    ' Check collision with enemies
    CheckEnemyCollision
End Sub

Sub CheckPlatformCollision
    For i = 0 To 9
        If playerX + 10 > platforms(i).x And playerX < platforms(i).x + platforms(i).width Then
            If playerY + 10 > platforms(i).y And playerY < platforms(i).y + platforms(i).height Then
                playerY = platforms(i).y - 10
                playerVelY = 0
                isJumping = 0
            End If
        End If
    Next
End Sub

Sub CreatePlatforms
    For i = 0 To 9
        platforms(i).x = Rnd * (SCREEN_WIDTH - 100)
        platforms(i).y = Rnd * (SCREEN_HEIGHT - 200)
        platforms(i).width = 100
        platforms(i).height = 10
    Next
End Sub

Sub CreateEnemies
    For i = 0 To 4
        enemies(i).x = Rnd * (SCREEN_WIDTH - 50)
        enemies(i).y = Rnd * (SCREEN_HEIGHT - 50)
        enemies(i).width = 30
        enemies(i).height = 30
        enemies(i).velX = 2 * (Rnd - 0.5)
    Next
End Sub

Sub UpdateEnemies
    For i = 0 To 4
        enemies(i).x = enemies(i).x + enemies(i).velX
        If enemies(i).x < 0 Or enemies(i).x > SCREEN_WIDTH - enemies(i).width Then
            enemies(i).velX = -enemies(i).velX
        End If
    Next
End Sub

Sub CheckEnemyCollision
    For i = 0 To 4
        If playerX + 10 > enemies(i).x And playerX < enemies(i).x + enemies(i).width Then
            If playerY + 10 > enemies(i).y And playerY < enemies(i).y + enemies(i).height Then
                ' Game over or reduce player health
                Print "Game Over!"
                Sleep
                End
            End If
        End If
    Next
End Sub

Sub RenderGame
    Cls
    _PrintString (playerX, playerY), "O"
    For i = 0 To 9
        Line (platforms(i).x, platforms(i).y)-(platforms(i).x + platforms(i).width, platforms(i).y + platforms(i).height), _RGB(0, 255, 0), BF
    Next
    For i = 0 To 4
        Line (enemies(i).x, enemies(i).y)-(enemies(i).x + enemies(i).width, enemies(i).y + enemies(i).height), _RGB(255, 0, 0), BF
    Next
    _Display
End Sub
   

When I adjusted the arrow key controls to A, D, and space bar it actually worked. It ain't the prettiest, but it does work.
Tread on those who tread on you

Reply
#3
you should give it terry's tut so it can learn how to comment it's code
b = b + ...
Reply
#4
Good one
Tread on those who tread on you

Reply
#5
(05-17-2024, 05:08 PM)SpriggsySpriggs Wrote: I am working on a QB64 GPT. I have been training it on the Wiki as well as some sample programs. Doesn't always produce ready-to-use code, especially when it comes to OpenGL or Windows API. Otherwise, most things it makes should be good. If anyone is willing to concatenate all their samples or libraries into single files, I'd be happy to use them as training data for the GPT. It also has InForm as training data, though I can't say it does too well. I plan on making another GPT that is strictly for helping with making changes to the IDE/compiler.

https://chatgpt.com/g/g-Cufiyami0-qb64-gpt

Sick! How did you train it?

It says I have to sign-up.

Are you going to put your model onto hugging face? (is that a thing that can happen with what you did?) then we could like host our own local copy of the model?
grymmjack (gj!)
GitHubYouTube | Soundcloud | 16colo.rs
Reply
#6
(05-18-2024, 04:11 PM)grymmjack Wrote:
(05-17-2024, 05:08 PM)SpriggsySpriggs Wrote: I am working on a QB64 GPT. I have been training it on the Wiki as well as some sample programs. Doesn't always produce ready-to-use code, especially when it comes to OpenGL or Windows API. Otherwise, most things it makes should be good. If anyone is willing to concatenate all their samples or libraries into single files, I'd be happy to use them as training data for the GPT. It also has InForm as training data, though I can't say it does too well. I plan on making another GPT that is strictly for helping with making changes to the IDE/compiler.

https://chatgpt.com/g/g-Cufiyami0-qb64-gpt

Sick! How did you train it?

It says I have to sign-up.

Are you going to put your model onto hugging face? (is that a thing that can happen with what you did?) then we could like host our own local copy of the model?

This was made using the GPT builder on ChatGPT. I don't have any models. It was trained using the Wiki and some sample code.
Tread on those who tread on you

Reply




Users browsing this thread: 5 Guest(s)