Beispiel #1
0
        public IntPtr ScanForPatternInRegion(MemoryRegion region, MemoryPattern pattern)
        {
            var endAddr     = (int)region.RegionSize - pattern.Size;
            var wholeMemory = ReadMemory(region.BaseAddress, (int)region.RegionSize);

            for (var addr = 0; addr < endAddr; addr++)
            {
                var buff = new byte[pattern.Size];
                Array.Copy(wholeMemory, addr, buff, 0, buff.Length);

                var found = true;

                for (var i = 0; i < pattern.Size; i++)
                {
                    if (!pattern.PatternParts[i].Matches(buff[i]))
                    {
                        found = false;
                        break;
                    }
                }

                if (!found)
                {
                    continue;
                }

                return(region.BaseAddress + addr);
            }

            return(IntPtr.Zero);
        }
    public void Evaluate(MemoryManager memoryManager, ActionQueue actionQueue)
    {
        SetScore(0.0f);

        //Heuristic 1 - get length
        int numberOfActions = actions.Count;

        AddToScore((-0.05f) * numberOfActions);

        //Heuristic 2 - check similar memories
        foreach (Action action in actions)
        {
            MemoryPattern memory = memoryManager.RetrieveSentMemoryPattern(action.Name);
            if (memory != null)
            {
                AddToScore(memory.Desirability);
            }
        }

        //Heuristic 3 - forecast result on emotions
        foreach (Action action in actions)
        {
            AddToScore(SelfStatEffectDesirability(action));
            AddToScore(TargetStatEffectDesirability(action));
            int repeatCount = memoryManager.senderPool.CountMemoryPatternsFromActionName(action.Name);
            if (repeatCount > 0)
            {
                AddToScore(repeatCount * -0.5f);
            }
        }
    }
Beispiel #3
0
    private MemoryPattern RetrieveMemoryPattern(MemoryPool pool, int id)
    {
        MemoryPattern memory = pool.RetrieveMemoryPattern(id);

        if (memory != null)
        {
            Testing.WriteToLog(transform.name, "Retrieved memory: " + Testing.GetMemoryInfo(memory));
        }
        return(memory);
    }
Beispiel #4
0
 public void AddMemoryPattern(MemoryPattern mp)
 {
     memories.Add(mp);
     foreach (string keyword in mp.Keywords)
     {
         AddMemoryNode(keyword);
     }
     foreach (string keyword in mp.Keywords)
     {
         List <string> keywords = new List <string>(mp.Keywords);
         keywords.Remove(keyword);
         AddConnections(keyword, keywords);
     }
 }
    public static string GetMemoryInfo(MemoryPattern mp)
    {
        string keywords = "";

        for (int i = 0; i < mp.Keywords.Length; i++)
        {
            keywords += mp.Keywords[i];
            if (i != mp.Keywords.Length - 1)
            {
                keywords += ", ";
            }
        }
        return("Memory(keywords = " + keywords + ")");
    }
Beispiel #6
0
        public IntPtr PatternScan(MemoryPattern pattern)
        {
            var regions = QueryMemoryRegions();

            foreach (var memoryRegion in regions)
            {
                var addr = ScanForPatternInRegion(memoryRegion, pattern);

                if (addr == IntPtr.Zero)
                {
                    continue;
                }

                return(addr);
            }

            return(IntPtr.Zero);
        }
Beispiel #7
0
 private void AddMemoryPattern(MemoryPool pool, MemoryPattern mp)
 {
     pool.AddMemoryPattern(mp);
     currentID++;
 }
Beispiel #8
0
 public void AddSentMemoryPattern(MemoryPattern mp)
 {
     AddMemoryPattern(senderPool, mp);
 }
Beispiel #9
0
 public void AddReceivedMemoryPattern(MemoryPattern mp)
 {
     AddMemoryPattern(receiverPool, mp);
 }
Beispiel #10
0
 public MatchCollection Matches(MemoryPattern Pattern) => Pattern.Matches(StringDump);
Beispiel #11
0
 public Match Match(MemoryPattern Pattern) => Pattern.Match(StringDump);
Beispiel #12
0
 public MatchCollection Matches(MemoryPattern Pattern)
 {
     return(Pattern.Matches(StringDump));
 }
Beispiel #13
0
 public Match Match(MemoryPattern Pattern)
 {
     return(Pattern.Match(StringDump));
 }