ChatGPT to make a BASIC program !

In this forum you can write about anything that does not fit in other forums.
This includes generic Oric talkings and things that are totaly unrelated but want to share with people here :)
User avatar
goyo
Officer Cadet
Posts: 52
Joined: Sat Jan 12, 2019 10:16 am

ChatGPT to make a BASIC program !

Post by goyo »

Hello,

I tried ChatGPT , it's truly impressive but when we asked for a bigger program it's more difficult for him.

sample for generate a simple code :

Code: Select all


hello, can you make a program with the basic language of Oric Atmos who print 10 times "hello" on the screen ?

Sure, here's a program in BASIC for the Oric Atmos that will print "Hello" ten times:

10 FOR I = 1 TO 10
20 PRINT "Hello"
30 NEXT I
40 END

 
Just type the lines of code into the BASIC interpreter, then run the program with the command "RUN".

:o
User avatar
jbperin
Flight Lieutenant
Posts: 480
Joined: Wed Nov 06, 2019 11:00 am
Location: Valence, France

Re: ChatGPT to make a BASIC program !

Post by jbperin »

Dbug have already made an evaluation of chapGPT for Basic on Oric.. and he's somewhat sceptical.



I personnaly plan to use Dall-e for some illustration.
User avatar
xahmol
Flight Lieutenant
Posts: 437
Joined: Sun Jun 28, 2020 7:32 pm
Location: Utrecht, The Netherlands
Contact:

Re: ChatGPT to make a BASIC program !

Post by xahmol »

Problem is that ChatGPT really can not distinguish one basic dialect from each other, so expect to get BBC Micro and C64 statements and pokes in an Oric Atmos listing.

It bases itself on open GitHub repos, and there are not that many open Oric Atmos GitHub repos out there, let alone in BASIC. So if it dishes out BASIC it is heavily biased to using dialects that are often to be found on GitHub (like BBC or C64 BASIC).
It’s also logical it can not distinguish dialects as it is based on GitHub repos. GitHub can correctly identify whether code is C, BASIC or assembly and shows that in the metadata of your reliable, but not which target platform it is intended for.

So for getting it to write BASiC, only very basic (no pun intended) examples make sense.

In getting it to write C for CC65 or getting it to write 6502 assembly code it has much more success. Also there, if it needs memory addresses it probably fails for the Oric and you get the C64 variants.

ChatGPT is great for programming, but only really usable for platform independent higher level languages. Some C code I got from it was rather useful (but you always need to check and adapt). And as I understand, VSCode and Visual Studio already are using ChatGPT for code suggestions.
Which by the way created mother controversy, as all repos you put as public on GitHub might actually end up as code snippet suggestion in VSCode or VStudio.
User avatar
Dbug
Site Admin
Posts: 4444
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: ChatGPT to make a BASIC program !

Post by Dbug »

goyo wrote: Fri Feb 03, 2023 7:22 pm I tried ChatGPT , it's truly impressive but when we asked for a bigger program it's more difficult for him.
As Xahmol already mentioned, it all depends of the training set.

In your particular example, I've to point out it did not even do what you actually asked. You asked for "hello" and it wrote "Hello", which indeed is a trivial difference, but it is a difference, and that's the number one thing with ChatGPT: It will gloriously provided you an answer with the confidence of a 5years old showing a completely out of proportion drawing of a car proud of their achievement.

The core thing with ChatGPT is that you have to be knowledgeable of the domain to be able to evaluate the quality of the result. Anyone who use this thing without actually knowing what a proper answer would be, will probably fail to find all the errors or approximations.

So as a tool to do faster what you already know how to do, sure.

As a tool to suggest APIs to use or how to use them when you already have a good idea about what you want to achieve, sure.

Using ChatGPT to provide an answer on something you don't know? You better have to triple check every single part of the answer and not using blindly, because you have zero guarantee about the content.

And then of course there are all the copyright issues, the fact these things are trained on data which can have licences and never outputs it, so you may be infringing on other's people rights.
User avatar
peacer
Flight Lieutenant
Posts: 451
Joined: Wed Jun 09, 2010 9:23 pm
Location: Turkey
Contact:

Re: ChatGPT to make a BASIC program !

Post by peacer »

As an interesting coincidence, I also tried to get Oric program written with chatgpt. The artificial intelligence system is incredibly successful and amazing. It's really impressive like a science fiction movie. Although the application initially wrote some faulty and random codes, it quickly learns and develops the code. I tried to give an example below.

