Day 1 Quest

Crafting Bolt's First Brain Block

Quest: How does a machine learn something?

Today Dad and Franklin opened the Craft Lab.

We are building an Iron Golem named Bolt. Right now his head is empty iron. Today we craft his very first brain block: a tiny artificial neuron.

Its job is to answer one question:

Should we play outside?

<Franklin>

If we put the right blocks in the crafting table, can Bolt learn by himself?

Crafting table + furnace

World

What is the weather and homework like?

Crafting Table

Crafting Table

Use + / to stack blocks (that is the weight). Torch flips the weight negative.

Sunny

Homework

Rain

Bias

Redstone Dust

Redstone dust

Output
Emerald

YES — play!

50% sure

Furnace

Furnace

Hearts (less loss = more hearts)

HeartHeartHeartHeartHeartHeartHeartHeartHeartHeart
Day/Night 00%

Loss: 0.7110

The chest of examples

Instead of writing rules like IF raining THEN stay inside, we filled a chest with examples and let the furnace discover the pattern.

SunnyHomework doneRainingPlay outside?
1101
1000
0110
1110
0101
0000

1 means yes. 0 means no. Each row is one item in the training chest.

The recipe

Our whole AI model is only three weights and one bias.

In Minecraft words:

  • Sunny block, Homework book, Rain cloud = inputs
  • Stack count = how important that block is (weight)
  • Redstone torch on a slot = that weight is negative
  • Redstone dust = bias
  • Crafting table = the neuron
  • Furnace = training

Crafting recipe

3 input blocks+3 weights+1 bias dust+sigmoid+furnace smelt=Neuron

Smelting (training)

At the start the stacks are almost random. Bolt guesses badly. We measure how wrong he is (that number is called loss, shown as empty hearts). Then the furnace nudges the stacks a tiny bit and tries again. Thousands of day/night cycles.

That redstone loop looks like this:

  1. DataRedstone Dust
  2. ModelRedstone Dust
  3. PredictionRedstone Dust
  4. LossRedstone Dust
  5. GradientsRedstone Dust
  6. UpdateRedstone Dust
  7. Repeat

Item crafted

When smelting finished, we put a new item in the Chest: the Play-Outside Compass.

Item crafted!

Play-Outside Compass

Compass

Points toward playing outside. Hates rain. Loves finished homework.

  • Homework Boost I
  • Rain Aversion II
Sunny Block
Homework Book
Redstone Dust
Rain Cloud
Compass
Crafting Table

Achievement Get!

First Craft

The first big lesson

A model's "knowledge" is just numbers (stack counts and torches).

The compass learned four numbers. Giant language models learn billions. The stacks get bigger and wilder, but this furnace loop stays underneath everything.

Teaching Franklin

We explained the neuron as a crafting recipe with three ingredients. Some stacks matter more. A redstone torch means "this block pushes the answer the other way."

After smelting, look at the rain slot. It should have a redstone torch (negative). Bolt was never told "rain is bad for playing outside." He inferred it from the chest of examples.

The command block

This is the exact program we ran on the computer (not just the browser craft bench):

Command Blockday01_neuron.py
import numpy as np

# -------------------------------------------------
# 1. OUR DATASET
# -------------------------------------------------

# Each row is:
# [sunny, homework_finished, raining]

X = np.array(
    [
        [1, 1, 0],
        [1, 0, 0],
        [0, 1, 1],
        [1, 1, 1],
        [0, 1, 0],
        [0, 0, 0],
    ],
    dtype=float,
)

# Correct answers:
# 1 = play outside
# 0 = don't play outside

y = np.array(
    [
        [1],
        [0],
        [0],
        [0],
        [1],
        [0],
    ],
    dtype=float,
)


# -------------------------------------------------
# 2. CREATE OUR MODEL
# -------------------------------------------------

np.random.seed(42)

# The neuron has three weights because we have
# three input features.

weights = np.random.randn(3, 1) * 0.1

# And one bias.

bias = np.zeros((1,))


# -------------------------------------------------
# 3. SIGMOID
# -------------------------------------------------

def sigmoid(x):
    return 1 / (1 + np.exp(-x))


# -------------------------------------------------
# 4. TRAIN THE MODEL
# -------------------------------------------------

learning_rate = 0.5
epochs = 5000

for epoch in range(epochs):

    # Make predictions
    z = X @ weights + bias
    predictions = sigmoid(z)

    # Calculate the error
    error = predictions - y

    # Calculate gradients
    weight_gradient = X.T @ error / len(X)
    bias_gradient = np.mean(error)

    # Update the model
    weights -= learning_rate * weight_gradient
    bias -= learning_rate * bias_gradient

    if epoch % 500 == 0:
        loss = -np.mean(
            y * np.log(predictions + 1e-8)
            + (1 - y) * np.log(1 - predictions + 1e-8)
        )

        print(f"Epoch {epoch}: loss = {loss:.4f}")


# -------------------------------------------------
# 5. LOOK AT WHAT THE MODEL LEARNED
# -------------------------------------------------

print("\nLearned weights:")

print("Sunny:", weights[0][0])
print("Homework finished:", weights[1][0])
print("Raining:", weights[2][0])
print("Bias:", bias[0])


# -------------------------------------------------
# 6. TEST OUR MODEL
# -------------------------------------------------

def should_we_play(sunny, homework_finished, raining):

    inputs = np.array([[sunny, homework_finished, raining]])

    probability = sigmoid(inputs @ weights + bias)[0][0]

    print(f"\nProbability of playing outside: {probability:.1%}")

    if probability >= 0.5:
        print("YES - Let's play outside!")
    else:
        print("NO - Stay inside!")


# Sunny + homework done + not raining

should_we_play(sunny=1, homework_finished=1, raining=0)

Run it yourself:

python3 -m venv .venv
source .venv/bin/activate
pip install numpy
python content/lab/days/day-001/day01_neuron.py

Watch the loss go down. That decreasing number is Bolt learning. Rain gets a torch.

Oak SignDad's Lab Notes (tap to open)
Wanted to learn
Understand what 'training a model' really means at the smallest possible scale.
Learned
A neuron is weighted inputs plus bias, squeezed through sigmoid into a probability. Knowledge lives in the parameters. Loss falling means learning. Rain learns a negative weight.
Built
A single artificial neuron trained on a 6-row play-outside dataset, plus a crafting-table and furnace playground Franklin can twist.
Confused me
How the furnace knows the direction to nudge each stack (gradients). That is tomorrow.
Failed
Nothing catastrophic. Early random stacks made silly predictions, which is exactly what we wanted to see before smelting.
Taught Franklin
Franklin: a neuron is a tiny crafting recipe. Change the stacks and the YES/NO emerald flips. After training, rain gets a redstone torch by itself.
Tomorrow
Take one furnace tick apart by hand: loss, gradient, learning rate, stack update.

Tomorrow

How does the furnace know which block to add or remove? Tomorrow we learn about loss, gradients, and gradient descent.