Sacred Potato Productions

Home      Blog      Chuck & Bernie      Music      Info       RSS
spp > blog > chatgpt_presents_mr._dont!
< Programming annoyances Archive In appreciation of Culver's Pumpkin Spice Shake >

Depressing adventures in generative AI

Published Wednesday, October 10, 2024 at 7:17pm

It's hard to say how I feel about AI at any given moment. On one hand, it's amazing that I can type a sentence into a text box on a website which will turn it moments later into a slick, three-minute pop song. On the other hand, it's hard to get excited about that when authors of best-selling e-books freely admit that they haven't actually read a single word of their most popular novel.

Still, it's fun to play with AI which seems to get more capable every time I turn around. I did my first experiments with generative AI a couple of years ago, and the results were, if not impressive, then at least interesting (at left: "Sammy Davis Jr. not particularly thrilled to be afloat on an ocean of lard" from late December 2022). My feelings about using AI for creative work are very conflicted and it's hard not to be pessimistic about the future of working artists. We read exponentially more news than we used to, but the value of traditional journalism has never been lower, and I think the arts are headed in the same direction. AI's proponents like to point out that technology has always had detractors, but the difference in effort and talent between a good visual artist and somebody who's good at generating AI prompts is an insurmountable gulf compared to the difference in effort and talent between a good painter and a good digital artist.

As I said, though, I do enjoy playing idly with AI. I've been seeing people talk about using ChatGPT to cover up their inexperience with new programming languages, and I started wondering if I could make it write a program in an old, unpopular language, like, say, a machine-specific dialect of BASIC like the one on which I cut my first programming teeth.

Mr. Do! was a popular video game in the early '80s, and I've seen it referenced for years but am slightly too young to have ever actually seen it. I ran across the name Mr. Do! again a couple of weeks ago. decided to look it up, and discovered that there's an Android version. I downloaded it and was quickly reminded that no matter how much fun it might have been on original hardware, it's really hard to play old games on a touchscreen rather than with physical buttons. Thinking about this, I asked ChatGPT to write me a Mr. Do! clone in GW-BASIC, which was bundled with the earliest versions of MS-DOS. A lot of programmers will roll their eyes and tell you that you can't do something as complex as Mr. Do! in BASIC, and that might have been true in the early '80s on an 8-bit machine, but modern computers are literally thousands of times faster; a game that was unplayably slow on an 8088 needs to be throttled on a modern machine to keep it from running too fast. This is what ChatGPT came up with:

Creating a full clone of a game like Mr. Do in GW BASIC is quite complex, given the limitations of the language and the need for detailed graphics and gameplay mechanics. However, I can help you get started with a basic framework for a simple game. Here's a very basic example to get you started:

10 REM Mr. Do Clone in GW BASIC
20 REM Initialize the game
30 SCREEN 0: WIDTH 80
40 CLS
50 PRINT "Welcome to Mr. Do Clone!"
60 PRINT "Use W, A, S, D to move. Press Q to quit."
70 PRINT "Collect all the cherries to win!"
80 PRINT "Press any key to start..."
90 WHILE INKEY$ = "": WEND
100 REM Game variables
110 DIM grid(10, 10)
120 playerX = 5: playerY = 5
130 cherries = 10
200 REM Initialize grid
210 FOR i = 1 TO 10
220 FOR j = 1 TO 10
230 grid(i, j) = 0
240 NEXT j
250 NEXT i
260 REM Place cherries
270 FOR i = 1 TO cherries
280 x = INT(RND * 10) + 1
290 y = INT(RND * 10) + 1
300 IF grid(x, y) = 1 THEN GOTO 280
310 grid(x, y) = 1
320 NEXT i
400 REM Main game loop
410 WHILE cherries > 0
420 REM Draw grid
430 CLS
440 FOR i = 1 TO 10
450 FOR j = 1 TO 10
460 IF i = playerX AND j = playerY THEN
470 PRINT "P";
480 ELSEIF grid(i, j) = 1 THEN
490 PRINT "C";
500 ELSE
510 PRINT ".";
520 END IF
530 NEXT j
540 PRINT
550 NEXT i
560 REM Get player input
570 k$ = INKEY$
580 IF k$ = "q" OR k$ = "Q" THEN END
590 IF k$ = "w" OR k$ = "W" THEN IF playerX > 1 THEN playerX = playerX - 1
600 IF k$ = "s" OR k$ = "S" THEN IF playerX < 10 THEN playerX = playerX + 1
610 IF k$ = "a" OR k$ = "A" THEN IF playerY > 1 THEN playerY = playerY - 1
620 IF k$ = "d" OR k$ = "D" THEN IF playerY < 10 THEN playerY = playerY + 1
630 REM Check for cherry collection
640 IF grid(playerX, playerY) = 1 THEN
650 grid(playerX, playerY) = 0
660 cherries = cherries - 1
670 END IF
680 WEND
700 REM Game over
710 CLS
720 PRINT "Congratulations! You've collected all the cherries!"
730 END

