// The message should be formatted as [<dest>][{tag1, ..., tagN}][<content>] // where <dest> is either "WorkingMemory" or "LongTermMemory". The tag list is optional for items // inserted into working memory, but must be present for long-term memory items. If tags are included, // they are added to the tag list of the memory item. Then the content (specified in <content>, without // the < >) is added as well. // Note that the message must have PRECISELY the shape defined above! private void ProcessInternetInput(string message) { StringMemoryItem internetInputItem = new StringMemoryItem(); char leftSeparationCharacter = AgentConstants.INTERNET_INPUT_LEFT_SEPARATION_CHARACTER; char rightSeparationCharacter = AgentConstants.INTERNET_INPUT_RIGHT_SEPARATION_CHARACTER; List <string> messageSplit = message.Split(new char[] { leftSeparationCharacter, rightSeparationCharacter }, StringSplitOptions.RemoveEmptyEntries).ToList(); if (messageSplit.Count == 2) // No tags { if (messageSplit[0] == AgentConstants.WORKING_MEMORY_NAME) { string content = messageSplit[1]; if (content != null) { if (content.Length > 0) { internetInputItem.SetContent(content); internetInputItem.TagList.Add(internetInputTag); workingMemory.AddItem(internetInputItem); timeOfLastInternetInput = internetInputItem.InsertionTime; // if (!busy) { HandleInput(internetInputItem); } } } } } else if (messageSplit.Count == 3) { if (messageSplit[0] == AgentConstants.WORKING_MEMORY_NAME) { string content = messageSplit[2]; if (content != null) { if (content.Length > 0) { internetInputItem.SetContent(content); internetInputItem.TagList.Add(internetInputTag); char leftListCharacter = AgentConstants.INTERNET_INPUT_TAG_LIST_LEFT_CHARACTER; char rightListCharacter = AgentConstants.INTERNET_INPUT_TAG_LIST_RIGHT_CHARACTER; char separator = AgentConstants.INTERNET_INPUT_TAG_LIST_SEPARATOR_CHARACTER; List <string> tagListSplit = messageSplit[1].Split(new char[] { leftListCharacter, rightListCharacter, separator }, StringSplitOptions.RemoveEmptyEntries).ToList(); if (tagListSplit != null) { if (tagListSplit.Count > 0) { foreach (string tag in tagListSplit) { internetInputItem.TagList.Add(tag); } } } workingMemory.AddItem(internetInputItem); timeOfLastInternetInput = internetInputItem.InsertionTime; // if (!busy) { HandleInput(internetInputItem); } } } } else if (messageSplit[0] == AgentConstants.LONG_TERM_MEMORY_NAME) { // Insertions on long-term memory do not trigger actions by the agent, but the contents // will of course be available for later use. // Also, for long-term memory items, tags are _required_. If no tags are present, the // input is simply ignored. char leftListCharacter = AgentConstants.INTERNET_INPUT_TAG_LIST_LEFT_CHARACTER; char rightListCharacter = AgentConstants.INTERNET_INPUT_TAG_LIST_RIGHT_CHARACTER; char separator = AgentConstants.INTERNET_INPUT_TAG_LIST_SEPARATOR_CHARACTER; List <string> tagListSplit = messageSplit[1].Split(new char[] { leftListCharacter, rightListCharacter, separator }, StringSplitOptions.RemoveEmptyEntries).ToList(); if (tagListSplit != null) { if (tagListSplit.Count > 0) { foreach (string tag in tagListSplit) { internetInputItem.TagList.Add(tag); } string content = messageSplit[2]; if (content != null) { if (content.Length > 0) { internetInputItem.SetContent(content); longtermMemory.AddItem(internetInputItem); timeOfLastInternetInput = internetInputItem.InsertionTime; } } } } } } }