Generative Art with GPT4 #3: Labyrinth

View full-screen.

Multi-Line Animation

Even for a great coder (which I’m not) the path from a detailed plan to a working prototype can be long. Sometimes the journey is worth it, full of digression, adventure, or flow. But often it is tedious digital labour.

If coding is an uphill climb — either salutary or exhausting depending on one’s views — LLMs offer helicopter rides. It took one prompt on ChatGPT to code an animated labyrinth and a few more to refine until it achieved the above form.

The prompt was not: In HTML5 animate a labyrinth.

The underwhelming result of this is rendered below:

Animated Labyrinth

The first prompt was the result of a few minutes on my own part:

In HTML5, animate the drawing of a 2-pixel line that advances 5 pixels at each step. After each step it has a probability of 0.9 of continuing straight; 0.05 of making a 90-degree turn left; 0.05 of making a turn or right. If one of these moves would result in the line being 5 pixels in its direction of travel from another line section, then it should try one of the other moves. If all moves result in it being within 5 pixels, then a new line should be animated starting at least 5 pixels from any other line segment. Set the background colour to black. Use the palette #A66021 #07091C #19837E #11C55A #FFFD34 #B9FB4F #732401.

However, I could have been lazier and prompted ChatGPT to describe an algorithm for a labyrinth and subsequently create that. This is somewhat better, though rather imperfect — resulting in the below.

Coding as a game

Coding is itself a kind of labyrinth. I’m not referring to spaghetti code (though I’ve created more than my fair share of that), but it can be thought of as either:

  • A problem to be solved
  • Or a game to be played

In the first conception, the writing of code is no more than a means to an end, an impediment we can remove in any way that works — for example by generating the code with an LLM. In the second conception, the journey is important and coding conforms to Bernard Suit’s definition of a game:

Now returning to games, consider a third case. Again I am in the labyrinth, but my purpose is not just to be outside (as it might be if Ariadne were waiting for me to emerge), but to get out of the labyrinth, so to speak, labyrinthically. What is the status of the walls? It is clear that they are not simply impediments to my being outside the labyrinth, because it is not my purpose to (simply) be outside. For if a friend suddenly appeared overhead in a helicopter I would decline the offer of a lift,although I would accept it in the second case. My purpose is to get out of the labyrinth only by accepting the conditions it imposes, that is, by responding to the challenge it presents.

The Grasshopper — Bernard Suits

Suits was fond of referencing another sort of game: mountaineering. Until recently, code creation tools — WYSIWYG editors, boilerplate generators — have been like better snowshoes to mountaineers, but LLMs are helicopters. In five years, those who code from scratch will do it as a game.

Leave a Comment