feat(examples): rewrite baker-family as coherent Competition Week narrative

Rewrote the baker-family example around a unified story: the annual Harvest
Baking Competition is Saturday. Martha's sourdough starter Old Maggie is
sluggish from a cold snap, Jane is secretly entering the FreeStyle category,
Emma's science fair project is "The Chemistry of Fermentation", Henry is
judging for the first time and worried about impartiality, and Roland is
defending last year's title.

The week's schedules (Mon guild meeting → Tue test bakes → Wed sourcing →
Thu dough prep → Fri science fair → Sat competition → Sun recovery) are
now fully populated with narrative-specific actions.

Files split for composability:
- behaviors/baker_behaviors.sb → 5 focused files by character/domain
- schema/types.sb → 4 files (core, baking, world, social)
- schedules/work_schedules.sb → 4 files (one per schedule)
- relationships/baker_family_relationships.sb → family + bakery

Strong typing: replaced all enumerable string fields with concepts
(BakerSpecialty, Occupation, LocationType, InstitutionType, ParentingStyle,
Intensity, BakeryDomain, BakingDiscipline, ManagementDomain,
CompetitiveAdvantage).

Remove new-syntax-demo.sb (superseded by baker-family example).
This commit is contained in:
2026-02-23 21:51:01 +00:00
parent 1fa90aff0e
commit abd54e4c33
29 changed files with 820 additions and 587 deletions

View File

