lantern

sprout-garden-phase-7

Sprout Garden Phase 7: Harvests & Recipes

Accumulation and Synthesis - Collecting, filtering, and combining

Overview

Phase 7 introduces advanced harvests - plots that collect, filter, count, and combine sprouts. This teaches data aggregation, pipelines, and synthesis - turning raw ingredients into finished products.

This phase teaches: Collect many things. Combine them into new things. Build something greater than the parts.

Plot Types Introduced

Plot Symbol Category Behavior
Filter 🧹 selection Only passes matching sprouts
Counter πŸ”’ aggregation Counts sprouts, outputs count
Basket 🧺 collection Holds until N sprouts arrive
Recipe Pot 🍲 synthesis Combines sprouts into new form
Splitter Emitter 🌱ⁿ source Emits N sprouts
Timed Emitter 🌱⏱️ source Emits one sprout every X ticks

Filter Mechanics

Only passes sprouts matching criteria:

// "Only red sprouts pass"
redFilter = createFilter({ color: 'red' });

// "Only stars pass"  
starFilter = createFilter({ shape: 'star' });

// "Only red stars pass"
redStarFilter = createFilter({ shape: 'star', color: 'red' });
    πŸ”΄ ───┐
    🟒 ───┼───▢ [🧹 red only] ───▢ πŸ”΄
    πŸ”΅ β”€β”€β”€β”˜
    
    (green and blue are blocked/discarded)

Basket Mechanics

Holds sprouts until threshold reached:

basket = createBasket({ 
  capacity: 5,
  releaseMode: 'all'  // or 'first', 'random'
});
    🌱 ───▢ [🧺 need 5] ───▢ (nothing yet)
    🌱 ───▢ [🧺 need 4] ───▢ (nothing yet)
    🌱 ───▢ [🧺 need 3] ───▢ (nothing yet)
    🌱 ───▢ [🧺 need 2] ───▢ (nothing yet)
    🌱 ───▢ [🧺 need 1] ───▢ 🌱🌱🌱🌱🌱 (all release!)

Use case: Synchronize multiple streams before continuing.

Recipe Pot Mechanics

Combines specific sprouts into new form:

recipe:
  name: "Build a Car"
  requires:
    - { shape: 'star', color: 'red', count: 4 }    # 4 red stars (wheels)
    - { shape: 'square', color: 'blue', count: 1 } # 1 blue square (body)
  produces:
    shape: 'car'
    color: 'red'
    β˜…πŸ”΄ ───┐
    β˜…πŸ”΄ ────
    β˜…πŸ”΄ ───┼───▢ [🍲 car recipe] ───▢ πŸš—πŸ”΄
    β˜…πŸ”΄ ────
    β– πŸ”΅ β”€β”€β”€β”˜

The magic moment: Five simple shapes become a car!

Counter Mechanics

Counts sprouts and outputs the count:

counter = createCounter({
  outputMode: 'continuous',  // Output count after each sprout
  // or 'final'             // Output count at end
});
    🌱 ───▢ [πŸ”’] ───▢ "1"
    🌱 ───▢ [πŸ”’] ───▢ "2"
    🌱 ───▢ [πŸ”’] ───▢ "3"

Use case: "How many red sprouts came through?"

Emitter Modes

Burst Emitter (🌱ⁿ)

burstEmitter = createSpring({
  mode: 'burst',
  count: 5,
  emits: { shape: 'circle', color: 'red' }
});
// Emits 5 sprouts at once on tick 0

Timed Emitter (🌱⏱️)

timedEmitter = createSpring({
  mode: 'timed',
  interval: 3,  // Every 3 ticks
  emits: { shape: 'circle', color: 'red' }
});
// Emits 1 sprout every 3 ticks

Continuous Emitter (🌱∞)

continuousEmitter = createSpring({
  mode: 'continuous',
  emits: { shape: 'circle', color: 'red' }
});
// Emits 1 sprout every tick until stopped

Source Files (To Be Created)

File Purpose
src/plots/types/filter.js Property-based filtering
src/plots/types/counter.js Sprout counting
src/plots/types/basket.js Collect N before release
src/plots/types/recipe-pot.js Combine into new forms
src/core/recipes.js Recipe definitions

