Пример #1
0
        public static void PopulateGroundActions(Domain domain, Problem problem)
        {
            GroundActions = new List <IOperator>();
            GroundLibrary = new Dictionary <int, IOperator>();
            TypeDict      = new Dictionary <string, List <string> >();
            var ops              = domain.Operators;
            var objectHierarchy  = EnumerableExtension.HashtableToDictionary <string, List <string> >(domain.objectTypes);
            var typeToObjectDict = EnumerableExtension.HashtableToDictionary <string, List <string> >(problem.ObjectsByType);

            foreach (var keyvalue in typeToObjectDict)
            {
                TypeDict[keyvalue.Key] = keyvalue.Value;
            }
            // Foreach object key that isn't a typedict key
            var excludedObjectKeys = objectHierarchy.Keys.Where(okey => !typeToObjectDict.ContainsKey(okey));

            foreach (var okey in excludedObjectKeys)
            {
                var newValues = typeToObjectDict.Keys.Where(tkey => objectHierarchy[okey].Contains(tkey)).Select(tkey => typeToObjectDict[tkey]);
                TypeDict[okey] = newValues.SelectMany(x => x).ToList();
            }


            FromOperators(ops);
        }