Post by Horizon on Apr 14, 2023 9:19:20 GMT
Just for fun I wondered if its possible to teach Just BASIC to Chat GPT. After an initial misunderstanding things seemed to move quite quickly:
# So far so good #
# Here we can see the initial misunderstanding (confusion with other types of Basic). #
# At this point I provide the Just BASIC keyword and Reserved Word Lists #
# I then ask for a simple program #
# Hmmm some errors here, but not terrible #
# Clearly this code does not work in Just BASIC, so I offer help... #
# Chat GPT then regenerates the code, but stubbornly puts back the "Randomize Timer" #
# I correct this and then the code is reproduced so that it runs in Just BASIC #
# I then ask for a GUI #
# Lets see what happens...#
# At this point there's quite a few problems for Chat GPT, its not to hard to unpick, but I think it will need a few sessions to get there. #
I'll keep you updated on progress...
Me: Hello, do you know how to program in Just BASIC? Information on this programming language can be found here: justbasic.com/index.html
A: Yes, as an AI language model, I have information on Just BASIC programming language. Just BASIC is a dialect of the BASIC programming language and is designed to be easy to learn and use, making it an ideal language for beginners. Just BASIC comes with a comprehensive help file and a range of example programs to help users get started.
Here is a simple "Hello, World!" program in Just BASIC:
Here is a simple "Hello, World!" program in Just BASIC:
PRINT "Hello, World!"
This program will display the message "Hello, World!" on the screen.
Just BASIC is a procedural programming language, which means that programs are organized into subroutines or procedures that perform specific tasks. Here is an example program that uses a subroutine to calculate the area of a circle:
Just BASIC is a procedural programming language, which means that programs are organized into subroutines or procedures that perform specific tasks. Here is an example program that uses a subroutine to calculate the area of a circle:
DIM radius
INPUT "Enter the radius of the circle: ", radius
circArea(radius)
END
SUB circArea(r)
area = 3.14159 * r * r
PRINT "The area of the circle is: "; area
END SUB
# Here we can see the initial misunderstanding (confusion with other types of Basic). #
A: This program prompts the user to enter the radius of a circle, then calls the circArea subroutine to calculate and display the area of the circle.
Just BASIC also provides support for graphics and user interfaces, making it a versatile language for creating simple programs and games. The Just BASIC website provides a range of tutorials, sample code, and a helpful community forum to help users get started with programming in Just BASIC.
Just BASIC also provides support for graphics and user interfaces, making it a versatile language for creating simple programs and games. The Just BASIC website provides a range of tutorials, sample code, and a helpful community forum to help users get started with programming in Just BASIC.
Me: There's some difference in Just BASIC syntax, would you like to learn this? I can provide you with the information.
A: As an AI language model, I'm always eager to learn new things. Please feel free to provide me with any information about the differences in syntax between Just BASIC and other dialects of BASIC.
# At this point I provide the Just BASIC keyword and Reserved Word Lists #
# I then ask for a simple program #
Me: Please write a "Guess the number" Just BASIC program.
A: Certainly! Here's a simple "Guess the Number" program in Just BASIC:
RANDOMIZE TIMER
numToGuess = INT(RND * 100) + 1
numGuesses = 0
guess = 0
PRINT "I'm thinking of a number between 1 and 100. Can you guess what it is?"
WHILE guess <> numToGuess
INPUT "Enter your guess: ", guess
numGuesses = numGuesses + 1
IF guess < numToGuess THEN
PRINT "Too low! Try again."
ELSE IF guess > numToGuess THEN
PRINT "Too high! Try again."
END IF
WEND
PRINT "Congratulations! You guessed the number in " + STR$(numGuesses) + " guesses."
# Hmmm some errors here, but not terrible #
A: This program generates a random number between 1 and 100 using the RND function and the INT function to convert the random number to an integer. It then prompts the user to guess the number using a WHILE loop that continues until the user guesses correctly. The program provides feedback to the user if their guess is too high or too low using IF statements. Finally, the program outputs the number of guesses it took the user to guess the correct number.
# Clearly this code does not work in Just BASIC, so I offer help... #
Me: Your Just BASIC code does not quite work. Please take a look at this example:
numToGuess = int(rnd(1)*100) + 1
numGuesses = 0
guess = 0
PRINT "I'm thinking of a number between 1 and 100. Can you guess what it is?"
WHILE guess <> numToGuess
INPUT "Enter your guess: "; guess
numGuesses = numGuesses + 1
IF guess = numToGuess then [win]
IF guess < numToGuess THEN
PRINT "Too low! Try again."
ELSE
PRINT "Too high! Try again."
END IF
WEND
[win]
PRINT "Congratulations! You guessed the number in " + STR$(numGuesses) + " guesses."
# Chat GPT then regenerates the code, but stubbornly puts back the "Randomize Timer" #
# I correct this and then the code is reproduced so that it runs in Just BASIC #
# I then ask for a GUI #
Me: Could you add to the Just BASIC code to include a GUI for the example program above?
A: Certainly! Here's an updated version of the "Guess the number" program that includes a GUI:
' Guess the number game with GUI
' Written in Just BASIC
' Set up the GUI window
nomainwin
WindowWidth = 300
WindowHeight = 200
UpperLeftX=int((DisplayWidth-WindowWidth)/2)
UpperLeftY=int((DisplayHeight-WindowHeight)/2)
text$ = "Guess the number"
open "Guess the number" for graphics_nsb as #main
#main "trapclose [quit]"
#main "font arial 12"
#main "down ; fill lightgray ; backcolor lightgray ; flush"
' Set up game variables
numToGuess = int(rnd(1)*100) + 1
numGuesses = 0
guess = 0
' Display the instructions
#main "color black ; backcolor lightgray ; up ; goto 10 10 ; boxfilled 280 90 ; font bold ; color blue ; print "; text$
#main "color black ; backcolor lightgray ; up ; goto 20 40 ; font normal ; print I'm thinking of a number between 1 and 100. Can you guess what it is? ; flush"
' Get user input and check for correct guess
WHILE guess <> numToGuess
INPUT "Enter your guess: "; guess
numGuesses = numGuesses + 1
IF guess = numToGuess THEN [win]
IF guess < numToGuess THEN
#main "color black ; backcolor lightgray ; up ; goto 20 60 ; font normal ; print Too low! Try again. ; flush"
ELSE
#main "color black ; backcolor lightgray ; up ; goto 20 60 ; font normal ; print Too high! Try again. ; flush"
END IF
WEND
[win]
#main "color black ; backcolor lightgray ; up ; goto 20 60 ; font normal ; print Congratulations! You guessed the number in " + STR$(numGuesses) + " guesses. ; flush"
WAIT
[quit]
CLOSE #main
END
# At this point there's quite a few problems for Chat GPT, its not to hard to unpick, but I think it will need a few sessions to get there. #
I'll keep you updated on progress...