basic_usage/
basic_usage.rs

1//! Basic usage example of the phyla-lang library.
2
3use phyla_lang::{CulturalProfile, Geography, Language};
4
5fn main() {
6    println!("=== Phyla-Lang: Procedural Language Generation ===\n");
7
8    // Define different cultures
9    let coastal_folk = CulturalProfile::new(
10        4.0, // High agreeableness - cooperative, empathetic
11        3.0, // Moderate openness
12        2.0, // Lower conscientiousness - more flexible
13        3.0, // Moderate extraversion
14        3.0, // Moderate honesty-humility
15        4.0, // High emotionality - sensitive, expressive
16    );
17
18    let mountain_warriors = CulturalProfile::new(
19        1.0, // Low agreeableness - more competitive
20        2.0, // Lower openness - traditional
21        4.0, // High conscientiousness - disciplined
22        3.0, // Moderate extraversion
23        3.0, // Moderate honesty-humility
24        2.0, // Lower emotionality - stoic
25    );
26
27    let river_scholars = CulturalProfile::new(
28        3.0, // Moderate agreeableness
29        4.0, // High openness - innovative, curious
30        4.0, // High conscientiousness - organized
31        3.0, // Moderate extraversion
32        4.0, // High honesty-humility - modest, sincere
33        3.0, // Moderate emotionality
34    );
35
36    // Create languages
37    let melodic = Language::from_culture(coastal_folk, Geography::Coastal, 1001);
38    let harsh = Language::from_culture(mountain_warriors, Geography::Mountains, 1002);
39    let scholarly = Language::from_culture(river_scholars, Geography::RiverValley, 1003);
40
41    println!("1. MELODIC COASTAL LANGUAGE (Agreeable, Emotional, Coastal)");
42    println!("   Word order: {:?}", melodic.word_order());
43    demonstrate_language(&melodic);
44
45    println!("\n2. MOUNTAIN WARRIOR LANGUAGE (Disagreeable, Conscientious, Mountains)");
46    println!("   Word order: {:?}", harsh.word_order());
47    demonstrate_language(&harsh);
48
49    println!("\n3. RIVER VALLEY SCHOLAR LANGUAGE (Open, Conscientious, River Valley)");
50    println!("   Word order: {:?}", scholarly.word_order());
51    demonstrate_language(&scholarly);
52
53    // Demonstrate determinism
54    println!("\n=== DETERMINISM DEMONSTRATION ===");
55    println!("Creating two identical languages with the same parameters...\n");
56
57    let lang1 = Language::from_culture(coastal_folk, Geography::Coastal, 5555);
58    let lang2 = Language::from_culture(coastal_folk, Geography::Coastal, 5555);
59
60    let word1 = lang1.translate_word("forever");
61    let word2 = lang2.translate_word("forever");
62
63    println!("Language 1 translates 'forever' as: {}", word1);
64    println!("Language 2 translates 'forever' as: {}", word2);
65    println!("Are they the same? {}", word1 == word2);
66
67    // Demonstrate word variation
68    println!("\n=== VOCABULARY SAMPLE ===");
69    let concepts = vec![
70        "water", "fire", "earth", "wind", "sun", "moon", "star", "tree", "stone", "mountain",
71    ];
72
73    println!("\nCoastal Language:");
74    for concept in &concepts {
75        println!("  {} → {}", concept, melodic.translate_word(concept));
76    }
77
78    println!("\nMountain Language:");
79    for concept in &concepts {
80        println!("  {} → {}", concept, harsh.translate_word(concept));
81    }
82
83    println!("\nScholar Language:");
84    for concept in &concepts {
85        println!("  {} → {}", concept, scholarly.translate_word(concept));
86    }
87}
88
89fn demonstrate_language(language: &Language) {
90    let phrases = vec![
91        "I bring the beer quickly",
92        "the sun rises in the east",
93        "water flows down the mountain",
94    ];
95
96    for phrase in phrases {
97        println!("   \"{}\" → \"{}\"", phrase, language.translate_phrase(phrase));
98    }
99}
100