release: Storybook v0.2.0 - Major syntax and features update
BREAKING CHANGES: - Relationship syntax now requires blocks for all participants - Removed self/other perspective blocks from relationships - Replaced 'guard' keyword with 'if' for behavior tree decorators Language Features: - Add tree-sitter grammar with improved if/condition disambiguation - Add comprehensive tutorial and reference documentation - Add SBIR v0.2.0 binary format specification - Add resource linking system for behaviors and schedules - Add year-long schedule patterns (day, season, recurrence) - Add behavior tree enhancements (named nodes, decorators) Documentation: - Complete tutorial series (9 chapters) with baker family examples - Complete reference documentation for all language features - SBIR v0.2.0 specification with binary format details - Added locations and institutions documentation Examples: - Convert all examples to baker family scenario - Add comprehensive working examples Tooling: - Zed extension with LSP integration - Tree-sitter grammar for syntax highlighting - Build scripts and development tools Version Updates: - Main package: 0.1.0 → 0.2.0 - Tree-sitter grammar: 0.1.0 → 0.2.0 - Zed extension: 0.1.0 → 0.2.0 - Storybook editor: 0.1.0 → 0.2.0
This commit is contained in:
208
examples/baker-family/behaviors/baker_behaviors.sb
Normal file
208
examples/baker-family/behaviors/baker_behaviors.sb
Normal file
@@ -0,0 +1,208 @@
|
||||
//! Behavior trees for the Baker family
|
||||
//!
|
||||
//! These are referenced by schedule blocks via the action: field
|
||||
|
||||
// Main baking work routine
|
||||
behavior BakingWork {
|
||||
then {
|
||||
check_orders
|
||||
prepare_ingredients
|
||||
choose {
|
||||
make_bread
|
||||
make_pastries
|
||||
make_cakes
|
||||
}
|
||||
bake
|
||||
cool_products
|
||||
package_goods
|
||||
}
|
||||
}
|
||||
|
||||
// Kitchen prep routine
|
||||
behavior PrepKitchen {
|
||||
then {
|
||||
clean_surfaces
|
||||
check_supplies
|
||||
preheat_ovens
|
||||
organize_workspace
|
||||
}
|
||||
}
|
||||
|
||||
// type
|
||||
concept Vendor;
|
||||
|
||||
// type
|
||||
sub_concept VendorInventory {
|
||||
Bread: any,
|
||||
Pastries: any,
|
||||
Cakes: any,
|
||||
Cup: any
|
||||
}
|
||||
|
||||
// type (but really just an enum lol)
|
||||
concept Cup;
|
||||
|
||||
// enum
|
||||
sub_concept CupSize: {
|
||||
Small,
|
||||
Medium,
|
||||
Large
|
||||
}
|
||||
|
||||
// enum
|
||||
sub_concept CupType: {
|
||||
Ceramic,
|
||||
Glass,
|
||||
Plastic
|
||||
}
|
||||
|
||||
// enum
|
||||
sub_concept CupColor {
|
||||
Red,
|
||||
Blue,
|
||||
Green
|
||||
}
|
||||
|
||||
// enum comparison done at compile time
|
||||
concept_comparison CustomerInterestInCups {
|
||||
Interested: {
|
||||
CupSize: any, // any means any value of the type can be matched
|
||||
CupType: CupType is Glass or CupType is Plastic,
|
||||
CupColor: CupColor is Red or CupColor is Blue
|
||||
},
|
||||
NotInterested: {
|
||||
CupSize: any,
|
||||
CupType: any,
|
||||
CupColor: any
|
||||
},
|
||||
Maybe: {
|
||||
CupSize: any,
|
||||
CupType: any,
|
||||
CupColor: any
|
||||
}
|
||||
}
|
||||
|
||||
// type
|
||||
concept Plate;
|
||||
|
||||
// enum
|
||||
sub_concept PlateColor {
|
||||
Blue,
|
||||
Green,
|
||||
Red
|
||||
}
|
||||
|
||||
// type
|
||||
concept Customer;
|
||||
|
||||
// enum
|
||||
sub_concept CustomerInterest {
|
||||
Interested: 10,
|
||||
NotInterested: 20,
|
||||
Maybe: 70
|
||||
}
|
||||
|
||||
|
||||
// Market day selling behavior
|
||||
behavior SellAtMarket {
|
||||
repeat {
|
||||
then {
|
||||
greet_customer
|
||||
show_products
|
||||
if(CustomerInterestInCups.Interested.CupSize is Medium or CupSize is Large and CustomerInterestInCups.Interested.CupType is Glass or CupType is Plastic and CustomerInterestInCups.Interested.CupColor is Red or CupColor is Blue) {
|
||||
make_sale(Cup)
|
||||
}
|
||||
if(CustomerInterestInCups.Interested.CupSize is Small and CustomerInterestInCups.Interested.CupType is Ceramic and CustomerInterestInCups.Interested.CupColor is Green) {
|
||||
if (Plate.PlateColor is Blue or PlateColor is Green) {
|
||||
// variadic arguments
|
||||
make_sale(Cup, Plate)
|
||||
}
|
||||
// or there can be generic fallthroughs too
|
||||
thank_customer
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
}
|
||||
|
||||
concept Hunger;
|
||||
|
||||
sub_concept HungerState {
|
||||
Hungry,
|
||||
NotHungry
|
||||
}
|
||||
|
||||
// Basic needs (from Person template)
|
||||
behavior BasicNeeds {
|
||||
repeat {
|
||||
choose {
|
||||
if(HungryState.Hungry) { eat }
|
||||
if(HungryState.NotHungry) { rest }
|
||||
if(thirsty) { drink }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Social interaction
|
||||
behavior SocialInteraction {
|
||||
choose {
|
||||
greet_neighbors
|
||||
chat_with_customers
|
||||
family_time
|
||||
}
|
||||
}
|
||||
|
||||
// Baking skills
|
||||
behavior BakingSkills {
|
||||
then {
|
||||
assess_dough
|
||||
adjust_recipe
|
||||
monitor_temperature
|
||||
}
|
||||
}
|
||||
|
||||
// Customer service
|
||||
behavior CustomerService {
|
||||
then {
|
||||
greet_warmly
|
||||
listen_to_needs
|
||||
recommend_products
|
||||
handle_payment
|
||||
}
|
||||
}
|
||||
|
||||
// Child behaviors
|
||||
behavior PlayBehavior {
|
||||
choose {
|
||||
play_outside
|
||||
play_with_toys
|
||||
draw_pictures
|
||||
}
|
||||
}
|
||||
|
||||
behavior LearnBehavior {
|
||||
then {
|
||||
attend_school
|
||||
do_homework
|
||||
read_books
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user