DEV Community

Cover image for I Let Free Web Gemini Code My Terrarium, and Now the Worms are Having an Identity Crisis
EffessDev
EffessDev

Posted on

I Let Free Web Gemini Code My Terrarium, and Now the Worms are Having an Identity Crisis

I built a terrarium simulation using Pygame a while back:

Terrarium

Let's check whether Gemini can add entirely new features to this Python codebase without blowing everything up.

Let's open up the project in VS Code:

Project opened in VS Code

I am using ReptClip for VS Code (an extension I built) to build the context and apply the diffs.

Let's addREADME.md, requirements.txt, and all Python files into the context (I know it's not ideal, but let's try):

Typing files into ReptClip

Already 64,000 tokens. Let's paste it in:

What? The browser chat UI silently truncated the context I pasted in, without showing a single warning!

Luckily, the limit is larger if you upload the context as a file:

Let's type the prompt and hit send!

A 108-line diff. Now, I can copy the diffs and click Apply Diffs in my extension. It will automatically read them from the clipboard and apply the changes:

Let's try once more:

Even though ReptClip supports fuzzy matching in SEARCH blocks, the AI hallucinated too much, so the extension wasn't able to find a match.

Here is my new plan:

  1. Give the AI only the project structure, README, and requirements.txt
  2. Ask it which files it needs to see to implement the feature

It gave a list of the files it wants to see:

Since we already added the project structure and output format, let's uncheck them and add the files Gemini asked for:

Luckily, this time it didn't get truncated:

The new diff was 165 lines:

Let's apply the diffs:

Only one fuzzy match. Let's launch the terrarium:

There we go! We got the feature we asked for.

Time to make it harder. The new feature:

A suspiciously tiny diff that literally fits into a single screenshot:

I applied it anyway:

And ran the simulation:

The worms looked a bit different, but it was definitely far from what I asked. Let's try again with Gemini Pro.

It's using some big words:

It gave me a 265-line diff modifying 2 files. Let's see what it did.

I can't even see the worms.

I thought maybe they were still growing. I waited in front of the simulation at 8x speed for days*:

Still empty. Let's try with Gemini Extended Thinking:

According to Gemini, it found the exact bug:

I applied its recommended patch:

Still no worms.

Let me handle this alone without taking a screenshot every 5 seconds. I'll come back soon.

🏃 ...

So, according to Gemini, this was the reason:

Anyway, I gave it ant.py so it could refer to it and generate proper diffs. This time, I was able to see something!

Now THAT is what actual peristalsis looks like!

I think that's enough for now without breaking it even more.

Top comments (16)

Collapse
 
unitbuilds profile image
UnitBuilds •

That's awesome! I actually did a thing similar a few months ago, but an antfarm, turned 3d, then stopped, cuz it was becoming a pain to get the procedural renderer working right. That being said, I wanna still figure it out at some point. The idea was cool, it was for the gemini + Elevenlabs weekend challenge, the ant's status gives it an internal monologue that elevenlabs talks to you.

Collapse
 
effessdev profile image
EffessDev •

I have to check it out! But I couldn't find it in your GitHub.

Collapse
 
unitbuilds profile image
UnitBuilds •

I'll public'd it for ya: github.com/UnitBuilds-CC/AI-Antfarm

Thread Thread
 
effessdev profile image
EffessDev •

Thanks!!! 🙂 It's Next.js??! Let me reach home so I could try it!

Thread Thread
 
unitbuilds profile image
UnitBuilds •

Yeah, I tried to use all 3 the sponsored fields. Cuz why not. If you like games though, I did make a game engine back when I was making the LLM to Game series, github.com/UnitBuilds-CC/Game-Gen it's not Godot, but it was purpose built to let a LLM do more, so feel free to give it a try too if you like

Thread Thread
 
effessdev profile image
EffessDev • • Edited

I had seen it already! I had also tried a few of your games too! On DEV.

Thread Thread
 
unitbuilds profile image
UnitBuilds •

Yeah, I just got sad that they never applied my PR that would have given me scaling for my Embeddings. It was a pain trying to fit games into the tiny frame without a scaler. That + lack of time lead me to just stop with the series, even though I liked making them and I expanded on the engine with each game I made, that way it's lean, but as it falls short, I expand it.

Thread Thread
 
effessdev profile image
EffessDev •

Even I don't know what I am doing 😄

Thread Thread
 
unitbuilds profile image
UnitBuilds •

Yeah, it was still very early stage...

Thread Thread
 
effessdev profile image
EffessDev • • Edited

The ants dig holes themselves. That's cool!

Thread Thread
 
unitbuilds profile image
UnitBuilds •

The idea was that the ants should decide when they need more space and expand themselves, but it was still very early stage, stuff like contamination and isolation werent implemented yet, because I switched focus to getting it 3d voxel based instead, so to dig, they have to move grains of sand from inside, out. But that made observability an issue, so had to implement skinning and thresholding, so you can navigate into the tunnels and see them from above ground (xray). Then also wanted them to go harvest from fruit, not just sugar drops, so they have to navigate via scent to the nearest fruit, rotting fruit smells more, but only 'ripe' fruit can be harvested, etc. Overall way too much to fit in a weekend project, but the idea was cool. Eventually, I wanted to get 1 of those LCD panels for a pc, then have them exist in there as a 'terrarium in my pc', but try finding 1 of those...

Thread Thread
 
effessdev profile image
EffessDev •

Really ambitious idea! But I want to see Dwarven Stronghold first.

Thread Thread
 
unitbuilds profile image
UnitBuilds •

On the brightside, the sim loop of DS can easily be ported, so it'll be an actual weekend project turning it into an antfarm, cuz DS was actually started as a direct result of it. That being said, still a long way to go, but I'm hoping it does the original justice! Luckily, because of the hub and spoke design, adding/editing/modding should be a breeze!

Thread Thread
 
effessdev profile image
EffessDev •

I also like ants a lot! I have tried to build a real ant aquarium multiple times, where I can actually see the inside of the nest it builds. I've tried several variations, but none of them really worked. I even took several queens from the backyard.

Thread Thread
 
unitbuilds profile image
UnitBuilds •

I much preferred making eternal terrariums in lightbulbs

Collapse
 
effessdev profile image
EffessDev •

Hello?