sprout-garden-phase-5
Sprout Garden Phase 5: Logic Trellises
Boolean Algebra - AND, OR, NOT, XOR
Overview
Phase 5 introduces logic trellises - plots that implement boolean operations. Sprouts become signals, and the garden becomes a logic circuit.
This phase teaches: Combine conditions. Invert things. Build complex logic from simple parts.
Plot Types Introduced
| Plot | Symbol | Category | Inputs | Output |
|---|---|---|---|---|
| AND Trellis | ∧ | logic | 2 | 1 (both must arrive) |
| OR Trellis | ∨ | logic | 2 | 1 (either works) |
| NOT Trellis | ¬ | logic | 1 | 1 (inverts property) |
| XOR Trellis | ⊕ | logic | 2 | 1 (one or other, not both) |
| NAND Trellis | ⊼ | logic | 2 | 1 (not both) |
Logic Trellis Mechanics
AND Trellis (∧)
Both inputs must have sprouts before output fires:
sprout A ───┐
├───▶ [∧] ───▶ outputs when BOTH arrive
sprout B ───┘Blocking behavior: First sprout waits until second arrives.
OR Trellis (∨)
Either input triggers output:
sprout A ───┐
├───▶ [∨] ───▶ outputs when EITHER arrives
sprout B ───┘Pass-through behavior: First sprout to arrive goes through immediately.
NOT Trellis (¬)
Inverts a sprout property:
// Shape inversion
circle ↔ star
square ↔ triangle
// Color inversion
red ↔ blue
green ↔ yellow sprout ───▶ [¬] ───▶ inverted sproutXOR Trellis (⊕)
One or the other, but not both:
sprout A ───┐
├───▶ [⊕] ───▶ outputs if EXACTLY ONE arrives
sprout B ───┘Cancellation: If both arrive same tick, neither passes.
Timing and Synchronization
Logic trellises introduce temporal coordination:
// AND waits for both inputs
andTrellis.state = {
inputA: null, // Waiting
inputB: null, // Waiting
};
// When sprout arrives at input A
andTrellis.receiveA(sprout) {
this.state.inputA = sprout;
this.checkFire();
}
// Fire when both present
andTrellis.checkFire() {
if (this.state.inputA && this.state.inputB) {
// Combine or pass first sprout
this.emit(this.state.inputA);
this.state = { inputA: null, inputB: null };
}
}Source Files (To Be Created)
| File | Purpose |
|---|---|
src/plots/types/and-trellis.js |
Both inputs required |
src/plots/types/or-trellis.js |
Either input works |
src/plots/types/not-trellis.js |
Property inversion |
src/plots/types/xor-trellis.js |
Exclusive or |
src/plots/types/nand-trellis.js |
Not both |
API Documentation
files:
- /Users/graemefawcett/working/ben.fawcett.family/activities/sprout-garden/src/plots/types/and-trellis.js
- /Users/graemefawcett/working/ben.fawcett.family/activities/sprout-garden/src/plots/types/or-trellis.js
- /Users/graemefawcett/working/ben.fawcett.family/activities/sprout-garden/src/plots/types/not-trellis.js
- /Users/graemefawcett/working/ben.fawcett.family/activities/sprout-garden/src/plots/types/xor-trellis.js
- /Users/graemefawcett/working/ben.fawcett.family/activities/sprout-garden/src/plots/types/nand-trellis.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
Multi-Input Seeds
Logic trellises need labeled inputs:
// and-trellis.js
export default {
id: 'and-trellis',
name: 'AND Trellis',
symbol: '∧',
category: 'logic',
phase: 5,
seeds: {
A: ['left'], // Input A from left
B: ['up'] // Input B from up
},
fruits: ['right'], // Output right
state: { A: null, B: null },
receive(sprout, inputLabel) {
this.state[inputLabel] = sprout;
},
shouldFire() {
return this.state.A !== null && this.state.B !== null;
},
fire() {
const output = this.state.A; // Or combine them
this.state = { A: null, B: null };
return output;
}
};NOT Inversion Tables
const SHAPE_INVERSE = {
'circle': 'star',
'star': 'circle',
'square': 'triangle',
'triangle': 'square'
};
const COLOR_INVERSE = {
'red': 'blue',
'blue': 'red',
'green': 'yellow',
'yellow': 'green'
};
// NOT can be configured for shape or color
notTrellis.grow(sprout) {
if (this.config.invert === 'shape') {
return { ...sprout, shape: SHAPE_INVERSE[sprout.shape] };
}
if (this.config.invert === 'color') {
return { ...sprout, color: COLOR_INVERSE[sprout.color] };
}
// Default: invert both
return {
...sprout,
shape: SHAPE_INVERSE[sprout.shape],
color: COLOR_INVERSE[sprout.color]
};
}Level Ideas
| Level | Challenge | Teaches |
|---|---|---|
| 31 | Simple AND gate | Synchronization |
| 32 | Simple OR gate | Alternatives |
| 33 | NOT to invert shape | Negation |
| 34 | AND + transforms | Logic with processing |
| 35 | XOR puzzle | Exclusive logic |
| 36 | Build half-adder | Digital circuits |
| 37 | Multiple ANDs | Complex synchronization |
| 38 | De Morgan's Law | Logic equivalence |
Pedagogy
What Kids Learn (Without Knowing It)
- Boolean algebra: AND, OR, NOT fundamentals
- Digital logic: How computers compute
- Synchronization: Waiting for multiple events
- Inversion: Opposites and negation
- Logic equivalence: Different ways to express same thing
Building Blocks
With AND, OR, NOT you can build ANY boolean function:
NAND = NOT(AND)
NOR = NOT(OR)
XOR = OR(AND(A, NOT(B)), AND(NOT(A), B))The garden becomes a logic circuit simulator.
Verification
Live test results from [[sprout-garden-phase-5-test]]:
| Test | Status | Details |
|---|---|---|
| and-trellis.js exists | fail | not yet implemented |
| or-trellis.js exists | fail | not yet implemented |
| not-trellis.js exists | fail | not yet implemented |
| xor-trellis.js exists | fail | not yet implemented |
| nand-trellis.js exists | fail | not yet implemented |
Slots
North
slots:
- sprout-garden
- sprout-gardenSouth
slots:
- sprout-garden-phase-5-testEast
slots:
- sprout-garden-phase-6West
slots:
- sprout-garden-phase-4