Super Glop Arcade: an exercise in AI code generation
For me, LD59 was an attempt to accelerate my gamedev workflow using AI coding techniques, where my goal was to have my game code 100% AI generated, without losing control over the game design. I am interested in other LD entries that have mostly or fully AI generated code. As of yet I found only one game, called Codevibes, which is described as "vibe coded". So if you have an AI coded entry, please respond to this post and I will play your game!
This experiment is only about AI coding, as the graphics are hand drawn, and the (newly added) sound is generated using ZzFX (an SFXR variant). I managed to create 9 small games with 100% AI generated code in less than a day. These aren't very exciting from a gamer's point of view, but they serve to test my coding technique on different game mechanics.
Years ago did a similar exercise, where I created 8 games in a weekend, to test my (then newly updated) game library. The result is similar (I finished the games but they have some rough edges), but done in less time. So in that sense it was a success.
The rest of the LD period I adapted my game library to be more suitable for AI generation, while enjoying my vacation in Seville, which looks something like this:
Me having a vacation while the AI does all the hard work
Last week I tinkered some more with the games, ironing out some of the rough edges, and adding sound and particles.
>>>Play the original game and the postcompo here!<<
Now, about the technique I used. I did not use vibe coding, but instead, I use the AI as a 'compiler' to compile technical specifications into code. I split the game into components and then let AI generate each component. I used the WebCogs VS Code extension to specify component prompts via what I call 'prompt buildfiles', and also created a new VS Code extension for quickly generating sounds. The prompt buildfiles include overall technical specifications of the relevant game library functions, and for each component, a description of the component. I also instructed the AI to add configuration parameters (such as entity speed, fire rate, etc), so that each component can be configured by changing input parameters. I modified these manually to tweak the gameplay.
AI generated component types I now have are:
- map generators: these output maps with ASCII characters, which are converted to tiles and entities by the game library. Example prompt:
Create a function that generates a scramble type level. Each tile is either: wall (@), empty (.), rocket (!), UFO (u), or player (S). The level consists of a horizontal cave/tunnel, with varying position and height, with a minimum height of 6 and maximum height of 12. Rockets are placed randomly on the floor along the tunnel, and UFOs in the middle. The leftmost 20 tiles of the tunnel are straight. The player is positioned at the middle left.
- entities: describes the behaviour of each game entity after being placed on the map. An entity can spawn other entities, manipulate the tile map, collide with entities, etc. Example prompt:
Create an enemy that shifts slowly and smoothly around in a fixed pattern. Occasionally it swoops down in curved patterns until it encounters a wall, then flies back to its original position. When it swoops down, it shoots bullets towards the player, but only if the player is below or diagonally below the enemy. The enemy dies when it hits a player bullet. Bullets pass through player bullets.
- particle generators (newly added after the compo): generates particle effects given at a particular position and effect size, like smoke and explosions. Example prompt:
Create a particle generator that generates a flying fish firework effect. There are two types of particles: cloud and fish. The cloud particles are shown on top, are large and white, move slowly, and fade quickly. The fish particles first move away from the center, then veer away at random moments in random directions with angles up to 180 degrees. Choose 2 different saturated colors for every effect. Fish particles have either of these 2 colors.
The maps, entities, particles, and sounds are tied together into a game using a single javascript file with just configuration tables. This defines the ordering of the levels, the mapping between map characters and tiles/entities, and the available animations, and particle and sound triggers.
For example, a level is defined like this:
{
"name": "Space shooter", def: "stdlevel",
"type": "galaga",
"tilemap": { nrtilesx: 32, nrtilesy: 18},
bg: "levelbg",
"wincond": () => { return JGObject.countObjects(null,enemy_mask) === 0 }
},
Entities and tiles are defined like this:
// cave shooter
"Q": {entity: function(tx,ty)
{createEntity("caveplayer",false,tx,ty,player_mask,"caveplayer")}},
"C": {entity: function(tx,ty)
{createEntity("caveenemy",true,tx,ty,enemy_mask,"caveenemy")}},
"&": {tile:4, mask: getTileMaskDef("wall"),
onRemove: {particle: {type: "flame",size: 20,sprite:30}, sound: "dig"}},
And animations like this:
"caveenemy": {anim: {start:14,end:14,speed:0.2,always:false,vertical:true, dir:"nodir"},
onRemove: {
particle: {type: "fisheffect",size: 40,sprite:30},
sound: "caveenemyexplo"
},
},
Altogether a successful result, I think. The generated code was pretty good, considering the straightforward prompts I used, but the AI had trouble generating code for some of the maps, in particular the platform and pac-man levels. This can often be resolved by giving more specific instructions, such as what algorithm to use, but I did only limited prompt tinkering. Another was that in my current setup, I had a lot of maps, entities, sprites, particles, etc., to create all the 9 games, which became difficult to keep track of in the configuration tables. For example, I have about 30 different tiles and entities, which means I started running out of ASCII characters at some point. I tried to do everything from within VS code, with help of some extensions, but I may want to create a dedicated game development GUI at some point.