| Posted By
Haegar on 2025-01-20 14:53:44
| Programming with CHATGPT
Have any of you ever used CHATGPT to create a program?
I tried it out and asked for a program to calculate a flight path in Basic 3.5. The first attempt was very good, but unfortunately CHATGPT didn't yet know the difference between BASIC 2 and BASIC3.5. After a few small tips, such as replacing PLOT with DRAW, I already had the first program that worked. After I pointed out that the Hires mode is 360 pixels wide and not 160, CHATGPT even suggested that I adapt the program for both modes. Here is the result after less half an hour work:
10 REM BALL THROW SIMULATION WITH WIND IN COMMODORE BASIC 3.5 20 REM INITIALIZE VARIABLES 30 V0 = 20: REM INITIAL VELOCITY (M/S) 40 ANGLE = 45: REM LAUNCH ANGLE (DEGREES) 50 G = 9.81: REM GRAVITATIONAL ACCELERATION (M/S^2) 60 WIND = 0.5: REM WIND ACCELERATION (M/S^2, POSITIVE = TAILWIND, NEGATIVE = HEADWIND)
70 RAD = ANGLE * PI / 180: REM CONVERT ANGLE TO RADIANS 80 VX0 = V0 * COS(RAD): REM INITIAL HORIZONTAL VELOCITY 90 VY0 = V0 * SIN(RAD): REM INITIAL VERTICAL VELOCITY 100 TMAX = (2 * VY0) / G: REM MAXIMUM FLIGHT TIME 110 DT = TMAX / 100: REM TIME STEP
120 REM SELECT GRAPHICS MODE 130 PRINT "select graphics mode:" 140 PRINT "1 - hi-res (320x200)" 150 PRINT "2 - multicolor (160x200)" 160 INPUT "enter choice (1 or 2): "; MODE 170 IF MODE = 1 THEN GRAPHIC 1,1: SCX = 10: SCY = 5: GOTO 200 180 IF MODE = 2 THEN GRAPHIC 3,1: SCX = 5: SCY = 5: GOTO 200 190 PRINT "invalid choice! try again.": GOTO 130
200 REM SIMULATE THE FLIGHT PATH 210 FOR T = 0 TO TMAX STEP DT 220 X = VX0 * T + 0.5 * WIND * T^2: REM HORIZONTAL POSITION WITH WIND 230 Y = VY0 * T - 0.5 * G * T^2: REM VERTICAL POSITION 240 IF Y < 0 THEN GOTO 300: REM AVOID DRAWING BELOW THE GROUND 250 PX = INT(X * SCX): REM SCALE HORIZONTAL POSITION TO SCREEN 260 PY = 100 - INT(Y * SCY): REM SCALE VERTICAL POSITION TO SCREEN (REVERSE Y-AXIS) 270 IF PX > 319 OR PY > 100 THEN GOTO 300: REM STOP IF OUT OF BOUNDS 280 DRAW 1,PX,PY: REM DRAW AN ISOLATED POINT 290 NEXT T
300 REM WAIT FOR USER INPUT TO END 310 PRINT "press any key to exit." 320 GETKEY A$: REM WAIT FOR A KEY PRESS 330 GRAPHIC 0: REM EXIT GRAPHICS MODE 340 END
It's amazing what you can do with it. But to avoid any questions, of course I will continue to program my projects by myself in the future.
|
|
Posted By
Luca on 2025-01-20 15:00:26
| Re: Programming with CHATGPT
Yes, I guess we all did it years ago. And guess what, it has been a big laugh
|
|
Posted By
MMS on 2025-01-20 19:14:05
| Re: Programming with CHATGPT
Actually, I also made some trials, just to generate picture in Commodore format. Hires or multicolor, best fit for the converters.
I saw some REALLY good ones on C64 so I had high hopes, but meh.
Matt with Robert Ramsay created some stunning stuff with the help of AI: https://csdb.dk/scener/?id=3835
Probably I was not so prepared as him, or maybe I chose a bad tool.
First of all the AI was not willing to create 4:3 ratio pictures. It created much higher resolution pictures, than 320x200. Then I asked to use only 16 Commodore 16 or C64 colors, then it refused to do it, but still stated as a 16 color picture. Seeing the picture I did not believe it, and I was right, I saved the picture, and Irfanview told it has 140 colors,
It had no clue about the attribute clash limiation, I mean it told it knows it, but still created pictures did not count with that limitation.
So I suppose the best part of the AI to state something what is not true, and still stating after asking, that it is what I asked. What a liar!
|
|
Posted By
Haegar on 2025-01-21 13:32:10
| Re: Programming with CHATGPT
I've already experimented with creating graphics.
Unfortunately, ChatGPT crashed on the first real image or I reached the daily limit. But I had it at the point where a block is 4*8 pixels and a multicolor pixel is 2 bits wide to store the color information. It looked good in the test images (checkerboard and crosses). The next step was to explain the memory allocation to ChatGPT.
I'll report when I've achieved something.
@Luca: I was inactive for over 20 years, so I must have missed the hype about ChatGPT and I discovered it now.
|
|
| |
Copyright © Plus/4 World Team, 2001-2025. Support Plus/4 World on Patreon |