Esempio n. 1
0
        public void Tell(Name property, Name value, Name perspective, float certainty)
		{
			if (property.IsPrimitive)
				throw new ArgumentException("The given property name cannot be a primitive value.",nameof(property));

			if (!property.IsConstant)
				throw new ArgumentException("The given property name is not constant. Only constant names can be stored",nameof(property));

			var ToMList = AssertPerspective(perspective, nameof(perspective));
			property = RemovePropertyPerspective(property, ToMList);

			//ToM property shift
			property = ExtractPropertyFromToM(property, ToMList, nameof(property));

			if (_registry.WillEvaluate(property))
				throw new ArgumentException("The given name will be obfuscated by a dynamic property", nameof(property));

			var mind_key = ToMList2Key(ToMList);

			var fact = property.ApplyToTerms(p => ApplyDynamic(p,mind_key));

			KnowledgeEntry entry;
			if (!m_knowledgeStorage.TryGetValue(fact, out entry))
			{
				entry = new KnowledgeEntry();
				m_knowledgeStorage[fact] = entry;
			}

			entry.TellValueFor(mind_key,value,certainty);
			if (entry.IsEmpty())
				m_knowledgeStorage.Remove(fact);
		}
Esempio n. 2
0
        public void AddKnowledgeItem(AddKnoledgeItemModel model)
        {
            var entry = new KnowledgeEntry
            {
                Content   = model.Content,
                Date      = DateTime.Now,
                User      = "******",
                Link      = ToLink(model.Link),
                Documents = ToDocuments(model.Documents)
            };

            _dbContext.KnoledgeEntries.Add(entry);
            _dbContext.SaveChanges();
        }
Esempio n. 3
0
        public void Tell(Name property, PrimitiveValue value, Name perspective)
        {
            if (property.IsPrimitive)
            {
                throw new ArgumentException("The given property name cannot be a primitive value.", nameof(property));
            }

            if (!property.IsConstant)
            {
                throw new ArgumentException("The given property name is not constant. Only constant names can be stored", nameof(property));
            }

            perspective = perspective.ApplyPerspective(Perspective);
            var ToMList = AssertPerspective(perspective, nameof(perspective));

            property = RemovePropertyPerspective(property, ToMList);

            //ToM property shift
            property = ExtractPropertyFromToM(property, ToMList, nameof(property));

            if (m_dynamicProperties.Unify(property).Any())
            {
                throw new ArgumentException("The given name will be objuscated by a dynamic property", nameof(property));
            }

            var fact = property.ApplyToTerms(p => SimplifyProperty(p, ToMList));

            KnowledgeEntry entry;

            if (!m_knowledgeStorage.TryGetValue(fact, out entry))
            {
                entry = new KnowledgeEntry();
                m_knowledgeStorage[fact] = entry;
            }

            var mind_key = ToMList2Key(ToMList);

            entry.TellValueFor(mind_key, value);
            if (entry.IsEmpty())
            {
                m_knowledgeStorage.Remove(fact);
            }
        }
Esempio n. 4
0
        public void Tell(Name property, Name value, Name perspective)
        {
            if (property.IsPrimitive)
                throw new ArgumentException("The given property name cannot be a primitive value.",nameof(property));

            if (!property.IsConstant)
                throw new ArgumentException("The given property name is not constant. Only constant names can be stored",nameof(property));

            var ToMList = AssertPerspective(perspective, nameof(perspective));
            property = RemovePropertyPerspective(property, ToMList);

            //ToM property shift
            property = ExtractPropertyFromToM(property, ToMList, nameof(property));

            if (m_dynamicProperties.Unify(property).Any())
                throw new ArgumentException("The given name will be objuscated by a dynamic property", nameof(property));

            var fact = property.ApplyToTerms(p => SimplifyProperty(p, ToMList));

            KnowledgeEntry entry;
            if (!m_knowledgeStorage.TryGetValue(fact, out entry))
            {
                entry = new KnowledgeEntry();
                m_knowledgeStorage[fact] = entry;
            }

            var mind_key = ToMList2Key(ToMList);
            entry.TellValueFor(mind_key,value);
            if (entry.IsEmpty())
                m_knowledgeStorage.Remove(fact);
        }
Esempio n. 5
0
        private static BasicResource CreateResource(int index)
        {
            WarResource resource = rawResources[index];

            KnowledgeEntry ke = KnowledgeBase[index];

            ContentFileType fileType = ContentFileType.FileUnknown;

            if (ke != null)
            {
                fileType = ke.type;
            }

            switch (fileType)
            {
            case ContentFileType.FileCursor:
            {
                WarResource palRes = null;
                if (ke != null)
                {
                    palRes = rawResources[ke.param];
                }

                return(new CursorResource(resource, palRes));
            }

            case ContentFileType.FileImage:
            {
                WarResource palRes = null;
                if (ke != null)
                {
                    palRes = rawResources[ke.param];
                }

                return(new ImageResource(resource, palRes, rawResources[191]));
            }

            case ContentFileType.FileLevelInfo:
                return(new LevelInfoResource(resource));

            case ContentFileType.FileLevelPassable:
                return(new LevelPassableResource(resource));

            case ContentFileType.FileLevelVisual:
                return(new LevelVisualResource(resource));

            case ContentFileType.FilePalette:
                return(new PaletteResource(resource));

            case ContentFileType.FilePaletteShort:
                return(new PaletteResource(resource));

            case ContentFileType.FileSprite:
            {
                WarResource palRes = null;
                if (ke != null)
                {
                    palRes = rawResources[ke.param];
                }

                return(new SpriteResource(resource, palRes, rawResources[191]));
            }

            case ContentFileType.FileTable:
                return(new TableResource(resource));

            case ContentFileType.FileText:
                return(new TextResource(resource));

            case ContentFileType.FileTiles:
                return(new RawResource(resource, ContentFileType.FileTiles));

            case ContentFileType.FileTileSet:
                return(new RawResource(resource, ContentFileType.FileTileSet));

            case ContentFileType.FileUI:
                return(new UIResource(resource));

            case ContentFileType.FileVOC:
                return(new RawResource(resource, ContentFileType.FileVOC));

            case ContentFileType.FileWave:
                return(new RawResource(resource, ContentFileType.FileWave));

            case ContentFileType.FileXMID:
                return(new RawResource(resource, ContentFileType.FileXMID));

            default:
                return(new RawResource(resource, ContentFileType.FileUnknown));
            }
        }