using Godot; namespace WorldSim; /// Domains of practical knowledge (SPEC §5 — deliberately few). public enum KnowledgeDomain { Forage, Woodcraft, Masonry } /// /// What a person knows how to do (SPEC §5). Not an object in the world — /// it lives in people, spreads by proximity, grows by practice, and dies /// with its holder unless it was passed on. Every death is a small library /// burning; a teaching culture is a culture of copies. /// /// Capacity is personal and randomized: some people can hold more than /// others, and what fills first is what they lived. /// public class Knowledge { public const int DomainCount = 3; /// 0–1 per domain. public float[] Skill = new float[DomainCount]; /// Total learning this mind can hold, across all domains. public float Capacity = 1.5f; public float Total => Skill[0] + Skill[1] + Skill[2]; public float Headroom => Mathf.Max(0f, Capacity - Total); public float this[KnowledgeDomain d] => Skill[(int)d]; /// Learn, limited by personal capacity. public void Gain(KnowledgeDomain d, float amount) { if (amount <= 0f || Headroom <= 0f) return; float a = Mathf.Min(amount, Headroom); Skill[(int)d] = Mathf.Clamp(Skill[(int)d] + a, 0f, 1f); } /// Which domain a material teaches and benefits from. public static KnowledgeDomain DomainFor(MaterialKind kind) => kind switch { MaterialKind.Food => KnowledgeDomain.Forage, MaterialKind.Herb => KnowledgeDomain.Forage, // gathering the living land MaterialKind.Wood => KnowledgeDomain.Woodcraft, _ => KnowledgeDomain.Masonry, // stone, clay, ore — builder's craft }; }