Login
Back to forumSee the full topicGo to last reply

Posted By

AaronGale
on 2023-04-02
21:10:51
 Re: Program an adventure game with AI (Chat GPT)

ChatGPT can actually write some amazing code in many modern languages. Not always perfect but very functional.

It seems to be struggling to remember Commodore Basic 3.5 keywords, syntax and variable name contraints though.

For fun, I asked:

"Do you know the syntax and constraints of basic on the Commdore 16?"

Yes, I can assist you with BASIC programming on the Commodore 16.

The Commodore 16 uses a version of BASIC known as "Commodore BASIC 3.5", which is similar to the BASIC used on other Commodore computers, such as the VIC-20 and the Commodore 64.

Some key differences and constraints to keep in mind when programming on the Commodore 16 are:

The Commodore 16 has 16KB of memory, of which about 12KB is available for BASIC programming.
The screen resolution is 320x200 pixels with 16 colors available.
The Commodore 16 uses a different character set than the Commodore 64, which can affect the appearance of text on the screen.
The Commodore 16 does not have a built-in disk drive, so programs must be saved and loaded using a cassette tape or other external storage device.
The Commodore 16 uses a different set of keywords and commands than other BASIC dialects, although many are similar.
Let me know if you have any specific questions or if there's anything I can assist you with.


"Can you write me a simple program I can run on a Commodore 16?"

Certainly! Here's a simple program that prints "Hello, world!" to the screen:

10 PRINT "Hello, world!"
20 END

To run this program on a Commodore 16, you can type it in manually or load it from a saved file using the LOAD and RUN commands. Here are the steps to type it in manually:

Turn on the Commodore 16 and wait for the READY prompt to appear.
Type 10 PRINT "Hello, world!" and press ENTER.
Type 20 END and press ENTER.
Type RUN and press ENTER.
The program should now run and print "Hello, world!" to the screen.


"That worked, can you write me a longer program, say a very simple text based game?"

Sure, here's a simple text-based game you can try on your Commodore 16:

10 REM SIMPLE ADVENTURE GAME
20 REM BY CHATGPT
30 PRINT "WELCOME TO THE ADVENTURE GAME!"
40 PRINT "YOU ARE IN A ROOM WITH 3 DOORS."
50 PRINT "CHOOSE A DOOR TO ENTER (1, 2, OR 3):"
60 INPUT DOOR
70 IF DOOR = 1 THEN GOTO 100
80 IF DOOR = 2 THEN GOTO 200
90 IF DOOR = 3 THEN GOTO 300
100 PRINT "YOU ENTERED ROOM 1."
110 PRINT "THERE IS A KEY ON THE TABLE."
120 PRINT "TAKE THE KEY? (Y OR N):"
130 INPUT KEY
140 IF KEY = "Y" THEN GOTO 400
150 PRINT "YOU LEAVE THE KEY ON THE TABLE."
160 GOTO 500
200 PRINT "YOU ENTERED ROOM 2."
210 PRINT "THERE IS A MONSTER IN THE ROOM!"
220 PRINT "FIGHT OR RUN? (F OR R):"
230 INPUT ACTION
240 IF ACTION = "F" THEN GOTO 600
250 IF ACTION = "R" THEN GOTO 500
300 PRINT "YOU ENTERED ROOM 3."
310 PRINT "THERE IS A TREASURE CHEST IN THE ROOM."
320 PRINT "OPEN THE CHEST? (Y OR N):"
330 INPUT CHEST
340 IF CHEST = "Y" THEN GOTO 700
350 PRINT "YOU LEAVE THE CHEST ALONE."
360 GOTO 500
400 PRINT "YOU TOOK THE KEY."
410 PRINT "GO BACK TO THE DOOR AND CHOOSE ANOTHER ROOM."
420 GOTO 50
500 PRINT "YOU GO BACK TO THE DOOR AND CHOOSE ANOTHER ROOM."
510 GOTO 50
600 PRINT "THE MONSTER ATTACKS YOU AND YOU DIE!"
610 PRINT "GAME OVER."
620 END
700 PRINT "YOU FOUND THE TREASURE!"
710 PRINT "YOU WIN!"
720 END


At this point I went back and forth pointing out errors it made with type mismatches, string name mistakes, variable name mistakes etc.

Annoyingly each time you ask it to fix an error it rewrites the code completely in a different way usually.

So I asked it:

"Can you rewrite the program you gave me with corrections: Ensure variables are a single character, ensure string variables have a $."
I gave it the program above as input as well.

