# Baker Family Example A comprehensive example demonstrating Storybook v0.2.0 features through a realistic multi-character scenario. ## Features Demonstrated ### Resource Linking - **Templates with behaviors**: `Baker` template specifies `BakingSkills` and `CustomerService` - **Templates with schedules**: `Baker` template uses `BakerSchedule` - **Multi-level inheritance**: `Baker` → `Worker` → `Person` template chain - **Character inheritance**: Characters automatically inherit behaviors and schedules from templates ### Schedule Composition - **Schedule inheritance**: `BakerSchedule extends WorkWeek` - **Override blocks**: Modify inherited time blocks with `override work { ... }` - **Named blocks**: All blocks have names for the override system - **Action references**: Schedule blocks reference behavior trees via `action: BehaviorName` - **Recurrence patterns**: Market day repeats `on Saturday` ### Behavior Trees - Comprehensive behavior definitions for all activities - Referenced from schedule blocks showing integration - Hierarchical behaviors (sequences, selectors, repeaters) ## File Structure ``` baker-family/ ├── README.md # This file ├── schema/ │ └── templates.sb # Template definitions with resource linking ├── schedules/ │ └── work_schedules.sb # Composable schedules ├── behaviors/ │ └── baker_behaviors.sb # Behavior tree definitions └── characters/ ├── martha.sb # Master baker (uses Baker template) ├── john.sb # Pastry chef (uses Baker template) └── emma.sb # Daughter (uses Child template) ``` ## Template Hierarchy ``` Person (behaviors: BasicNeeds, SocialInteraction) └─> Worker (schedule: WorkWeek) └─> Baker (behaviors: +BakingSkills, +CustomerService, schedule: BakerSchedule) └─> Child (behaviors: PlayBehavior, LearnBehavior, no schedule) ``` ## Schedule Inheritance ``` WorkWeek ├─ morning_prep (08:00-09:00) ├─ work (09:00-17:00) └─ evening_rest (18:00-22:00) BakerSchedule extends WorkWeek ├─ pre_dawn_prep (04:00-05:00) [NEW] ├─ work (05:00-13:00) [OVERRIDE] → action: BakingWork ├─ evening_rest (18:00-22:00) [INHERITED] └─ recurrence MarketDay on Saturday └─ market (06:00-14:00) → action: SellAtMarket ``` ## Key Integration Points 1. **Martha (character)** → inherits from **Baker (template)** - Gets behaviors: `BakingSkills`, `CustomerService`, `BasicNeeds`, `SocialInteraction` - Gets schedule: `BakerSchedule` (which extends `WorkWeek`) 2. **BakerSchedule (schedule)** → references **BakingWork (behavior)** - `action: BakingWork` in the work block - Creates link between scheduling and behavior systems 3. **Template chain** → cascading resource inheritance - `Baker` includes `Worker` includes `Person` - All behaviors and schedules flow down the hierarchy ## Usage This example shows how to: - Build reusable templates with attached behaviors and schedules - Create character hierarchies representing different roles - Compose schedules through inheritance and overrides - Link schedules to behaviors through action references - Model realistic daily routines with time-of-day variations - Handle special events (market days) with recurrence patterns ## Narrative Implications The Baker family example demonstrates: - **Daily rhythms**: Early morning routine for bakers vs. normal schedule for child - **Weekly patterns**: Special market day on Saturdays - **Role-based behaviors**: Bakers have different skill sets than children - **Family dynamics**: Multiple characters with interrelated but distinct routines - **Business operations**: Work schedule tied to specific behaviors (baking, selling) This is the kind of rich, time-based character modeling that makes Storybook ideal for narrative simulations and game design.