Regret, Recursion, and Minecraft

For a while, I was haunted by the feeling that I squandered my teenage years. Most people have standard regrets, like "I should have bought Bitcoin" or "I wish I hadn't been in such a rush to grow up."

My struggle was different: a cringing realization of how narrow my world was.

Coding is actually more fun than video games, and unlike gaming, it's a skill I can use to make the world a better place. It's hard not to feel a level of guilt about not using that time wisely.

I sacrificed sleep to beat levels; I chased high scores; I even move out of my parents' at 16, just in hopes of having the uninterrupted right to stare at a screen.

If you know anything about me, I am infamously bad at making lists, yet I seem to have no trouble cataloging my regrets. It is a regrettab—oh for fuck's sake, not again.

While writing this article, I realised that me being regretful about how I can listing out regrets, is actually recursive itself... neat.

Punished curiosity

This has led me to develop a negative association with focus, whenever I tunnel vision on something, my gut feeling tells me that I am doing something wrong.

This was due to all the all-nighters that I pulled trying to achieve a new record or high score in whatever video game I was obsessed with at that time as a child, or teen.

This caused me to only get surface level knowledge of things instead of understanding them deeply.

Might come in handy

You've probably heard that "anything you learn will come in handy one day," maybe even with the Steve Jobs example - how a random typography course became Apple's iconic fonts.

Steve Jobs and typography
Steve Jobs discusses dropping in on a calligraphy course at Reed College

"I had no idea what I wanted to do with my life and no idea...

...looking back it was one of the best decisions I ever made. "

Given my dilettantish nature and fair share of randomly acquired skills, I've had many experiences that validate this. I now find it much easier to let myself dive into random rabbit holes, hoping to learn something new.

Don't dismiss all of it

There's one story I always remember when I start regretting time spent learning something that might never provide value, and it was all by accident, and I only reaped the benefits almost a decade after I had learned it... starring: recursion.

This mathematical concept describes a process defined or constructed in terms of itself.

If you made it through that sentence on the first try, you're either a programmer, mathematician, or someone who interacts with this stuff or you simply didn't bother trying to understand it (or you're lying to yourself). Because, let me tell you, people. hate. recursion.

so here is an example in simple terms:

a recursive function can be compared to climbing a ladder, you check for a rung, if you find one, take a step, and check again, and so on...

I thought I had hated it too, but I was wrong. When I started taking software development seriously about three years ago (of the time of writing this article), I thought I knew nothing, treating everything as completely new. After all, I'd spent my childhood playing video games and cheating (boy was I good at that) in school - what good could have come from that?

Recently, I was browsing LeetCode (not solving problems, just inducing imposter syndrome, like a real dev) when I stumbled across the "Number of Islands" problem.

Number of Islands

// An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically.
You may assume all four edges of the grid are all surrounded by water.

3islands found
The grid is interactive :D
Click on a cell to toggle it between 0 and 1.
input: grid = [
[
"",
"",
"",
"",
""
],
[
"",
"",
"",
"",
""
],
[
"",
"",
"",
"",
""
],
[
"",
"",
"",
"",
""
]
]

I whipped up my note pad and started doodling a solution, completely lost despite sensing it had something to do with recursion.

Then it clicked.

My swiss-cheese childhood memory somehow filled in some holes: I'd done this before. An even more complicated, 3D version... in Minecraft.

Turtles

These days, "turtles" in Minecraft means the actual animal - they have real turtles now. But back in my day... I somehow get to say this now. You're more likely to think of the computer turtle from ComputerCraft.

You can instruct them to do basic things: move forward with turtle.forward(), mine a block with turtle.dig(), and you can program them, with Lua That was my first introduction to programming.

Just like the real thing

It wasn't as easy as I thought; giving clear, concise instructions is hard. It was my first experience with something listening exactl- wait.. EXACTLY to what I told it, and it was immensely frustrating.

If you ever programmed anything, you probably wrote something, thought it looked fine, ran it, and it does something utterly unlike what you had thought would happen, then after a couple of seconds thought "oh, that makes a lot of sense".... Well that was me, for hours, days and probably weeks after I had found of about all that mod in Minecraft.

Where it circles back

I won't go too much in the detail of how I tried automating everything one could do in minecraft using those turtles or consoles that had.

But there is something that stands out to me, to this day.

Mining is a big part of Minecraft.. duh.. and turtles can do that for you, but making them mine 1 block, or 100 blocks in a straight line, is not so useful, you want it to look for ores (the shiny stuff) and dig up the entire node (multiple blocks that are connected) together.

Where the turtle would check around itself for ores, if it finds one, it would dig it, move to it, then check again for ores around it, and so on... sounds familiar?

This is exactly what the "Numbers of Islands" problem is on leetcode, I had solved it already.. in fucking Minecraft.

Was never late

Now I know, it can be too much sometimes, diving deep into youtube rabbit holes about some random fact might not come in handy, but do not dismiss all of it.

I thought I had wasted my entire childhood on meaningless pursuits.. but actually, I was a 12 year old who solved a leetcode medium... I didn't stay up late playing minecraft, I was studying software engineering, a decade too early.