Sure, here's the corrected program with single character variable names and $ for string variables:
10 REM SIMPLE ADVENTURE GAME
20 REM BY CHATGPT
30 PRINT "WELCOME TO THE ADVENTURE GAME!"
40 PRINT "YOU ARE IN A ROOM WITH 3 DOORS."
50 PRINT "CHOOSE A DOOR TO ENTER (1, 2, OR 3):"
60 INPUT D$
70 IF D$ = "1" THEN GOTO 100
80 IF D$ = "2" THEN GOTO 200
90 IF D$ = "3" THEN GOTO 300
100 PRINT "YOU ENTERED ROOM 1."
110 PRINT "THERE IS A KEY ON THE TABLE."
120 PRINT "TAKE THE KEY? (Y OR N):"
130 INPUT K$
140 IF K$ = "Y" THEN GOTO 400
150 PRINT "YOU LEAVE THE KEY ON THE TABLE."
160 GOTO 500
200 PRINT "YOU ENTERED ROOM 2."
210 PRINT "THERE IS A MONSTER IN THE ROOM!"
220 PRINT "FIGHT OR RUN? (F OR R):"
230 INPUT A$
240 IF A$ = "F" THEN GOTO 600
250 IF A$ = "R" THEN GOTO 500
300 PRINT "YOU ENTERED ROOM 3."
310 PRINT "THERE IS A TREASURE CHEST IN THE ROOM."
320 PRINT "OPEN THE CHEST? (Y OR N):"
330 INPUT C$
340 IF C$ = "Y" THEN GOTO 700
350 PRINT "YOU LEAVE THE CHEST ALONE."
360 GOTO 500
400 PRINT "YOU TOOK THE KEY."
410 PRINT "GO BACK TO THE DOOR AND CHOOSE ANOTHER ROOM."
420 GOTO 50
500 PRINT "YOU GO BACK TO THE DOOR AND CHOOSE ANOTHER ROOM."
510 GOTO 50
600 PRINT "THE MONSTER ATTACKS YOU AND YOU DIE!"
610 PRINT "GAME OVER."
620 END
700 PRINT "YOU FOUND THE TREASURE!"
710 PRINT "YOU WIN!"
720 END


It works, the monster fight even made me laugh!



I tried something more complicated and it failed and got stuck generating code:

"Can you write something more complicated say with a Dwarf main character, 10 locations, NPC characters and enemies to fight and a way to escape the game and win? Also for a Commodore 16 in Commodore Basic 3.5, ensure variables are a single character, ensure string variables have a $, ensure arrays also are only a single character. Store data for the game in data statements."

Sure, here's a longer game with a Dwarf main character, 10 locations, NPC characters, and enemies to fight. The goal of the game is to find the treasure and escape the dungeon.

Note: This program is quite long, so make sure you have enough space on your Commodore 16 to store it.

10 REM DUNGEON QUEST
20 REM BY CHATGPT
30 REM C16 BASIC 3.5
40 DIM D$(10)
50 DIM L$(10)
60 DIM E$(10)
70 DIM F(10)
80 DIM Q$(2)
90 FOR I=1 TO 10
100 READ D$(I),L$(I),E$(I),F(I)
110 NEXT I
120 REM MAIN GAME LOOP
130 PRINT "WELCOME TO DUNGEON QUEST!"
140 PRINT "YOU ARE A DWARF ON A QUEST TO FIND THE TREASURE AND ESCAPE THE DUNGEON."
150 PRINT "ARE YOU READY TO BEGIN? (Y OR N)"
160 INPUT Q$
170 IF Q$ <> "Y" THEN GOTO 640
180 LOC = 1
190 HEALTH = 100
200 PRINT L$(LOC)
210 IF F(LOC) = 1 THEN GOTO 280
220 REM CHECK FOR ENEMY ENCOUNTER
230 IF RND(10) > 7 THEN GOTO 280
240 REM ENEMY ENCOUNTERED
250 PRINT "YOU HAVE ENCOUNTERED AN ENEMY!"
260 GOSUB 800
270 IF HEALTH <= 0 THEN GOTO 620
280 REM CHECK FOR NPC ENCOUNTER
290 IF RND(10) > 8 THEN GOTO 400
300 REM NPC ENCOUNTERED
310 PRINT "YOU HAVE MET AN NPC!"
320 GOSUB 500
330 GOTO 180
400 REM CHECK FOR TREASURE ENCOUNTER
410 IF RND(10) > 5 THEN GOTO 180
420 REM TREASURE FOUND
430 PRINT "YOU HAVE FOUND THE TREASURE!"
440 PRINT "NOW FIND YOUR WAY BACK TO THE ENTRANCE TO ESCAPE THE DUNGEON."
450 GOTO 540
500 REM NPC ENCOUNTER
510 PRINT "THE NPC SAYS: " + D$(LOC)
520 PRINT "DO YOU WANT TO TALK TO THEM? (Y OR N)"
530 INPUT Q$
540 IF Q$ <> "Y" THEN RETURN
550 PRINT E$(LOC)
560 RETURN
620 PRINT "YOU HAVE DIED! GAME OVER."
630 GOTO 700
640 PRINT "MAYBE NEXT TIME. GOODBYE!"
650 END
700 PRINT "CONGRATULATIONS! YOU HAVE ESCAPED THE DUNGEON WITH THE TREASURE!"
710 END
800 REM FIGHT ENCOUNTER
810 PRINT "A " + E$(LOC) + " ATTACKS YOU!"
820 ENEMY_HEALTH = INT(RND(1)*50)+50
830 WHILE ENEMY_HEALTH > 0 AND HEALTH > 0
840 PRINT "YOUR HEALTH: " + STR$(HEALTH)
850 PRINT "ENEMY HEALTH: " + STR$(ENEMY_HEALTH)
860 PRINT "WHAT DO YOU WANT TO DO? (FIGHT OR RUN)"
870 INPUT Q$
880 IF Q$ = "FIGHT" THEN GOSUB 900
890 IF Q$ = "RUN" THEN GOTO 270
900 REM PLAYER ATTACKS
910 DAMAGE = INT(RND(1)*10)+10
920 PRINT "YOU DEAL " + STR$(DAMAGE) + " DAMAGE TO THE ENEMY."
930 ENEMY_HEALTH = ENEMY_HEALTH - DAMAGE
940 REM ENEMY ATTACKS
950 DAMAGE = INT(RND(1)*10)+




Back to top


Copyright © Plus/4 World Team, 2001-2024