This code sets up a simple grid-based game where the player can move around and collect "cherries." It uses text graphics and simple controls. To run this code, you would need to have a GW BASIC interpreter. This is a very basic framework, and there are many improvements and features you could add, such as enemies, more complex movement, scoring, and levels.

This is amazing, but it's also underwhelming. On one hand, I would not have thought until recently that it would be possible to make such a request in plain English and get anything even vaguely resembling a functional program. On the other hand, this is not Mr. Do!, and I have a lot of problems with the way it's written. I understand the choices, but they're bad ones.

First of all, this is much simpler than Mr. Do!, a game in which you must fend off monsters with a superball while you harvest cherries. It's basically Dig Dug with just enough added complexity to have prevented it from being a classic on the same level as Dig Dug. It's hard to classify this program as a game. You're presented with a rectangular playing field represented by a grid of periods. Dotted randomly across the playing field are ten cherries represented by the letter C, and you move yourself (the letter P) around the grid to collect the cherries. Once all ten cherries are collected, you receive a message of congratulation and the game abruptly ends. There are no enemies.

That's not to say that it isn't challenging, though, by virtue of a handful of really bad programming choices. You move around the grid using the W, A, S, and D keys which are standard in modern games where your left hand moves you and your right hand stays on the mouse, but the arrow keys would have been more appropriate back when people were still using GW-Basic. Much worse, the screen is constantly being redrawn. The main loop of the program clears the screen, displays the playing field, checks to see if you've pressed a key and responds appropriately if you have, and then repeats the process until you either win or quit. The playing field is drawn one character at a time, left to right, top to bottom, which means that the elements in the upper left are on screen the longest, and the screen is cleared immediately after drawing the character in the lower right. So, the upper left blinks quickly, and the lower right flickers so fast that you can barely see it, or tell when you've moved to that part of the playing field.

Programming is a very forgiving process, in that there are lots of ways to approach a problem, and most of them are acceptable. Crappier programmers might pause the program to wait for a keypress and then redraw the whole screen (slightly better than a quick check and an immediate redraw), but I think most of us would draw the whole playing field once, wait for the user to press a key, and then update only the parts that have changed. Adding moving enemies to this game wouldn't be difficult, but it still has a long way to go before most people would call it fun.

Okay, so, Mr. Do! was a bust. I wondered how ChatGPT would fare at writing an adventure game and asked it to write me one in BASIC for the TI-99/4A, which was the very first computer I owned:

Sure, let's create a simple text-based adventure game in TI-99/4A BASIC. Here's a basic outline and code to get you started:

