public void Attach(MemoryCue memCue) { cTransform.parent = memCue.CachedTransform; cTransform.localPosition = new Vector3(0.0f, 5.0f, 0.0f); lName.text = memCue.UniqueNodeID; clAlignment.enabled = true; }
private MemoryNode CreateNewMemoryNode(MemoryCue memCue) { switch (memCue.CueType) { case CueType.Character: return new CharacterNode((CharacterCue)memCue); case CueType.Item: return new ItemNode((ItemCue)memCue); case CueType.Location: return new LocationNode((LocationCue)memCue); case CueType.Event: return new EventNode((EventCue)memCue); default: throw new UnityException("MemoryNode is unhandled! The above are the only accepted types!"); } }
public override void UpdateMemory(MemoryGraph memoryGraph, MemoryGraphNode retainedMemory, MemoryCue memCue, float UpdateFrequency) { EventCue eventInfo = (EventCue)memCue; base.UpdateMemory(memoryGraph, retainedMemory, memCue, UpdateFrequency); }
public override void UpdateMemory(MemoryGraph memoryGraph, MemoryGraphNode retainedMemory, MemoryCue memCue, float UpdateFrequency) { LocationCue locInfo = (LocationCue)memCue; base.UpdateMemory(memoryGraph, retainedMemory, memCue, UpdateFrequency); }
public override void UpdateMemory(MemoryGraph memoryGraph, MemoryGraphNode retainedMemory, MemoryCue memCue, float UpdateFrequency) { if (IsMonster) return; //Current, we've no need to update monsters. CharacterCue charInfo = (CharacterCue)memCue; base.UpdateMemory(memoryGraph, retainedMemory, memCue, UpdateFrequency); }
public override void UpdateMemory(MemoryGraph memoryGraph, MemoryGraphNode retainedMemory, MemoryCue memCue, float UpdateFrequency) { ItemCue itemInfo = (ItemCue)memCue; status = itemInfo.Status; owner = itemInfo.Owner; durability = itemInfo.Durability; if (durability < 0.0f) { //Once durability starts to fall, a agent's affinity with an item will also drop. memoryGraph.UpdateCueOpinion(retainedMemory.MemoryNode, -UpdateFrequency); } base.UpdateMemory(memoryGraph, retainedMemory, memCue, UpdateFrequency); if (UpdateFrequency <= 0.0f || itemInfo.Owner == null) //We want to strengthen the memory between the specific item and the place it has been observed. return; MemoryGraphNode charNode; if (memoryGraph.Contains(itemInfo.Owner.UniqueNodeID)) charNode = memoryGraph.GetNamedNodeFromGraph(itemInfo.Owner.UniqueNodeID); else charNode = memoryGraph.AddNamedNodeToGraph(new CharacterNode(itemInfo.Owner)); //First make a connection between the character and the item. int index = charNode.Neighbours.IndexOf(retainedMemory); if (index == -1) memoryGraph.AddDirectedEdge(charNode, retainedMemory, UpdateFrequency, UpdateFrequency); else { //Strengthing the memory based on the length of time it was active in the working set. charNode.StrengthenMemory(index, UpdateFrequency); //charNode.OpinionStrengths[index] += UpdateFrequency; } //Then between the item and the character. index = retainedMemory.Neighbours.IndexOf(charNode); if (index == -1) memoryGraph.AddDirectedEdge(retainedMemory, charNode, UpdateFrequency, UpdateFrequency); else { //Strengthing the memory based on the length of time it was active in the working set. retainedMemory.StrengthenMemory(index, UpdateFrequency); //retainedMemory.OpinionStrengths[index] += UpdateFrequency; } }
public MemoryType MemoryType; //This tells us what type of memory this is about. public virtual void UpdateMemory(MemoryGraph memoryGraph, MemoryGraphNode retainedMemory, MemoryCue memCue, float UpdateFrequency) { //LastLocation = memCue.CurrentLocation; //if(memCue.CachedTransform != null) // LastPosition = memCue.CachedTransform.position; retainedMemory.LastLocation = memCue.CurrentLocation; if (memCue.CachedTransform != null) retainedMemory.LastPosition = memCue.CachedTransform.position; retainedMemory.LastUpdated = Time.time; //Debug.Log("Making a memory connection between " + memCue.UniqueNodeID + " and " + LastLocation.ToString() + " - " + UpdateFrequency); //if (UpdateFrequency <= 0.0f) //We want to strengthen the memory between the specific item and the place it has been observed. // return; MemoryGraphNode locNode; string locString = retainedMemory.LastLocation.ToString(); if (!memoryGraph.Contains(locString)) { locNode = memoryGraph.AddNamedNodeToGraph(new LocationNode(retainedMemory.LastLocation)); memoryGraph.AddUndirectedEdge(locNode, retainedMemory); } if (UpdateFrequency <= 0.0f) //We want to strengthen the memory between the specific item and the place it has been observed. return; if (memoryGraph.Contains(locString)) locNode = memoryGraph.GetNamedNodeFromGraph(locString); else locNode = memoryGraph.AddNamedNodeToGraph(new LocationNode(retainedMemory.LastLocation)); //First make a connection between the place and the item. int index = locNode.Neighbours.IndexOf(retainedMemory); if (index == -1) { //Somehow the cue relationship has been broken!? //Rebuild it! memoryGraph.AddDirectedEdge(locNode, retainedMemory, UpdateFrequency, UpdateFrequency); } else { //Strengthing the memory based on the length of time it was active in the working set. locNode.StrengthenMemory(index, UpdateFrequency); //locNode.StrengthenOpinion(index, UpdateFrequency); //We keep opinion strength updating here because it represents how strongly the agent believes the item / character etc. is connected to this location. //Debug.Log(string.Format("Node: {0}, NS: {1}, ES: {2}", retainedMemory.UID, locNode.NodeStrengths[index], locNode.EdgeStrengths[index])); //Debug.Log(string.Format("NS: {0}, ES: {1}", locNode.NodeStrengths[index], cueNode.EdgeStrengths[index])); } //Then between the item and the place. index = retainedMemory.Neighbours.IndexOf(locNode); if (index == -1) { //Somehow the cue relationship has been broken!? //Rebuild it! memoryGraph.AddDirectedEdge(retainedMemory, locNode, UpdateFrequency, UpdateFrequency); } else { //Strengthing the memory based on the length of time it was active in the working set. retainedMemory.StrengthenMemory(index, UpdateFrequency); //retainedMemory.StrengthenOpinion(index, UpdateFrequency); //We keep opinion strength updating here because it represents how strongly the agent believes the item / character etc. is connected to this location. //Debug.Log(string.Format("Node: {0}, NS: {1}, ES: {2}", locNode.UID, retainedMemory.NodeStrengths[index], retainedMemory.EdgeStrengths[index])); //Debug.Log(string.Format("NS: {0}, ES: {1}", locNode.NodeStrengths[index], cueNode.EdgeStrengths[index])); } }
public MemoryNode(MemoryCue memInfo, MemoryType mt) { MemoryCue = memInfo; UID = memInfo.UniqueNodeID; RelatedCues = memInfo.CueMarkers; MemoryType = mt; }
internal float GetCueOpinion(MemoryCue memCue) { if(memCue.CueMarkers == null) return 0.0f; MemoryGraphNode cueNode = GetNamedNodeFromGraph(memCue.CueMarkers[0]); if (cueNode == null) return 0.0f; for (int j = 0; j < cueNode.Neighbours.Count; j++) if (cueNode.Neighbours[j].UID == memCue.UniqueNodeID) return cueNode.OpinionStrengths[j]; return 0.0f; }
internal void UpdateCueOpinion(MemoryCue memCue, float strengthFactor) { for (int i = 0; i < memCue.CueMarkers.Length; i++) { MemoryGraphNode cueNode = GetNamedNodeFromGraph(memCue.CueMarkers[i]); for (int j = 0; j < cueNode.Neighbours.Count; j++) { if (cueNode.Neighbours[j].UID == memCue.UniqueNodeID) { cueNode.StrengthenOpinion(j, strengthFactor); break; } } } }
internal void UnbindRelatedCues(MemoryCue memCue) { for (int i = 0; i < memCue.CueMarkers.Length; i++) { MemoryGraphNode cueNode; if (Contains(memCue.CueMarkers[i]) == false) cueNode = AddNamedNodeToGraph(new MemoryNode(memCue.CueMarkers[i], MemoryType.Cue)); else cueNode = GetNamedNodeFromGraph(memCue.CueMarkers[i]); for (int j = 0; j < cueNode.Neighbours.Count; j++) { if (cueNode.Neighbours[j].UID == memCue.UniqueNodeID) { cueNode.UnbindMemory(j); //We unbind the memory, and set it to the max value so it can begin to degrade. break; } } } }
internal void BindRelatedCues(MemoryCue memCue) { for (int i = 0; i < memCue.CueMarkers.Length; i++) { MemoryGraphNode cueNode; if (Contains(memCue.CueMarkers[i]) == false) cueNode = AddNamedNodeToGraph(new MemoryNode(memCue.CueMarkers[i], MemoryType.Cue)); else cueNode = GetNamedNodeFromGraph(memCue.CueMarkers[i]); for (int j = 0; j < cueNode.Neighbours.Count; j++) { if(cueNode.Neighbours[j].UID == memCue.UniqueNodeID) { cueNode.BindMemory(j); //We bind the memory as long as we need to, by setting it to 11 it will never degrade. break; } } } }