Interacting with the robot is really fun :)


-------------------------------------------------------------

I want you to write a simple Oric atmos program . I will give you brief information about Oric coding especially in graphics

Sure, I can help you with that!

The Oric Atmos is a home computer that was popular in the 1980s. It had a 1 MHz 6502 processor and 48 KB of RAM, and it used BASIC as its programming language. The Oric Atmos had some unique features, such as a high-resolution graphics mode and a built-in sound chip.

To create a simple program that uses the high-resolution graphics mode on the Oric Atmos, we can use the following code:

vbnet
Copy code
10 MODE 2
20 FOR Y=0 TO 191
30 FOR X=0 TO 239
40 PLOT X,Y
50 NEXT X
60 NEXT Y
This program sets the graphics mode to mode 2, which is the high-resolution graphics mode that allows you to display 240 pixels horizontally and 200 pixels vertically. Then it loops through all the possible pixel positions on the screen and plots each one using the PLOT command.

To run this program on an Oric Atmos, you can enter the code into the BASIC interpreter and then type RUN to execute it. This will display a screen filled with dots, one for each pixel.

Note that this is a very simple example, and there are many more advanced techniques and features that you can use when programming on the Oric Atmos. However, this should give you an idea of how to get started with creating programs that use the high-resolution graphics mode.




peacer@gmail.com
Your code has many errors. Oric has no "mode" command to change graphic mode. To change into graphic mode "HIRES" command is used. To set cursor position on the screen CURSET command is used. CURSET X,Y,FB sets position of graphic coordinate to X,Y . If FB is 1 pixel is on. FB = 0 makes pixel off. 2 makes xor of the coordinate.
I apologize for the errors in my previous response. Here is an updated code that should work for setting the Oric Atmos to high-resolution graphics mode and plotting individual pixels:

vbnet
Copy code
10 HIRES
20 FOR Y=0 TO 191
30 FOR X=0 TO 239
40 CURSET X,Y,1
50 NEXT X
60 NEXT Y
This code sets the Oric Atmos to high-resolution graphics mode using the HIRES command, then loops through all the possible pixel positions on the screen and uses the CURSET command to plot each pixel at the specified X,Y coordinate with FB set to 1 to turn the pixel on.

To turn a pixel off or toggle its state, you can simply change the value of FB in the CURSET command to 0 or 2, respectively.

I hope this updated code helps, and please let me know if you have any further questions!




peacer@gmail.com
ORIC HIRES mode resolution is 240x200 . So X value can be 0-239 and Y value can be 0-199. So write a code to set HIRES cursor in the middle of the screen
Sure, here's some code that sets the HIRES cursor to the middle of the screen on the Oric Atmos:

Copy code
10 HIRES
20 X = 120
30 Y = 99
40 CURSET X,Y,1
This code first sets the Oric Atmos to high-resolution graphics mode using the HIRES command. Then it sets the X and Y variables to the middle of the screen: X is set to 120, which is half of the maximum X value of 239, and Y is set to 99, which is half of the maximum Y value of 199.

Finally, the CURSET command is used to set the HIRES cursor to the specified X and Y coordinates, and set the FB parameter to 1 to turn the pixel on.

I hope this code helps you get started with programming on the Oric Atmos, and please let me know if you have any further questions!




peacer@gmail.com
CIRCLE R,FB command draws a CIRCLE in radius of R. before using CIRCLE , graphic cursor must be set by CURSET command as I explained. So write a program which draws 20 different radius circles in the center of the screen
Sure, here's some code that draws 20 circles of different radii in the center of the screen on the Oric Atmos:

css
Copy code
10 HIRES
20 X = 120
30 Y = 99
40 FOR I = 1 TO 20
50 R = I * 5
60 CURSET X,Y,1
70 CIRCLE R,1
80 NEXT I
This code first sets the Oric Atmos to high-resolution graphics mode using the HIRES command. Then it sets the X and Y variables to the middle of the screen: X is set to 120, which is half of the maximum X value of 239, and Y is set to 99, which is half of the maximum Y value of 199.

The FOR loop then iterates 20 times, with the loop variable I ranging from 1 to 20. On each iteration, it sets the radius R to I * 5, which increases by 5 for each iteration.

The CURSET command is used to set the HIRES cursor to the center of the screen at the X and Y coordinates. Then, the CIRCLE command is used to draw a circle with the specified radius R and the FB parameter set to 1 to turn the pixels on.