@@ -1,6 +1,7 @@
//! Behavior trees for the Baker family
//! Core baking behaviors — Martha and Jane's craft
//!
//! These are referenced by schedule blocks via the action: field
//! These behaviors are referenced by the Baker template and BakerSchedule.
//! See also: competition_behaviors.sb for competition-week-specific actions.
// Main baking work routine
behavior BakingWork {
@@ -42,48 +43,7 @@ behavior SellAtMarket {
}
}
// Assistant work (subset of main baking)
behavior AssistWithBaking {
then {
check_orders
prepare_ingredients
choose {
assist_with_bread
assist_with_pastries
}
clean_workspace
}
}
// Quick morning prep
behavior QuickPrep {
then {
check_supplies
organize_workspace
}
}
// Basic needs (from Person template)
behavior BasicNeeds {
repeat {
choose {
if(self.hunger is hungry) { eat }
if(self.hunger is satisfied) { rest }
if(self.thirst is thirsty) { drink }
}
}
}
// Social interaction
behavior SocialInteraction {
choose {
greet_neighbors
chat_with_customers
family_time
}
}
// Baking skills
// Baker skill behaviors (from Baker template)
behavior BakingSkills {
then {
assess_dough
@@ -92,7 +52,6 @@ behavior BakingSkills {
}
}
// Customer service
behavior CustomerService {
then {
greet_warmly
@@ -101,20 +60,3 @@ behavior CustomerService {
handle_payment
}
}
// Child behaviors
behavior PlayBehavior {
choose {
play_outside
play_with_toys
draw_pictures
}
}
behavior LearnBehavior {
then {
attend_school
do_homework
read_books
}
}

View File

@@ -0,0 +1,78 @@
//! Child behaviors — Emma's school week, science fair, and bakery life
// Child template behaviors
behavior PlayBehavior {
choose {
play_outside
play_with_toys
draw_pictures
}
}
behavior LearnBehavior {
then {
attend_school
do_homework
read_books
}
}
// School schedule behaviors
behavior SchoolDay {
then {
travel_to_school
attend_classes
eat_lunch
attend_afternoon_classes
travel_home
}
}
behavior DoHomework {
then {
organize_assignments
study
complete_homework
}
}
// After-school help at the bakery
behavior HelpInBakery {
then {
package_goods
wipe_counters
chat_with_customers
}
}
// Thursday: Emma prepares her science fair project on fermentation
behavior PrepareScienceFair {
then {
collect_fermentation_samples
examine_under_microscope
update_data_charts
rehearse_presentation
arrange_poster_board
}
}
// Friday: Emma presents at the science fair
behavior ScienceFairPresentation {
then {
setup_display
present_findings
answer_questions
receive_feedback
}
}
// Saturday: Emma helps her parents at the competition venue
behavior HelpAtCompetition {
then {
carry_supplies
setup_station
fetch_water
watch_competition
cheer_for_parents
}
}

View File

@@ -0,0 +1,98 @@
//! Competition week behaviors — the Harvest Baking Competition
//!
//! These behaviors drive the narrative arc from Monday's guild meeting
//! through Saturday's competition and Sunday's recovery.
// Tuesday: Martha tests her competition sourdough, adjusting for Old Maggie's sluggishness
behavior TestCompetitionRecipe {
then {
check_starter_health
choose {
adjust_hydration
adjust_temperature
extend_fermentation
}
mix_test_batch
monitor_rise
assess_result
}
}
// Thursday: 24-hour competition dough prep — rise begins before Saturday
behavior PrepCompetitionDough {
then {
feed_starter_extra
wait_for_activity
mix_competition_dough
initial_fold
bulk_fermentation
shape_loaves
begin_cold_retard
}
}
// Saturday: full competition routine for the baker
behavior CompetitionRoutine {
then {
load_supplies
transport_to_venue
setup_competition_station
final_proof_check
bake_under_pressure
present_to_judges
wait_for_results
}
}
// Monday evening: guild meeting — competition rules announced, tension with Roland
behavior AttendGuildMeeting {
then {
travel_to_town_hall
review_competition_rules
choose {
discuss_with_peers
argue_with_rival
}
vote_on_motions
travel_home
}
}
// Wednesday: source premium flour and imported butter for the competition
behavior SourceIngredients {
then {
visit_flour_mill
select_premium_flour
choose {
source_imported_butter
source_local_butter
}
check_specialty_items
transport_ingredients
}
}
// Friday evening: parents and Henry attend Emma's science fair
behavior AttendScienceFair {
then {
travel_to_school
find_emma_display
listen_to_presentation
congratulate_emma
talk_with_teachers
}
}
// Saturday evening: post-competition gathering at the bakery
behavior Celebration {
then {
gather_at_bakery
share_stories
choose {
toast_the_winner
console_the_losers
}
eat_leftover_competition_bread
family_time
}
}

View File

@@ -0,0 +1,48 @@
//! Henry's behaviors — retired teacher, loyal customer, first-time judge
// Henry's morning routine: daily visit to the bakery
behavior BakeryVisit {
then {
walk_to_bakery
buy_sourdough_loaf
chat_with_martha
}
}
behavior MorningWalk {
then {
walk_through_town
greet_neighbors
enjoy_morning_air
}
}
behavior ReadingTime {
choose {
read_history_book
read_newspaper
write_in_journal
}
}
// Friday: Henry reviews the judging criteria before Saturday's competition
behavior ReviewJudgingCriteria {
then {
read_scoring_rubric
practice_palate
review_past_winners
prepare_notes
}
}
// Saturday: Henry judges the Harvest Baking Competition
behavior JudgeCompetition {
then {
arrive_at_venue
review_entries
taste_each_entry
score_on_criteria
deliberate_with_panel
announce_results
}
}

View File

@@ -0,0 +1,54 @@
//! Shared person behaviors — used by all characters via the Person template
behavior BasicNeeds {
repeat {
choose {
if(self.hunger is hungry) { eat }
if(self.hunger is satisfied) { rest }
if(self.thirst is thirsty) { drink }
}
}
}
behavior SocialInteraction {
choose {
greet_neighbors
chat_with_customers
family_time
}
}
// Generic schedule utility behaviors used across WorkWeek-derived schedules
behavior MorningRoutine {
then {
wake_up
eat_breakfast
prepare_for_day
}
}
behavior DailyWork {
then {
travel_to_work
perform_duties
travel_home
}
}
behavior Resting {
choose {
read_book
take_nap
sit_in_garden
}
}
// Sunday recovery — the whole family
behavior FamilyBreakfast {
then {
sleep_in
make_breakfast_together
eat_together
discuss_the_week
}
}

View File

@@ -20,17 +20,24 @@ character Emma from Child {
mood: 0.85
---backstory
Emma is the bright, energetic daughter of Martha and Jane. She loves
helping in the bakery on weekends, though she's not allowed to work
the ovens yet. She's fascinated by the chemistry of baking and often
asks her mothers endless questions about why dough rises, how yeast
works, and what makes bread crusty.
Emma is the bright, energetic daughter of Martha and Jane. She is
fascinated by the chemistry of baking — why dough rises, how yeast
works, what makes bread crusty — and has turned that curiosity into
her school science fair project: "The Chemistry of Fermentation."
At school, she excels in science and math, and dreams of one day
creating her own innovative recipes. She learns the science of bread
from Martha and the art of decoration from Jane. For now, she's
content to help package goods and chat with the regular customers
who've watched her grow up.
She borrowed a microscope from the school lab and has been studying
Old Maggie under magnification, sketching the yeast colonies and
tracking how temperature affects their activity. Her poster board
is covered in hand-drawn diagrams of lactobacillus and graphs of
rise times at different temperatures. The science fair is Friday
evening, and she has been rehearsing her presentation to anyone
who will listen — Henry, the regular customers, even Roland once
when he stopped by to buy flour.
On weekends she helps in the bakery, packaging goods and chatting
with customers. She is not allowed to work the ovens yet, but she
knows the recipes by heart. She is quietly proud that her science
project connects her two worlds: school and the bakery.
---
}

View File

@@ -18,12 +18,21 @@ character Henry from Person {
---backstory
Henry taught history at the local school for over forty years before
retiring. He has been a daily customer at the bakery since Martha
first opened its doors. Every morning at precisely seven o'clock,
he arrives for a sourdough loaf and a chat.
first opened its doors — every morning at seven o'clock, a sourdough
loaf and a chat. The bakery is his anchor to the community.
He watched Emma grow up and occasionally helps her with her homework
when he stops by. The bakery is his anchor to the community now that
he no longer teaches. Martha always sets aside his favorite loaf,
and Jane saves him a croissant on Saturdays.
This year, the Bakers Guild invited him to sit on the judging panel
for the Harvest Baking Competition. It is the first time he has been
a judge rather than a spectator, and he is quietly terrified. He
knows the competition's two-hundred-year history better than anyone
— he wrote a monograph on it during his teaching days — but judging
Martha's bread fairly when she saves him his favorite loaf every
morning feels like a conflict of interest.
He has been re-reading the guild's judging criteria and practicing
his palate with different breads from the market. He does not want
to let anyone down — not Martha, not Roland, not the guild. Emma
asked him to come to her science fair on Friday, and he would not
miss it for the world.
---
}

View File

@@ -12,7 +12,7 @@ character Jane from Baker {
age: 36
// Baker-specific traits
specialty: "pastries"
specialty: Pastries
baking_skill: 0.85
customer_relations: 0.80
skill_tier: Journeyman
@@ -23,17 +23,28 @@ character Jane from Baker {
// Work ethic
work_ethic: 0.90
occupation: "pastry chef"
occupation: PastryChef
---backstory
Jane trained at a culinary school in the capital before returning
to her hometown and meeting Martha. Her specialty is delicate
pastries and elaborate wedding cakes. While Martha handles the
bread and business, Jane focuses on the artistic creations that
draw customers from neighboring towns.
to her hometown and meeting Martha. Her croissants are legendary —
people drive from three towns over for the Saturday batch. While
Martha handles bread and business, Jane creates the artistic
pastries that fill the display cases.
She is more of a night owl by nature, but has adapted to the baker's
early schedule over the years. Her croissants are legendary.
This year, for the first time, Jane is entering the Harvest Baking
Competition herself, in the FreeStyle category. She has been
secretly practicing an ambitious croquembouche after Emma's
bedtime: a tower of cream puffs held together with spun caramel,
decorated with candied violets from their garden. Martha does not
know the full scope of what Jane is planning — Jane wants to
surprise her.
She is nervous. She has always been the support crew on competition
day, packing Martha's tools and keeping the workspace organized.
Stepping out from behind the scenes feels like a risk, but Emma
keeps telling her she should, and Martha has been encouraging her
for years.
---
}

View File

@@ -12,7 +12,7 @@ character Martha from Baker {
age: 34
// Baker-specific traits
specialty: "sourdough"
specialty: Sourdough
baking_skill: 0.9
customer_relations: 0.95
skill_tier: Master
@@ -23,17 +23,27 @@ character Martha from Baker {
// Work ethic (from Worker template)
work_ethic: 0.95
occupation: "master baker"
occupation: MasterBaker
---backstory
Martha learned to bake from her grandmother and has perfected
the art of sourdough over fifteen years. She wakes at 4 AM every
day to prepare the morning bread, and her bakery is known throughout
the region for its exceptional quality.
Martha learned to bake from her grandmother, who passed down Old
Maggie — a sourdough starter that has been alive for thirty years.
Old Maggie is the soul of Martha's bread, and Martha tends to her
like a third child: daily feedings, temperature checks, and quiet
conversations when the bakery is empty.
She manages the business side as well, keeping meticulous records
and maintaining warm relationships with all her customers. The bakery
is not just a shop - it's the heart of the community.
She has won the Harvest Baking Competition three out of the last
five years, always in the Signature category with her sourdough.
Last year, Roland took the title with a dark rye that the judges
called "revelatory," and Martha has been determined to reclaim it
ever since. The rivalry deepened when Roland hired away her former
apprentice, Thomas, last spring — a betrayal she has not forgotten.
This week, Old Maggie is sluggish from a cold snap that dropped
the bakery's overnight temperature. Martha has been wrapping the
starter in blankets and moving her near the oven, but the rise is
still not where it needs to be for Saturday's competition. She is
quietly worried but will not show it.
---
}

View File

@@ -12,7 +12,7 @@ character Roland from Baker {
age: 42
// Baker-specific traits
specialty: "rye bread"
specialty: RyeBread
baking_skill: 0.75
customer_relations: 0.60
skill_tier: Journeyman
@@ -23,18 +23,25 @@ character Roland from Baker {
// Work ethic
work_ethic: 0.80
occupation: "baker"
occupation: Baker
---backstory
Roland runs a bakery in the neighboring town. He learned baking from
his father and considers himself the rightful best baker in the region.
His rye bread is excellent, but he lacks Martha's warmth with customers
and Jane's artistic flair.
Last year, he won the Harvest Baking Competition with a dark rye that
the judges called "revelatory" — the first time in three years that
Martha did not take the title. He intends to defend his championship.
He sees Martha's bakery as his chief competition and often tries to
undercut her prices at the market. Despite the rivalry, there is a
grudging respect between them. Roland once admitted, after too much
ale at the harvest festival, that Martha's sourdough was better than
his own.
He has been experimenting with a new fermented rye technique, using a
wild starter he cultivated from grain husks foraged in the hills. The
results are promising but inconsistent, and he has been running test
bakes every other evening. He hired Thomas, Martha's former apprentice,
last spring — a move that was practical (he needed the help) but that
Martha took as a personal betrayal.
Roland respects Martha's skill more than he would ever admit. After
too much ale at last year's harvest festival, he told Henry that
Martha's sourdough was better than his own. He regretted saying it
immediately, and has been trying to prove himself wrong ever since.
---
}

View File

@@ -6,7 +6,7 @@
//! - Connection to characters through membership
institution BakersGuild {
type: "trade guild"
type: TradeGuild
founded: 1823
members: 12
meeting_day: "first Monday"
@@ -18,9 +18,15 @@ institution BakersGuild {
he frequently clashes with Martha over proposed changes to the
guild's standards.
The guild meets monthly at the town hall to discuss flour prices,
apprenticeship standards, and preparations for seasonal festivals.
Henry, as a retired teacher, occasionally gives talks on the history
of baking in the region.
The guild organizes the annual Harvest Baking Competition — this
year marks the forty-seventh. Competitors enter in three categories:
Signature, FreeStyle, and Traditional. The guild meets monthly at
the town hall to discuss flour prices, apprenticeship standards, and
preparations for the competition.
This year, the guild invited Henry to join the judging panel, citing
his deep knowledge of the competition's history. It is the first time
a non-baker has been asked to judge, and it raised a few eyebrows —
Roland's among them.
---
}

View File

@@ -1,4 +1,4 @@
//! Locations for the Baker family
//! Locations for the Baker family — Competition Week
//!
//! Demonstrates:
//! - Location declarations with fields
@@ -7,7 +7,7 @@
location MarthasBakery {
capacity: 30
type: "shop"
type: Shop
open_hours: "04:00-14:00"
---description
@@ -19,12 +19,14 @@ location MarthasBakery {
The smell of fresh bread seeps out through the door from before dawn,
drawing the earliest risers. A small chalkboard by the entrance lists
the day's specials in Jane's elegant handwriting.
the day's specials in Jane's elegant handwriting. In the back corner,
Old Maggie — the thirty-year-old sourdough starter — sits in a ceramic
crock wrapped in a wool blanket, waiting for the cold snap to pass.
---
}
location MainStreet {
type: "road"
type: Road
foot_traffic: 0.8
---description
@@ -35,3 +37,33 @@ location MainStreet {
and laughter.
---
}
location TownHall {
capacity: 200
type: PublicBuilding
---description
The oldest stone building in town, built in 1780 and expanded twice
since. The main hall has high ceilings, arched windows, and long
wooden tables that serve for guild meetings, town councils, and — once
a year — the Harvest Baking Competition. During competition week, the
hall smells of flour and anticipation. Trestle tables line the walls
for each competitor's station, and the judges sit at an elevated table
at the far end, beneath a portrait of the guild's founder.
---
}
location SchoolHouse {
capacity: 120
type: School
---description
A redbrick building at the end of the lane, with tall windows and a
bell tower that still rings at eight each morning. The gymnasium
doubles as the science fair venue on Friday evenings, with folding
tables arranged in rows for student displays. Emma's poster board
on fermentation chemistry sits between a model volcano and a
solar-system mobile, drawing a surprising number of visitors who
want to know why bread rises.
---
}

View File

@@ -1,96 +0,0 @@
//! Relationships for the Baker family
//!
//! Demonstrates:
//! - Multiple relationship types
//! - Asymmetric participant perspectives (roles)
//! - Participant-specific fields
//! - Shared relationship fields
// Marriage between Martha and Jane
relationship Marriage {
Martha as wife {
commitment: 0.95
role_in_bakery: "business and bread"
}
Jane as wife {
commitment: 0.95
role_in_bakery: "pastries and cakes"
}
years_together: 14
relationship_quality: 0.90
}
// Martha and Emma - parent/child
relationship ParentChild_MarthaEmma {
Martha as parent {
parenting_style: "encouraging"
teaches: "baking fundamentals"
}
Emma as child {
admiration: 0.9
learns_from: "baking science"
}
}
// Jane and Emma - parent/child
relationship ParentChild_JaneEmma {
Jane as parent {
parenting_style: "creative"
teaches: "pastry decoration"
}
Emma as child {
admiration: 0.85
learns_from: "artistic expression"
}
}
// Martha and Jane - business partnership (they co-run the bakery)
relationship BusinessPartnership {
Martha as co_owner {
domain: "bread and business"
manages: "operations and suppliers"
}
Jane as co_owner {
domain: "pastries and presentation"
manages: "menu design and displays"
}
partnership_strength: 0.95
}
// Henry as loyal customer
relationship CustomerRelationship {
Martha as baker {
service_priority: "high"
reserved_item: "sourdough loaf"
}
Henry as customer {
loyalty: 0.95
daily_visit: true
favorite_item: "sourdough"
}
years_as_customer: 8
}
// Roland and Martha - business competition
relationship Competition {
Martha as competitor {
market_share: 0.65
advantage: "customer loyalty"
}
Roland as competitor {
market_share: 0.35
advantage: "lower prices"
}
intensity: 0.70
mutual_respect: 0.40
}

View File

@@ -0,0 +1,70 @@
//! Bakery relationships — business, customers, and rivalry
// Martha and Jane - business partnership
relationship BusinessPartnership {
Martha as co_owner {
domain: BusinessAndBread
manages: OperationsAndSuppliers
}
Jane as co_owner {
domain: PastriesAndPresentation
manages: MenuDesignAndDisplays
}
partnership_strength: 0.95
}
// Henry as loyal customer — complicated this year by his judging role
relationship CustomerRelationship {
Martha as baker {
service_priority: High
reserved_item: "sourdough loaf"
}
Henry as customer {
loyalty: 0.95
daily_visit: true
favorite_item: "sourdough"
}
years_as_customer: 8
awkwardness: 0.6
---description
Henry has been Martha's most loyal customer for eight years, but his
new role as competition judge has introduced an uncomfortable tension.
Martha still sets aside his morning loaf, and Henry still arrives at
seven sharp, but they both avoid talking about Saturday. Henry worries
about impartiality. Martha worries he will overcompensate by scoring
her lower than she deserves.
---
}
// Roland and Martha - baking competition rivalry
relationship Competition {
Martha as competitor {
market_share: 0.65
advantage: CustomerLoyalty
competition_wins: 3
}
Roland as competitor {
market_share: 0.35
advantage: LowerPrices
competition_wins: 1
}
intensity: 0.80
mutual_respect: 0.40
---description
The rivalry between Martha and Roland has sharpened since last year's
competition, when Roland's dark rye unseated Martha's three-year
winning streak. The tension deepened when Roland hired Thomas,
Martha's former apprentice, creating a rift that guild meetings
have not fully healed. Roland respects Martha's skill but will
never say so sober. Martha considers his methods sound but his
ethics questionable.
---
}

View File

@@ -0,0 +1,43 @@
//! Family relationships — marriage and parent/child bonds
// Marriage between Martha and Jane
relationship Marriage {
Martha as wife {
commitment: 0.95
role_in_bakery: BusinessAndBread
}
Jane as wife {
commitment: 0.95
role_in_bakery: PastriesAndCakes
}
years_together: 14
relationship_quality: 0.90
}
// Martha and Emma - parent/child
relationship ParentChild_MarthaEmma {
Martha as parent {
parenting_style: Encouraging
teaches: BakingFundamentals
}
Emma as child {
admiration: 0.9
learns_from: BakingScience
}
}
// Jane and Emma - parent/child
relationship ParentChild_JaneEmma {
Jane as parent {
parenting_style: Creative
teaches: PastryDecoration
}
Emma as child {
admiration: 0.85
learns_from: ArtisticExpression
}
}

View File

@@ -0,0 +1,57 @@
//! Baker's schedule — Martha and Jane's competition week
//!
//! Modifies WorkWeek: pre-dawn start, then a full week of competition prep
//! building toward Saturday's Harvest Baking Competition.
schedule BakerSchedule modifies WorkWeek {
// Bakers start before dawn
override work {
05:00 -> 13:00
action:BakingWork
intensity:High
}
block pre_dawn_prep {
04:00 -> 05:00
action:PrepKitchen
}
block afternoon_rest { 14:00 -> 16:00, action:Resting }
// Monday: Guild meeting — competition rules announced, tension with Roland
recurrence GuildMeeting on Monday {
block guild_evening { 18:00 -> 20:00, action:AttendGuildMeeting }
}
// Tuesday: Test competition recipes, Old Maggie still sluggish
recurrence RecipeTesting on Tuesday {
block test_bake { 14:00 -> 17:00, action:TestCompetitionRecipe }
}
// Wednesday: Source premium flour and imported butter
recurrence SupplierDay on Wednesday {
block source_ingredients { 14:00 -> 16:00, action:SourceIngredients }
}
// Thursday: Mix competition dough, feed Old Maggie extra, 24h rise begins
recurrence CompPrep on Thursday {
block comp_prep { 14:00 -> 18:00, action:PrepCompetitionDough }
}
// Friday: Regular baking day + Emma's science fair in the evening
recurrence ScienceFair on Friday {
block science_fair { 17:00 -> 19:00, action:AttendScienceFair }
}
// Saturday: Competition day!
recurrence CompetitionDay on Saturday {
block competition { 06:00 -> 16:00, action:CompetitionRoutine }
block celebration { 17:00 -> 22:00, action:Celebration }
}
// Sunday: Recovery and family time
recurrence SundayRest on Sunday {
block family_morning { 08:00 -> 12:00, action:FamilyBreakfast }
block rest { 12:00 -> 18:00, action:Resting }
}
}

View File

@@ -0,0 +1,7 @@
//! Base work schedule — the foundation all other schedules modify
schedule WorkWeek {
block morning_routine { 07:00 -> 08:00, action:MorningRoutine }
block work { 09:00 -> 17:00, action:DailyWork }
block evening_rest { 18:00 -> 22:00, action:Resting }
}

View File

@@ -0,0 +1,21 @@
//! Henry's retired schedule — daily routine and judging week
schedule RetiredSchedule modifies WorkWeek {
override work {
07:00 -> 07:30
action:BakeryVisit
}
block morning_walk { 08:00 -> 09:00, action:MorningWalk }
block reading { 10:00 -> 12:00, action:ReadingTime }
// Friday: Review judging criteria before Saturday's competition
recurrence JudgingPrep on Friday {
block review_criteria { 14:00 -> 16:00, action:ReviewJudgingCriteria }
}
// Saturday: Judge the Harvest Baking Competition
recurrence CompetitionJudge on Saturday {
block judging { 08:00 -> 16:00, action:JudgeCompetition }
}
}

View File

@@ -0,0 +1,26 @@
//! Emma's school week — science fair week
schedule SchoolWeek modifies WorkWeek {
override work {
08:30 -> 15:30
action:SchoolDay
}
block homework { 16:00 -> 17:30, action:DoHomework }
block bakery_help { 17:30 -> 18:30, action:HelpInBakery }
// Thursday: Prep science fair poster and presentation
recurrence ScienceFairPrep on Thursday {
block fair_prep { 16:00 -> 18:00, action:PrepareScienceFair }
}
// Friday: Science fair presentation day
recurrence ScienceFairDay on Friday {
block fair_presentation { 17:00 -> 19:00, action:ScienceFairPresentation }
}
// Saturday: Help parents at the competition
recurrence WeekendBakery on Saturday {
block help_at_competition { 07:00 -> 16:00, action:HelpAtCompetition }
}
}

View File

@@ -1,55 +0,0 @@
//! Work schedules for the Baker family
//!
//! Demonstrates schedule composition features:
//! - modifies keyword for schedule inheritance
//! - override blocks to modify inherited schedules
//! - Named blocks for override system
//! - Action references to behavior trees
//! - Recurrence patterns for weekly variations
// Base work schedule (9-5 job)
schedule WorkWeek {
block morning_prep { 08:00 -> 09:00, action:MorningPrep }
block work { 09:00 -> 17:00, action:DailyWork }
block evening_rest { 18:00 -> 22:00, action:Resting }
}
// Baker's schedule modifies WorkWeek
schedule BakerSchedule modifies WorkWeek {
// Bakers start early - override the work block
override work {
05:00 -> 13:00
action:BakingWork
intensity:"high"
}
// Add pre-dawn prep
block pre_dawn_prep {
04:00 -> 05:00
action:PrepKitchen
}
// Market day on Saturdays
recurrence MarketDay on Saturday {
block market {
06:00 -> 14:00
action:SellAtMarket
place:"town_square"
}
}
}
// Assistant baker schedule (helps during busy times)
schedule AssistantSchedule modifies BakerSchedule {
// Assistant comes in later
override work {
06:00 -> 14:00
action:AssistWithBaking
}
// Assistant does a quick prep before work
override pre_dawn_prep {
05:30 -> 06:00
action:QuickPrep
}
}

View File

@@ -0,0 +1,86 @@
//! Baking types — products, specialties, skills, and craft domains
//!
//! The type vocabulary for everything that happens in the bakery.
// Bakery product categories
concept BakedGood
sub_concept BakedGood.Category {
Bread,
Pastry,
Cake
}
sub_concept BakedGood.Quality { freshness: 1.0, taste: 0.8 }
// Competition categories for the Harvest Baking Competition
sub_concept BakedGood.CompetitionCategory {
Signature,
FreeStyle,
Traditional
}
// Baker specialties
concept BakerSpecialty
sub_concept BakerSpecialty.Type {
Sourdough,
Pastries,
RyeBread,
Bread,
Artisan,
Learning
}
// Skill levels
concept SkillLevel
sub_concept SkillLevel.Tier {
Apprentice,
Journeyman,
Master
}
// Definition - compile-time mapping of skill tiers to quality expectations
// An Apprentice can produce any quality; a Master must produce fresh goods
definition SkillLevel {
Apprentice: {
baking_skill: Tier is Apprentice,
freshness: any
},
Journeyman: {
baking_skill: Tier is Journeyman,
freshness: any
},
Master: {
baking_skill: Tier is Master,
freshness: Tier is Master
}
}
// Baking disciplines (what bakers teach and learn)
concept BakingDiscipline
sub_concept BakingDiscipline.Area {
BakingFundamentals,
PastryDecoration,
BakingScience,
ArtisticExpression
}
// Bakery domain (areas of responsibility)
concept BakeryDomain
sub_concept BakeryDomain.Focus {
BusinessAndBread,
PastriesAndCakes,
PastriesAndPresentation
}
// Management domains
concept ManagementDomain
sub_concept ManagementDomain.Area {
OperationsAndSuppliers,
MenuDesignAndDisplays
}

View File

@@ -0,0 +1,32 @@
//! Core types — the Human species and universal concepts
//!
//! These are the foundational types used by all templates and characters.
// Species definition - provides default fields for all humans
species Human {
age: 0
energy: 0.5
mood: 0.5
occupation: "unemployed"
}
// Occupations
concept Occupation
sub_concept Occupation.Role {
Unemployed,
Laborer,
MasterBaker,
PastryChef,
Baker,
RetiredTeacher
}
// Intensity levels (used for work intensity, service priority)
concept Intensity
sub_concept Intensity.Level {
Low,
Medium,
High
}

View File

@@ -8,21 +8,21 @@
life_arc BakerCareer requires { baking_skill: Number, work_ethic: Number } {
state apprentice {
on enter {
specialty: "learning"
specialty: Learning
}
on baking_skill > 0.5 and work_ethic > 0.7 -> journeyman
}
state journeyman {
on enter {
specialty: "bread"
specialty: Bread
}
on baking_skill > 0.8 and work_ethic > 0.9 -> master
}
state master {
on enter {
specialty: "artisan"
specialty: Artisan
}
}
}

View File

@@ -0,0 +1,17 @@
//! Social types — relationship and competition vocabulary
// Parenting styles
concept ParentingStyle
sub_concept ParentingStyle.Type {
Encouraging,
Creative
}
// Competitive advantage (used in rivalry relationships)
concept CompetitiveAdvantage
sub_concept CompetitiveAdvantage.Type {
CustomerLoyalty,
LowerPrices
}

View File

@@ -18,7 +18,7 @@ template Person: Human {
template Worker {
include Person
uses schedule: WorkWeek
occupation: "laborer"
occupation: Laborer
work_ethic: 0.5..1.0
}
@@ -27,7 +27,7 @@ template Baker {
include Worker
uses behaviors: BakingSkills, CustomerService
uses schedule: BakerSchedule
specialty: "bread"
specialty: Bread
baking_skill: 0.0..1.0
customer_relations: 0.5..1.0
}

View File

@@ -1,51 +0,0 @@
//! Type system definitions for the Baker family
//!
//! Demonstrates v0.3.0 type system features:
//! - Species definitions with default fields
//! - Concepts and sub-concepts with dot notation
//! - Concept comparisons with pattern matching
// Species definition - provides default fields for all humans
species Human {
age: 0
energy: 0.5
mood: 0.5
occupation: "unemployed"
}
// Bakery product types
concept BakedGood
sub_concept BakedGood.Category {
Bread,
Pastry,
Cake
}
sub_concept BakedGood.Quality { freshness: 1.0, taste: 0.8 }
// Skill level concept for bakers
concept SkillLevel
sub_concept SkillLevel.Tier {
Apprentice,
Journeyman,
Master
}
// Definition - compile-time mapping of skill tiers to quality expectations
// An Apprentice can produce any quality; a Master must produce fresh goods
definition SkillLevel {
Apprentice: {
baking_skill: Tier is Apprentice,
freshness: any
},
Journeyman: {
baking_skill: Tier is Journeyman,
freshness: any
},
Master: {
baking_skill: Tier is Master,
freshness: Tier is Master
}
}

View File

@@ -0,0 +1,28 @@
//! World types — the physical and institutional landscape
// Weather conditions (affects sourdough starters like Old Maggie)
concept WeatherCondition
sub_concept WeatherCondition.Type {
ColdSnap,
Mild,
Warm,
Hot
}
// Location types
concept LocationType
sub_concept LocationType.Kind {
Shop,
Road,
PublicBuilding,
School
}
// Institution types
concept InstitutionType
sub_concept InstitutionType.Kind {
TradeGuild
}

View File

@@ -1,258 +0,0 @@
//! Demonstration of new behavior tree keyword syntax
//! This file showcases all the new features approved for implementation
// Simple behavior with choose and then
behavior SimpleGuardPatrol {
---description
A village guard who responds to threats or patrols.
Demonstrates basic choose/then keywords.
---
choose patrol_action {
then respond_to_threat {
if(threat_detected)
sound_alarm
rush_to_threat
}
repeat {
then {
patrol_north
patrol_east
patrol_south
patrol_west
}
}
}
}
// Named nodes
behavior ComplexBehavior {
---description
Demonstrates named nodes for better organization and debugging.
Labels help identify which part of the tree is executing.
---
choose root {
then handle_urgent {
when(need.any is urgent)
identify_need
satisfy_need
}
then social_interaction {
when(friend_nearby)
greet_friend
chat
}
then default_activity {
idle_wait
}
}
}
// Advanced decorators
behavior WhiteRabbitAnxiety {
---description
The White Rabbit from Alice in Wonderland, demonstrating
all decorator types: repeat, retry, timeout, cooldown, if.
---
choose {
// Extreme panic when very late
then panic_mode {
if(minutes_late > 100)
timeout(3s) {
repeat(5) {
then {
check_pocket_watch
mutter_desperately
}
}
}
sprint_to_destination
}
// Try to find alternate route when blocked
then find_route {
if(obstacle_encountered)
drop_gloves
drop_fan
retry(2) {
find_alternate_route
}
}
// Queen response with cooldown
then queen_response {
if(queen_nearby)
flatten_ears_in_fear
trembling_bow
cooldown(60s) {
await_commands
}
}
// Only run if energy is sufficient
if(energy > 30) {
scurry_around_frantically
}
// Default: perpetual anxiety
repeat {
then {
check_watch
mutter_anxiously
scurry_forward
}
}
}
}
// Mad Tea Party with infinite repeat
behavior MadTeaParty {
---description
The Mad Hatter's tea party that loops forever.
Demonstrates infinite repeat decorator.
---
repeat {
choose tea_party_activities {
then riddles {
pose_riddle
wait_for_answer
declare_answer_wrong
}
then seat_rotation {
switch_seats
clean_dirty_teacup
pour_fresh_tea
}
then dormouse_interaction {
wake_dormouse
listen_to_brief_story
stuff_dormouse_in_teapot
}
}
}
}
// Cheshire Cat with timing decorators
behavior CheshireCatMaterialization {
---description
Complex behavior with nested decorators showing gradual
materialization and dematerialization with timing controls.
---
choose {
// Materialize when Alice is near
then materialize {
if(alice_nearby and visibility < 0.1)
timeout(10s) {
repeat(5) {
then {
increase_visibility(0.2)
pause_for_effect(1s)
}
}
}
materialize_grin
speak_in_riddles
}
// Dematerialize when fully visible
then dematerialize {
if(visibility > 0.9)
cooldown(30s) {
timeout(8s) {
repeat(5) {
then {
decrease_visibility(0.2)
pause_for_effect(1s)
}
}
}
}
vanish_except_grin
}
// Only float when partially visible
if(visibility >= 0.5) {
idle_float
}
}
}
// Subtree inclusion
behavior WorkBehaviorWithSubtree {
---description
Demonstrates subtree inclusion with the new 'include' keyword.
---
choose {
include common::handle_urgent_needs
then work {
when(at_workplace)
perform_work_tasks
}
idle_wait
}
}
// Invert decorator
behavior AvoidEnemies {
---description
Uses invert decorator to reverse condition logic.
---
choose {
then safe_path {
invert {
if(enemy_nearby)
}
take_direct_route
}
then danger_path {
take_long_safe_route
}
}
}
// Repeat with range
behavior SearchBehavior {
---description
Demonstrates repeat with min..max range.
---
repeat(3..7) {
then {
search_area
rest_briefly
}
}
}
// Always succeed/fail decorators (for debugging)
behavior DebugBehavior {
---description
Shows succeed_always and fail_always decorators.
---
choose {
succeed_always {
experimental_feature
}
fail_always {
disabled_legacy_behavior
}
fallback_behavior
}
}

View File

@@ -119,15 +119,15 @@ fn test_baker_family_field_values() {
panic!("age should be a Number");
}
// Martha sets specialty: "sourdough" (overriding Baker template default
// "bread")
if let Some(storybook::syntax::ast::Value::Text(specialty)) = martha.fields.get("specialty") {
// Martha sets specialty: Sourdough (overriding Baker template default Bread)
if let Some(storybook::syntax::ast::Value::Identifier(parts)) = martha.fields.get("specialty") {
assert_eq!(
specialty, "sourdough",
"Martha's specialty should be sourdough"
parts,
&vec!["Sourdough".to_string()],
"Martha's specialty should be Sourdough"
);
} else {
panic!("specialty should be a Text");
panic!("specialty should be an Identifier");
}
}
@@ -182,9 +182,13 @@ fn test_baker_family_has_expected_schedules() {
#[test]
fn test_baker_family_multi_file_structure() {
// Baker family is organized across multiple files:
// - schema/templates.sb
// - behaviors/baker_behaviors.sb
// - schedules/work_schedules.sb
// - schema/core_types.sb, baking_types.sb, world_types.sb, social_types.sb
// - schema/templates.sb, life_arcs.sb
// - behaviors/baker_behaviors.sb, person_behaviors.sb, child_behaviors.sb
// - behaviors/competition_behaviors.sb, henry_behaviors.sb
// - schedules/base_schedule.sb, baker_schedule.sb, school_schedule.sb,
// retired_schedule.sb
// - relationships/family_relationships.sb, bakery_relationships.sb
// - characters/*.sb
let project = load_example("baker-family");