ChatGPT is seductive. It seems like you can just give it a robust prompt and have it spit out sparkling code. But sometimes the code it spits out just throws errors. And this doesn’t just happen when you ask it to generate code. Here’s a good video explaining the issue:
In any event, here’s an example of this problem that I encountered this morning. I was wondering whether you could use one line of Python to draw a chessboard and place the chess pieces in their correct starting positions. My intuition was, and remains, that this is possible. (There’s no practical reason, of course, why you would want this instantiated in one line of code. But I figure, if you can do it, why not?)
In any event, I told ChatGPT: “Write a terse Python script which will draw a chessboard, with the pieces in their starting position.”
Here’s what ChatGPT gave me:
board = {(i,1):"White Pawn",(i,6):"Black Pawn"} for i in range(8);board.update({(0,0):"White Rook",(1,0):"White Knight",(2,0):"White Bishop",(3,0):"White Queen",(4,0):"White King",(5,0):"White Bishop",(6,0):"White Knight",(7,0):"White Rook"});board.update({(0,7):"Black Rook",(1,7):"Black Knight",(2,7):"Black Bishop",(3,7):"Black Queen",(4,7):"Black King",(5,7):"Black Bishop",(6,7):"Black Knight",(7,7):"Black Rook"});[print(board[(i,j)] if (i,j) in board else "--",end=" ") for i in range(8) for j in range(8)];print()
Looks inscrutable. But it’s terse! So it must work, right?
Not so fast. Here’s what happens when I run the code in Replit:
Obviously that’s not a chessboard.
And therein lies the problem. ChatGPT understands what is meant by “terse” in the context of “Write a python script…” but it has no sense of whether its output is correct. The onus is on the user to verify whether the code is usable. If the next iteration of ChatGPT is able to verify the usability of the code it generates, that would be a game changer. But as of now the user is left with the responsibility. Trust, but verify, as it were. We are presently engaged in a grand experiment, limning ChatGPT’s capabilities and limitations.