コード例 #1
0
        public void LogicalInferenceStart(Frame userFrame)
        {
            List <Frame> frames = new List <Frame>();

            frames.AddRange((from frame in knowledgeBase.Frames select frame).ToList());

            for (int i = 0; i < frames.Count; i++)
            {
                for (int j = 0; j < userFrame.Slots.Count; j++)
                {
                    if (frames[i].Name == userFrame.Slots[j].Value)
                    {
                        userFrame.Parent = frames[i];
                        break;
                    }
                }
            }

            while (userFrame.Parent != null)
            {
                if (userFrame.Slots.Count == userFrame.Parent.Slots.Count)
                {
                    for (int i = 0; i < userFrame.Slots.Count; i++)
                    {
                        if (userFrame.Slots[i].Value == "" && userFrame.Parent.Slots[i].Value != "")
                        {
                            userFrame.Slots[i].Value = userFrame.Parent.Slots[i].Value;

                            Explanation(userFrame.Slots[i], userFrame.Parent);

                            if (userFrame.Parent.Slots[i].Demon != "")
                            {
                                userFrame.Slots[i].Demon = userFrame.Parent.Slots[i].Demon;
                            }
                        }
                        else
                        {
                            continue;
                        }
                    }
                }

                userFrame.Parent = userFrame.Parent.Parent;
            }

            foreach (Slot slot in userFrame.Slots)
            {
                if (slot.Demon != "")
                {
                    slot.Value = AttachedProcedureExecute(userFrame, AttachedProcedure.ProcedureParse(slot.Value));
                }
            }

            ReturnFrameIntoView(userFrame);
        }
コード例 #2
0
        private string AttachedProcedureExecute(Frame userFrame, string[] names)
        {
            bool   sale  = false;
            string value = "";

            foreach (Slot slot in userFrame.Slots)
            {
                if (slot.Name == "Акции VR-клуба")
                {
                    if (slot.Value == "Да")
                    {
                        sale = true;
                    }
                    else
                    {
                        sale = false;
                    }
                }
            }

            foreach (Slot slot in userFrame.Slots)
            {
                if (slot.Name == names[1])
                {
                    value = slot.Value;
                    break;
                }
            }

            if (names[0] == "get_price")
            {
                return(AttachedProcedure.GetPrice(value, sale));
            }

            if (names[0] == "get_time")
            {
                return(AttachedProcedure.GetTime(value));
            }

            if (names[0] == "get_sale")
            {
                return(AttachedProcedure.GetSale(value));
            }

            return(null);
        }