API Documentation

files:
  - /Users/graemefawcett/working/ben.fawcett.family/activities/sprout-garden/src/plots/types/filter.js
  - /Users/graemefawcett/working/ben.fawcett.family/activities/sprout-garden/src/plots/types/counter.js
  - /Users/graemefawcett/working/ben.fawcett.family/activities/sprout-garden/src/plots/types/basket.js
  - /Users/graemefawcett/working/ben.fawcett.family/activities/sprout-garden/src/plots/types/recipe-pot.js

❌ Fence Execution Error: "'code-api-docs' - Down the rabbit hole we went, but that node doesn't exist! Try 'oculus list' to see what's available."

Implementation Notes

Recipe System

// recipes.js
export const RECIPES = {
  'car': {
    requires: [
      { shape: 'star', color: 'red', count: 4 },
      { shape: 'square', color: 'blue', count: 1 }
    ],
    produces: { shape: 'car', color: 'red' }
  },
  'house': {
    requires: [
      { shape: 'square', color: 'red', count: 4 },
      { shape: 'triangle', color: 'blue', count: 1 }
    ],
    produces: { shape: 'house', color: 'red' }
  },
  'rainbow': {
    requires: [
      { color: 'red', count: 1 },
      { color: 'green', count: 1 },
      { color: 'blue', count: 1 },
      { color: 'yellow', count: 1 }
    ],
    produces: { shape: 'rainbow', color: 'multi' }
  }
};

Recipe Pot State

recipePot.state = {
  collected: [],
  recipe: RECIPES['car']
};

recipePot.receive(sprout) {
  this.state.collected.push(sprout);
  
  if (this.checkRecipeComplete()) {
    const product = this.synthesize();
    this.state.collected = [];
    this.emit(product);
  }
}

recipePot.checkRecipeComplete() {
  for (const requirement of this.state.recipe.requires) {
    const matches = this.state.collected.filter(s => 
      (!requirement.shape || s.shape === requirement.shape) &&
      (!requirement.color || s.color === requirement.color)
    );
    if (matches.length < requirement.count) {
      return false;
    }
  }
  return true;
}

Level Ideas

Level Challenge Teaches
46 Filter red from mixed Selection
47 Count how many stars Aggregation
48 Collect 5 in basket Synchronization
49 Build your first car Synthesis!
50 Build a house Recipe variation
51 Sort then count each color Pipeline
52 Build rainbow from all colors Complex recipe
53 Factory: continuous car production Automation
54 Optimize throughput Efficiency
55 FINAL: Build the ultimate machine Everything combined

Pedagogy

What Kids Learn (Without Knowing It)

  • Data pipelines: Filter β†’ Transform β†’ Aggregate
  • Map/Filter/Reduce: The fundamental operations
  • Synthesis: Combining ingredients
  • Manufacturing: Continuous production
  • Optimization: Throughput and efficiency
  • Systems thinking: Everything connects

The Factory Floor

By Phase 7, kids have built a visual factory:

Raw materials (springs)
    ↓
Transformation (growers)
    ↓
Quality control (filters)  
    ↓
Assembly (recipe pots)
    ↓
Output (harvest)

They've built a data pipeline without knowing it.

The Grand Finale

Level 55: Build a machine that:

  • Takes continuous input from multiple springs
  • Filters by property
  • Routes through forks
  • Transforms through growers
  • Synchronizes with logic gates
  • Assembles with recipes
  • Outputs finished products

They've built Factorio. They've built ETL. They've built Wanderland.

Verification

Live test results from [[sprout-garden-phase-7-test]]:

Test Status Details
filter.js exists fail not yet implemented
counter.js exists fail not yet implemented
basket.js exists fail not yet implemented
recipe-pot.js exists fail not yet implemented
recipes.js exists fail not yet implemented

Slots

North

slots:
- sprout-garden
- sprout-garden

South

slots:
- sprout-garden-phase-7-test

East

slots: []

West

slots:
- sprout-garden-phase-6
↑ northsprout-garden
↓ southsprout-garden-phase-7-test
← westsprout-garden-phase-6