100 CALL CLEAR
110 PRINT "WELCOME TO THE ADVENTURE GAME!"
120 PRINT "YOU FIND YOURSELF IN A DARK FOREST."
130 PRINT "YOU CAN GO NORTH, SOUTH, EAST, OR WEST."
140 INPUT "WHICH DIRECTION DO YOU WANT TO GO? "; D$
150 IF D$="NORTH" THEN GOTO 200
160 IF D$="SOUTH" THEN GOTO 300
170 IF D$="EAST" THEN GOTO 400
180 IF D$="WEST" THEN GOTO 500
190 PRINT "INVALID DIRECTION. TRY AGAIN."
195 GOTO 140
200 PRINT "YOU GO NORTH AND FIND A RIVER."
210 PRINT "DO YOU WANT TO SWIM ACROSS OR GO BACK? (SWIM/BACK)"
220 INPUT ""; A$
230 IF A$="SWIM" THEN GOTO 600
240 IF A$="BACK" THEN GOTO 100
250 PRINT "INVALID CHOICE. TRY AGAIN."
255 GOTO 210
300 PRINT "YOU GO SOUTH AND FIND A CAVE."
310 PRINT "DO YOU WANT TO ENTER OR GO BACK? (ENTER/BACK)"
320 INPUT ""; A$
330 IF A$="ENTER" THEN GOTO 700
340 IF A$="BACK" THEN GOTO 100
350 PRINT "INVALID CHOICE. TRY AGAIN."
355 GOTO 310
400 PRINT "YOU GO EAST AND FIND A MOUNTAIN."
410 PRINT "DO YOU WANT TO CLIMB OR GO BACK? (CLIMB/BACK)"
420 INPUT ""; A$
430 IF A$="CLIMB" THEN GOTO 800
440 IF A$="BACK" THEN GOTO 100
450 PRINT "INVALID CHOICE. TRY AGAIN."
455 GOTO 410
500 PRINT "YOU GO WEST AND FIND A VILLAGE."
510 PRINT "DO YOU WANT TO EXPLORE OR GO BACK? (EXPLORE/BACK)"
520 INPUT ""; A$
530 IF A$="EXPLORE" THEN GOTO 900
540 IF A$="BACK" THEN GOTO 100
550 PRINT "INVALID CHOICE. TRY AGAIN."
555 GOTO 510
600 PRINT "YOU SWIM ACROSS THE RIVER AND FIND TREASURE! YOU WIN!"
610 END
700 PRINT "YOU ENTER THE CAVE AND FIND A BEAR! YOU LOSE!"
710 END
800 PRINT "YOU CLIMB THE MOUNTAIN AND FIND A WISE SAGE WHO GIVES YOU A MAP! YOU WIN!"
810 END
900 PRINT "YOU EXPLORE THE VILLAGE AND FIND FRIENDLY LOCALS WHO HELP YOU. YOU WIN!"
910 END

I feel like most non-programmers could get a pretty good idea of how this program works by studying the code, and it helps that this is a terrible example of an adventure game. Most of what we think of as "text adventures" accept simple sentences from the player and respond accordingly. The programming for that sort of thing isn't exactly fancy, but it would probably be impenetrable if you're not famliar with code. The example above doesn't give the player any flexibility; instead of accepting sentences it accepts only single words, and it tells you which words it can take any any given time. This isn't an adventure game; it's barely even Choose Your Own Adventure. I wrote my first games in 4th grade, and they were like this but more complex. I always wrote a lot more text, had more branching paths, ASCII art, and preferred to give numbered choices rather than asking the user to enter a word ALL IN CAPS. They weren't very good but they were much better than this.

After reading through this listing, I asked ChatGPT to convert it to a Bash script. Bash is a command line interface for Unix-like operating systems, and it has an extremely powerful scripting language. ChatGPT obliged with a somewhat less user-friendly version of the program above. It's perfectly feasible to exactly replicate the functionality of this program in Bash, but ChatGPT decided to paint in very broad strokes. As written in BASIC, the game tells you if you've mistyped one of your choices and lets you correct it. The Bash script does not afford you such luxury; every choice is binary, and you either make exactly the right choice, or you've made the other one. If, given the choices of CLIMB and BACK, you type "climb" in lowercase or type "CLUNV" because your right hand is on the wrong keys, it responds as if you've entered "BACK."

Anyway, ChatGPT's inability to tackle these tasks appropriately has me feeling a little better about the state of things, but that won't last long. In 2019, you could recognize AI photos because the ears and the eyeglasses were all messed up. A couple of years later the ears and eyeglasses were fine but the hands had too many fingers. These days the hands look okay, and Mr. Do!: The Text Adventure is probably just around the corner.

< Programming annoyances Archive In appreciation of Culver's Pumpkin Spice Shake >


Creative Commons License

This page available under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Some rights reserved, .