After drawing each circle, the loop moves on to the next iteration and increases the radius R for the next circle.

I hope this code helps you get started with drawing circles in high-resolution graphics mode on the Oric Atmos, and please let me know if you have any further questions!




peacer@gmail.com
Now write a program for the Oric which draws random radius circles on random coordinates on Oric HIRES mode
Sure, here's some code that draws random circles of random radii and positions on the screen in high-resolution graphics mode on the Oric Atmos:

scss
Copy code
10 HIRES
20 FOR I = 1 TO 100
30 R = RND(30) + 1
40 X = RND(240)
50 Y = RND(200)
60 CURSET X,Y,1
70 CIRCLE R,1
80 NEXT I
This code first sets the Oric Atmos to high-resolution graphics mode using the HIRES command. Then, the FOR loop iterates 100 times.

On each iteration, it sets the radius R to a random integer between 1 and 30 using the RND function. It then sets the X and Y variables to random integer values between 0 and 239 and between 0 and 199, respectively, using the RND function.

The CURSET command is then used to set the HIRES cursor to the random X and Y coordinates, and set the FB parameter to 1 to turn the pixels on.

Finally, the CIRCLE command is used to draw a circle with the specified random radius R.

After drawing each circle, the loop moves on to the next iteration and selects new random values for the radius, X coordinate, and Y coordinate.

I hope this code helps you get started with drawing random circles in high-resolution graphics mode on the Oric Atmos, and please let me know if you have any further questions!




peacer@gmail.com
Your RND command is wrong. Oric RND command works like this. RND(X) Generates a random number between 0 and 1. If X<0 it starts a new sequence of random numbers using X. Calling RND with the same X starts the same random number sequence. X=0 gives the last random number generated. Repeated calls to RND(0) will allways return the same random number. X>0 generates a new random number between 0 and 1
Thank you for the correction! Here's the updated code that uses the correct RND command syntax for the Oric Atmos:

scss
Copy code
10 HIRES
20 FOR I = 1 TO 100
30 R = INT(RND(30)) + 1
40 X = INT(RND(240))
50 Y = INT(RND(200))
60 CURSET X,Y,1
70 CIRCLE R,1
80 NEXT I
This code first sets the Oric Atmos to high-resolution graphics mode using the HIRES command. Then, the FOR loop iterates 100 times.

On each iteration, it sets the radius R to a random integer between 1 and 30 using the RND function. To obtain an integer value, the result of RND(30) is passed to the INT function to round it down to the nearest integer, and 1 is added to ensure that the radius is never zero.

It then sets the X and Y variables to random integer values between 0 and 239 and between 0 and 199, respectively, using the RND




peacer@gmail.com
RND(x) Command creates value between 0-1. Any value of X >0 creates a number between 0 and 1. So RND (10) don't produce a number higher than 1. You can get a number between 1-10 by using N= RND(1) * 10
Thank you for the additional clarification on the RND command! Here's the updated code that uses the correct RND command syntax for generating random numbers between a specified range:

scss
Copy code
10 HIRES
20 FOR I = 1 TO 100
30 R = INT(RND(1) * 30) + 1
40 X = INT(RND(1) * 240)
50 Y = INT(RND(1) * 200)
60 CURSET X,Y,1
70 CIRCLE R,1
80 NEXT I
This code first sets the Oric Atmos to high-resolution graphics mode using the HIRES command. Then, the FOR loop iterates 100 times.

On each iteration, it sets the radius R to a random integer between 1 and 30 using the RND function. To obtain a random number between 1 and 30, the result of RND(1) is multiplied by 30 to get a random number between 0 and 30 (exclusive), and then INT function is used to round down the result to the nearest integer. Finally, 1 is added to ensure that the radius is never zero.

It then sets the X and Y variables to random integer values between 0 and 239 and between 0 and 199, respectively, using the RND function. Again, the RND(1) function is used to generate a random number between 0 and 1, which is then multiplied by 240 and 200 to get a random number between 0 and 239 and between 0 and 199 for the X and Y coordinates, respectively. Finally, the INT function is used to round down the results to the nearest integer.

The CURSET command is then used to set the HIRES cursor to the random X and Y coordinates, and set the FB parameter to 1 to turn the pixels on.

Finally, the CIRCLE command is used to draw a circle with the specified random radius R.

