Esempio n. 1
0
 private Goal FindGoal(List <Goal> items, Goal item)
 {
     return(items.Where(w => w.Negative == item.Negative && w.A == item.A && w.State == item.State && w.ThingB == item.ThingB).FirstOrDefault());
 }
Esempio n. 2
0
        /// <summary>
        /// 告诉对象的位置(如果信息在故事中并且是诚实的)
        /// 如果没有有关该对象的信息,则演员位于并设置一个随机位置
        /// </summary>
        public void DeltaTell()
        {
            if (MainActor.InMemoryGoal.Count == 0)
            {
                return;
            }

            var newGoal = MainActor.InMemoryGoal[0];

            if (FindGoal(InMemory, newGoal) == null)
            {
                logger.Debug($"DeltaTell");
                logger.Information(newGoal.ToString());

                var effect = DeepCopy(MainActor.InMemoryGoal[0]);
                effect.Negative = true;

                var answer1 = new Goal {
                    A = StoryCharactersList[1].Name, State = "告诉信息", ThingB = MainActor.Name
                };
                var answer2 = new Goal {
                    A = MainActor.Name, State = "知道", ThingB = newGoal.ThingB
                };
                var objectLocation = "";

                if (StoryCharactersList[1].Honest)
                {
                    objectLocation = SearchObject(InMemory, newGoal.ThingB);
                    if (!string.IsNullOrEmpty(objectLocation))
                    {
                        var scapeIndex = RandomUtil.Next(0, Locations.Count - 1);
                        objectLocation = Locations[scapeIndex];
                        StoryCharactersList[1].Honest = false;
                        var answer3 = new Goal {
                            A = newGoal.ThingB, State = "在", ThingB = objectLocation
                        };
                        var answer4 = new Goal {
                            A = StoryCharactersList[1].Name, State = "说谎", ThingB = MainActor.Name
                        };
                        var consequence = new List <Goal> {
                            answer1, answer2, answer3, answer4
                        };
                        AssertionMechanism(consequence, effect);
                    }
                    else
                    {
                        var answer3 = new Goal {
                            A = newGoal.ThingB, State = "在", ThingB = objectLocation
                        };
                        var consequence = new List <Goal> {
                            answer1, answer2, answer3
                        };
                        AssertionMechanism(consequence, effect);
                    }
                }
                else if (!StoryCharactersList[1].Honest)
                {
                    var scapeIndex = RandomUtil.Next(0, Locations.Count - 1);
                    objectLocation = Locations[scapeIndex];
                    StoryCharactersList[1].Honest = false;
                    var answer3 = new Goal {
                        A = newGoal.ThingB, State = "在", ThingB = objectLocation
                    };
                    var answer4 = new Goal {
                        A = StoryCharactersList[1].Name, State = "说谎", ThingB = MainActor.Name
                    };
                    var consequence = new List <Goal> {
                        answer1, answer2, answer3, answer4
                    };
                    AssertionMechanism(consequence, effect);
                }
                else
                {
                    var consequence = new List <Goal> {
                        answer1, answer2
                    };
                    AssertionMechanism(consequence, effect);
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 饥饿
        /// 为了满足饥饿感,您可以看到食物,然后把食物上吃掉。
        /// 前提条件:角色所在的地方有食物例如,熊可以在洞穴里看到食物,他没有身体可以吃
        /// 后置条件:
        /// 功效:演员吃东西,演员不饿
        /// </summary>
        public void SigmaHunger()
        {
            if (MainActor.InMemoryGoal.Count == 0)
            {
                return;
            }

            var newGoal       = MainActor.InMemoryGoal[0];
            var precondition1 = new Goal {
                A = MainActor.Food, State = "在", ThingB = MainActor.Location
            };
            var precondition2 = new Goal {
                A = MainActor.Name, State = "知道", ThingB = newGoal.ThingB
            };
            var precondition3 = new Goal {
                A = StoryCharactersList[1].Name, State = "说谎", ThingB = MainActor.Name
            };

            logger.Debug($"饥饿!!!!!{MainActor.InMemoryGoal.Count}");
            logger.Debug(MainActor.Location);

            var effect = DeepCopy(MainActor.InMemoryGoal[0]);

            effect.Negative = true;
            if (FindGoal(InMemory, precondition1) != null)
            {
                if (FindGoal(InMemory, precondition3) != null)
                {
                    var consequence = new List <Goal> {
                        new Goal {
                            A = MainActor.Name, State = "知道食物的位置", ThingB = MainActor.Food
                        },
                        new Goal {
                            A = MainActor.Name, State = "吃", ThingB = MainActor.Food
                        },
                        effect
                    };
                    AssertionMechanism(consequence, effect);
                }
                else
                {
                    var consequence = new List <Goal> {
                        new Goal {
                            A = MainActor.Name, State = "说谎"
                        },
                        new Goal {
                            A = "目标未实现"
                        }
                    };
                    AssertionMechanism(consequence, null);
                }
            }
            else if (FindGoal(InMemory, precondition2) != null)
            {
                var location       = SearchObject(InMemory, newGoal.ThingB);
                var moveToLocation = new Goal {
                    A = MainActor.Name, State = "想成为", ThingB = location
                };
                MainActor.InMemoryGoal.Insert(0, moveToLocation);
            }
            else
            {
                var goal = new Goal {
                    A = MainActor.Name, State = "想知道", ThingB = MainActor.Food
                };
                MainActor.InMemoryGoal.Insert(0, goal);
                logger.Debug("alternate");
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 根据特征验证其他参与者是否会与信息合作
        /// </summary>
        public void DeltaAsk()
        {
            if (MainActor.InMemoryGoal.Count == 0)
            {
                return;
            }

            var newGoal = MainActor.InMemoryGoal[0];

            if (FindGoal(InMemory, newGoal) == null)
            {
                logger.Debug($"Delta Ask");
                logger.Information(newGoal.ToString());

                var effect = DeepCopy(MainActor.InMemoryGoal[0]);
                effect.Negative = true;

                var      noMorePersecution = false;
                var      a  = MainActor.SocialRelation;
                var      b  = StoryCharactersList[1].SocialRelation;
                var      c  = MainActor.CurrentFeelingState;
                string[] s1 = { "furious", "physco", "deppresive" };
                string[] s2 = { "depressive", "sick" };
                string[] s3 = { "furious", "physco", "depressive", "sick" };

                if (a == "好" && b == "好" && !s1.Contains(c))
                {
                    logger.Debug("Delta Ask1");

                    var answer = new Goal {
                        A = MainActor.Name, State = "是的朋友", ThingB = StoryCharactersList[1].Name
                    };
                    var tellInformation = new Goal {
                        A = StoryCharactersList[1].Name, State = "告诉", ThingB = newGoal.ThingB
                    };
                    MainActor.InMemoryGoal.Insert(0, tellInformation);
                    var consequence = new List <Goal> {
                        answer
                    };
                    AssertionMechanism(consequence, effect);
                }
                else if (a == "好" && s1.Contains(c))
                {
                    logger.Debug("Delta Ask2");

                    var answer = new Goal {
                        A = StoryCharactersList[1].Name, State = "感到抱歉", ThingB = MainActor.Name
                    };
                    var tellInformation = new Goal {
                        A = StoryCharactersList[1].Name, State = "告诉", ThingB = newGoal.ThingB
                    };
                    MainActor.InMemoryGoal.Insert(0, tellInformation);
                    var consequence = new List <Goal> {
                        answer
                    };
                    AssertionMechanism(consequence, effect);
                    noMorePersecution = true;
                }
                else if (b == "坏" && !noMorePersecution)
                {
                    logger.Debug("Delta Ask3");
                    var scapeIndex = RandomUtil.Next(0, Locations.Count - 1);
                    var scape      = Locations[scapeIndex];
                    StoryCharactersList[1].Location = scape;
                    var currentFeelingStateIndex = RandomUtil.Next(0, s3.Length - 1);
                    var currentFeelingState      = s3[currentFeelingStateIndex];
                    MainActor.CurrentFeelingState = currentFeelingState;

                    var answer1 = new Goal {
                        A = StoryCharactersList[1].Name, State = "离家出走", ThingB = StoryCharactersList[1].Location
                    };
                    var answer2 = new Goal {
                        A = MainActor.Name, State = "感觉", ThingB = MainActor.CurrentFeelingState
                    };
                    var tellInformation = new Goal {
                        A = MainActor.Name, State = "想成为", ThingB = StoryCharactersList[1].Location
                    };
                    MainActor.InMemoryGoal.Insert(0, tellInformation);
                    var consequence = new List <Goal> {
                        answer1, answer2
                    };
                    AssertionMechanism(consequence, null);
                }
                else
                {
                    MainActor.SocialRelation = "好";
                    var consequence = new List <Goal> {
                        new Goal {
                            A = MainActor.Name, State = "送礼物", ThingB = StoryCharactersList[1].Name
                        },
                        new Goal {
                            A = MainActor.Name, State = "离家出走", ThingB = StoryCharactersList[1].Name
                        },
                    };
                    AssertionMechanism(consequence, null);
                }
            }
        }
Esempio n. 5
0
        public Actor(string name, string socialRelation, string currentFeelingState, Thing food, Thing location, Goal goal, bool honest)
        {
            Name                = name;
            SocialRelation      = socialRelation;
            CurrentFeelingState = currentFeelingState;
            Food                = food;
            Location            = location;
            Goal                = goal;
            InMemoryGoal.Add(goal);
            Honest = honest;

            logger.Debug($"{name}-{socialRelation}-{currentFeelingState}-{food.Name}-{location.Name}-{goal}");
        }