Cave Visualiser Tool

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andrew Davie

This video shows a new tool I use for visualising caves.  Caves are defined as a sort of text-based mini-program telling the decoder where to put various elements, size, etc. Normally to visualise this I've been making a change then running, then playing the cave. But it's real hard to get a good idea of what the entire cave looks like, as the screen shows a small window into a larger cave (usually).

I got the idea of a tool that will parse the source code, find the various graphics elements, and render an image of that cave. It's all working beautifully and although I'd like to say I'm brilliant -- all of this work was done by Claude. It's really quite remarkable.  Maybe half an hour from the basic idea to the completed product - after revisions.

Here's the initial prompt, from which Claude developed a Python tool that worked first time and essentially produced the images shown here. Refinements were to things like showing the Player, putting in the rounded corners, and changing the aspect ratio. In fact I'll show all my prompts.

Quotewrite me a tool that will create an image representation of each of the caves. It will effectively decode the cave the same way decodecaves does, then use the characterset to figure out the pixels etc and give me a visual png for each of the caves, saved in a directory cave_images

Quotebrilliant and working perfectly. TY.  Please adjust the size of the image to use the extents with a border of 1 (accounting for the surround).

QuoteGood.  The bottom Y is +1 by design, so reduce depth by 1.  Account for the aspect ratio of pixels (i.e., widen the image)

Quotegreat. TY.  add for each cave definition a link  // file://cave_images/* so that I can click to the cave image.

Separately, look at drawScreen and how it puts in corners in some characters. Try and replicate that in the images please.

QuoteGREAT. TY.  Install the tool in the regular build process so it happens whenever caveData.c changes

Quotegreat.  please add the player sprite at the player's starting position. Use the facing forward frame.

Quotefucking brilliant. ty

Note that the tool puts in the corners of the dirt, adds the player in starting position, renders with correct colours pulled from the source graphics, and even gets the player colours from source.  It also trims the image to correct size.

In the video I make some changes to a cave, show the generated image change when I do a build, and even show the new version running in the emulator.

I could of course write this stuff myself - but it would have taken me many days to get to this stage. And Claude has done it in, as I said - well, intial version was roughly 2 minutes.  But half an hour to refine everything to my satisfaction.

Now, designing caves is going to be sooo much easier.


Here's a prior text-version that I embedded in source code, from Boulder Dash.
    /*
    ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
    ▓░░░░◀● ●░░░░░●●░░░░● ● ░◀░░░●░░ ░░●●░░▓
    ▓░░R░ ░░░░░░●●░░░● ◀░ ░░● ░░░░░●░● ░●░░▓
    ▓ ░░◀░░░░░░░░ ░░░░● ░░ ░░░●░░░ ░ ░   ░◀▓
    ▓  ●●◀░░░●░░░░░●◀░░░●░░░●░░░░◀◀░░░░●░░░▓
    ▓░░░░░●░ ░░●░░ ░░◀●░░░░●░●  ░░●░░ ░░ ░●▓
    ▓░░░░ ░░░░◀ ░░░░  ░░●░ ░●░░  ░░░░░░●░░░▓
    ▓▞▞▞▞▞▞▞▞▞▞▞▞▞▞▞▞▞▞▞▞▞▞▞▞▞▞▞▞▞▞▞◀●░░░░░▓
    ▓●●░◀░░ ●░░░●░●░◀░░░░░●░░░░◀●░░░◀░░░  ░▓
    ▓░░░░ ░░●░░ ● ░░ ░░░ ░ ● ●░░●░  ░░░ ●░░▓
    ▓░●░░●●░◀░░░░░●░░░░░░░░░ ░░░░░ ●░ ░  ░ ▓
    ▓●░░░░░░░░░░░░░░░░░◀ ░░░●░░░    ░●●◀░  ▓
    ▓●░░░● ●░░ ░●░░░●░░ ░●░●░● ●░░  ░░░░░ ░▓
    ▓░░ ░ ●●░◀ ●●░░ ░ ░░░◀●●░░░◀░ ●░● ░░●░░▓
    ▓●● ░░░░▞▞▞▞▞▞▞▞▞▞▞▞▞▞▞▞▞▞▞▞▞▞▞▞▞▞▞▞▞▞▞▓
    ▓░░░░●░░░● ░░░● ░● ●░░░  ░░ ●░░░░ ░░ ●░▓
    ▓░░  ░●░░●  ●   ░░░●░░●●●●● ░░●░●░●●  E▓
    ▓░● ░░░●░░░░●░●●░ ░●░░●●●░◀░●░ ░●░●░░░●▓
    ▓░░░ ░●●   ░░░░░░░●●░░◀░●░░░░░░░  ░ ░ ░▓
    ▓░░░░░░░░░░ ░●░●●░░░░●░●░●░◀ ░░◀●░░░●░ ▓
    ▓░●░● ●●░░░● ░░░░░░░ ░░░░●░░● ░░░░░░●░░▓
    ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
    level 0
    26 diamonds

I mean, it's cool and old-skool, but ultimately not nearly as good as the new system. I wrote that tool myself (!), years ago, but I recently thought "I wonder if VSCodium" can embed links in source code - which it can!  So now I generate images, with a clickable link in the cave data.

const unsigned char P3_starsAndStripes[] = {
    // file://./../cave_images/cave_P3_starsAndStripes.png

Above, the clickable link embedded in code, so to see the cave's rendering I just Cmd-click that link and Bob's your uncle!