After drawing each circle, the loop moves on to the next iteration and selects new random values for the radius, X coordinate, and Y coordinate.

I hope this updated code helps you draw random circles with random radii and positions on the screen in high-resolution graphics mode on the Oric Atmos, and please let me know if you have any further questions!




peacer@gmail.com
Your code might generate circles out of the screen. this will create an error. So setting a graphic cursor on X, Y and drawing a circle in Radius R , X+R must not be over 299 and Y+R must not be over 199
Thank you for the additional clarification! You're absolutely right that the original code might draw circles outside of the visible screen, which could result in an error. Here's the updated code that takes this into account:

scss
Copy code
10 HIRES
20 FOR I = 1 TO 100
30 R = INT(RND(1) * 30) + 1
40 X = INT(RND(1) * 210) + 15
50 Y = INT(RND(1) * 170) + 15
60 IF X + R > 239 THEN X = 239 - R
70 IF Y + R > 199 THEN Y = 199 - R
80 CURSET X, Y, 1
90 CIRCLE R, 1
100 NEXT I
This updated code sets the Oric Atmos to high-resolution graphics mode using the HIRES command. Then, the FOR loop iterates 100 times.

On each iteration, it sets the radius R to a random integer between 1 and 30 using the RND function, just like before.

It then sets the X and Y variables to random integer values between 15 and 224 (instead of 0 and 239) and between 15 and 184 (instead of 0 and 199), respectively, using the RND function. These values have been adjusted to ensure that the circles will always be drawn within the visible area of the screen. The minimum value of 15 is chosen to ensure that the circles are not too close to the edge of the screen.

After setting the X and Y variables, the code checks whether X+R is greater than 239 or Y+R is greater than 199. If either of these conditions is true, it adjusts the X or Y value to ensure that the circle will not be drawn outside of the screen. Specifically, if X+R is greater than 239, the code sets X to 239-R to ensure that the circle's right edge will not extend beyond the screen's right edge. Similarly, if Y+R is greater than 199, the code sets Y to 199-R to ensure that the circle's bottom edge will not extend beyond the screen's bottom edge.

The CURSET command is then used to set the HIRES cursor to the random X and Y coordinates, and set the FB parameter to 1 to turn the pixels on.

Finally, the CIRCLE command is used to draw a circle with the specified random radius R.

After drawing each circle, the loop moves on to the next iteration and selects new random values for the radius, X coordinate, and Y coordinate.

I hope this updated code helps you draw random circles with random radii and positions on the screen while ensuring that they will always be drawn within the visible area of the screen in high-resolution graphics mode on the Oric Atmos, and please let me know if you have any further questions!




peacer@gmail.com
The code will give error if X-r and Y-r gets negative value as circle will be out of the screen
You're right! Thank you for catching that potential error. To make sure that the circle is always drawn within the visible area of the screen, we need to make sure that the CURSET command sets the cursor position to a valid coordinate that is within the screen bounds. Here is an updated version of the code that includes an additional check to ensure that X-R and Y-R are not negative:

scss
Copy code
10 HIRES
20 FOR I = 1 TO 100
30 R = INT(RND(1) * 30) + 1
40 X = INT(RND(1) * 210) + 15
50 Y = INT(RND(1) * 170) + 15
60 IF X - R < 0 THEN X = R
70 IF Y - R < 0 THEN Y = R
80 IF X + R > 239 THEN X = 239 - R
90 IF Y + R > 199 THEN Y = 199 - R
100 CURSET X - R, Y - R, 1
110 CIRCLE R, 1
120 NEXT I
This updated code is similar to the previous version, but includes two additional IF statements at lines 60 and 70 to make sure that X-R and Y-R are not negative. If either value is negative, the code adjusts the X or Y variable so that the circle will still be drawn on the screen.

The first IF statement at line 60 checks whether X-R is less than zero. If it is, the code sets X to R, which ensures that the left edge of the circle will be on the screen.

The second IF statement at line 70 checks whether Y-R is less than zero. If it is, the code sets Y to R, which ensures that the top edge of the circle will be on the screen.

The rest of the code is the same as before, with the CURSET command setting the cursor position to the adjusted X-R and Y-R values, and the CIRCLE command drawing a circle with the specified random radius R.

I hope this updated code helps you draw random circles with random radii and positions on the screen while ensuring that they will always be drawn within the visible area of the screen in high-resolution graphics mode on the Oric Atmos!
Post Reply