using System; namespace WulaFallenEmpire.EventSystem.AI { /// /// Represents a single memory entry extracted from conversations. /// Inspired by Mem0's memory structure. /// public class AIMemoryEntry { /// Unique identifier for this memory public string Id { get; set; } /// The actual memory content/fact public string Fact { get; set; } /// /// Category of memory: preference, personal, plan, colony, misc /// public string Category { get; set; } /// Game ticks when this memory was created public long CreatedTicks { get; set; } /// Game ticks when this memory was last updated public long UpdatedTicks { get; set; } /// Number of times this memory has been accessed/retrieved public int AccessCount { get; set; } /// Hash of the fact for quick duplicate detection public string Hash { get; set; } public AIMemoryEntry() { Id = Guid.NewGuid().ToString("N").Substring(0, 12); CreatedTicks = 0; UpdatedTicks = 0; AccessCount = 0; Category = "misc"; } public AIMemoryEntry(string fact, string category = "misc") : this() { Fact = fact; Category = category ?? "misc"; Hash = ComputeHash(fact); } public static string ComputeHash(string text) { if (string.IsNullOrEmpty(text)) return ""; // Simple hash based on normalized text string normalized = text.ToLowerInvariant().Trim(); return normalized.GetHashCode().ToString("X8"); } public void UpdateFact(string newFact) { Fact = newFact; Hash = ComputeHash(newFact); } public void MarkAccessed() { AccessCount++; } } }