Fun with AI: We Still Need Thinking

We Still Need Thinking

Recently, as an intellectual exercise I wanted to write a program to play “Psych-Out” (also called Flip-It), which is a small hand held plastic implementation of a game of Nim. I sought ChatGPT’s assistance in program the game for solo console play, first in Python and then in Ada.

ChatGPT is good at Python and in no time at all I had the game finished. Here is a screen shot of the first screen, where the player begins “removing chips.”

Psych Out game display programmed in Python

Then, I moved along to the Ada version. Early on, ChatGPT developed a version that worked, but the alignment of the chips was not right. It looked like this:

Psych Out game display programmed in Ada

I tried three or four times to get it to correct the code but it kept getting nowhere. I realized it was oscillating between two versions, going back and forth and decided to step in. Looking at the problem, I realized pretty quickly it had aligned the chips, but failed to consider the different lengths in the row labels. I merely changed the definition of Top from “TOP” (three characters) to “TOP ” (six characters, including three spaces) and the difficulty was instantly handled.

Getting the Ada version to display pink color “chips” was another issue. Ada naturally defaults to ASCII. To display color on an ANSI-capable console – and to use the solid vertical block character – it’s necessary to use Unicode (UTF-8). Ada can do this by use of the predefined type Wide_Wide_Character, as opposed to the easier and more common predefined type Character. ChatGPT tried all kinds of tricks and work-arounds attempting to make Character work. Only when I specifically told it to just accept reality and use Wide_Wide_Character did it give up trying longer, harder approaches and go with the straightforward Unicode character set.

Another point is that the program specification called for the player to input moves by either entering the desired row name, or simply the first letter of that row name. ChatGPT designed an approach in Ada that worked, but it was much simpler to just inspect the first letter of the string input by the player, and I replaced several lines of code with one, much simpler statement in Ada.

From my viewpoint, ChatGPT (AI in general) is pretty good at doing arcane, complicated, and repetitive things well. When so directed, it could and did write “good Ada code,” including language cultural approaches such as full use of code unit modularity, enforced separation of declarative parts and executable parts, and meaningful naming conventions. But left to its own, ChatGPT wrote Ada code in a Python like-approach: any time a new variable was needed an additional Declare block was thrown in to avoid thinking forward. Variable and constant names all come out as one-letter titles; when instructed to avoid use of single letters, ChatGPT uses variable names like c1, c2 and so on. With input of detailed expectations, the Ada code came out very good from the start.

Thinking is still required.