public void InteractWithMe_NoReaderOrBuilder_ForgettingSomethingReaction() { // ReSharper disable once InconsistentNaming var Sterling = new Person("Sterling Archer", Gender.Male, Sex.Male, Orientation.Straight, Guid.NewGuid()) { DateOfBirth = new StandardDateTime(DateTime.Now.AddYears(-33)) }; var testCharacter = new global::RNPC.Core.Character(Sterling, Archetype.None); VerifyTestFilesAndDirectory(testCharacter.MyName); var insult = new Action { EventType = EventType.Interaction, ActionType = ActionType.Verbal, Intent = Intent.Hostile, Message = "Hey Swirling! You suck!", Target = "Sterling Archer", EventName = "Insult", Source = "Unknown" }; var reaction = testCharacter.InteractWithMe(insult); Assert.IsNotNull(reaction); Assert.IsTrue(reaction[0].Message.Contains("It feels like I'm forgetting something")); Assert.AreEqual(reaction[0].InitialEvent, insult); }
/// <summary> /// Generates a number of characters of an archetype type for statistical models /// </summary> /// <param name="archetype">Archetype name</param> /// <param name="sampling"></param> private void CharacterGenerationByArchetype(Archetype archetype, int sampling) { //ARRANGE var strongPointStats = new List <int> { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; var weakPointStats = new List <int> { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; int numberOfOutliers = 0; //ACT for (int i = 0; i < sampling; i++) { Person newPerson = new Person("Character" + i, Guid.NewGuid()); var character = new global::RNPC.Core.Character(newPerson, archetype) { FileController = new DecisionTreeFileController(), DecisionTreeBuilder = new DecisionTreeBuilder() }; int numberOfStrongPoints = CalculateNbOfStrongPoints(character.MyTraits); int numberOfWeakPoints = CalculateNbOfWeakPoints(character.MyTraits); if (numberOfStrongPoints > 14) { numberOfOutliers++; } else { strongPointStats[numberOfStrongPoints]++; } if (numberOfWeakPoints > 14) { numberOfOutliers++; } else { weakPointStats[numberOfWeakPoints]++; } } //DISPLAY for (int i = 0; i < strongPointStats.Count; i++) { //double strongPercentage = strongPointStats[i] / (double)SAMPLING * 100; //Debug.WriteLine("Traits generated with {0} strong points: {1} -- percentage {2}%", i, strongPointStats[i], strongPercentage); //double weakPercentage = weakPointStats[i] / (double)SAMPLING * 100; //Debug.WriteLine("Traits generated with {0} weak points: {1} -- percentage {2}%", i, weakPointStats[i], weakPercentage); Debug.WriteLine("{0}, {1}, {2}", i, strongPointStats[i], weakPointStats[i]); } double outlierPercentage = numberOfOutliers / (double)sampling * 100; Debug.WriteLine("I have generated {0}% outliers", outlierPercentage); Assert.IsTrue(outlierPercentage < 0.5); }
public void KnowledgeTest_OccupationAndRelationship_AnswerReturned() { //Who was married to Queen Meve? //The King of Temeria //ARRANGE var knowledge = MemoryContentInitializer.CreateItemsAndLinkThem(new ItemLinkFactory()); var guineaPig = new Person("Guinea Pig", Gender.Male, Sex.Male, Orientation.Straight, Guid.NewGuid()); var testCharacter = new global::RNPC.Core.Character(guineaPig, Archetype.None, knowledge) { FileController = new DecisionTreeFileController(), DecisionTreeBuilder = new DecisionTreeBuilder(), KnowledgeRandomizer = new TestKnowledgeRandomization() }; testCharacter.AddContentToLongTermMemory(knowledge); //ACT var meve = testCharacter.MyMemory.Persons.FindPersonByName("Meve"); //ASSERT Assert.IsNotNull(meve); var husband = meve.FindRelationshipsByType(PersonalRelationshipType.Family).FirstOrDefault(r => r.Description == "wife-of")?.RelatedPerson; Assert.IsNotNull(husband); var occupation = husband.GetCurrentOccupation(); Assert.IsNotNull(occupation); Assert.AreEqual("King of Temeria", occupation.Name); }
public void KnowledgeTest_OccupationAndOrigin_AnswerReturned() { //Where do Vikings come from? //from Skellige //ARRANGE var knowledge = MemoryContentInitializer.CreateItemsAndLinkThem(new ItemLinkFactory()); var guineaPig = new Person("Guinea Pig", Gender.Male, Sex.Male, Orientation.Straight, Guid.NewGuid()); var testCharacter = new global::RNPC.Core.Character(guineaPig, Archetype.None, knowledge) { FileController = new DecisionTreeFileController(), DecisionTreeBuilder = new DecisionTreeBuilder(), KnowledgeRandomizer = new TestKnowledgeRandomization() }; testCharacter.AddContentToLongTermMemory(knowledge); //ACT var vikings = testCharacter.MyMemory.Occupations.FindOccupationByName("Vikings"); //ASSERT Assert.IsNotNull(vikings); Place vikingOrigin = vikings.FindLinkedPlaceByType(OccupationalTieType.OriginatedFrom); Assert.IsNotNull(vikingOrigin); Assert.IsTrue(vikingOrigin.Name.Contains("Skellige")); }
public void KnowledgeTest_RilbertsTrade_AnswerReturned() { //What is Ribert's trade? //Rilbert is a Mason //ARRANGE var knowledge = new List <MemoryItem>(); knowledge.AddRange(MemoryContentInitializer.CreatePersonsAndOccupationsForTest(new ItemLinkFactory())); var guineaPig = new Person("Guinea Pig", Gender.Male, Sex.Male, Orientation.Straight, Guid.NewGuid()); var testCharacter = new global::RNPC.Core.Character(guineaPig, Archetype.None, knowledge) { FileController = new DecisionTreeFileController(), DecisionTreeBuilder = new DecisionTreeBuilder(), KnowledgeRandomizer = new TestKnowledgeRandomization() }; testCharacter.AddContentToLongTermMemory(knowledge); //ACT // ReSharper disable once InconsistentNaming var Rilbert = testCharacter.MyMemory.Persons.FindPersonByName("Rilbert"); //ASSERT Assert.IsNotNull(Rilbert); var occupation = Rilbert.GetCurrentOccupation(); Assert.IsNotNull(occupation); Assert.AreEqual("Mason", occupation.Name); }
public void NotifyAllCharactersInRegion_() { // ReSharper disable once InconsistentNaming var Sterling = new Person("Sterling Archer", Gender.Male, Sex.Male, Orientation.Straight, Guid.NewGuid()); var testCharacter = new global::RNPC.Core.Character(Sterling, Archetype.None) { FileController = new DecisionTreeFileController(), DecisionTreeBuilder = new DecisionTreeBuilder(), MyMemory = new Memory(Sterling) }; testCharacter.CharacterReacted += TestCharacter_CharacterReacted; Cronos.Instance.AddFollower(testCharacter); Action tornado = new Action { EventType = EventType.Weather, Target = "None", EventName = "Tornado", Source = "Unknown" }; Cronos.Instance.NotifyAllCharactersInRegion(tornado, new Coordinates(), 500); }
public void KnowledgeTest_AnyasBirthplace_AnswerReturned() { //Where was Anya born? //Anya was born in Rivia //ARRANGE var knowledge = new List <MemoryItem>(); knowledge.AddRange(MemoryContentInitializer.CreatePersonsAndOccupationsForTest(new ItemLinkFactory())); var guineaPig = new Person("Guinea Pig", Gender.Male, Sex.Male, Orientation.Straight, Guid.NewGuid()); var testCharacter = new global::RNPC.Core.Character(guineaPig, Archetype.None, knowledge) { FileController = new DecisionTreeFileController(), DecisionTreeBuilder = new DecisionTreeBuilder(), KnowledgeRandomizer = new TestKnowledgeRandomization() }; testCharacter.AddContentToLongTermMemory(knowledge); //ACT // ReSharper disable once InconsistentNaming var Anya = testCharacter.MyMemory.Persons.FindPersonByName("Anya"); //ASSERT Assert.IsNotNull(Anya); // ReSharper disable once InconsistentNaming var Rivia = Anya.FindPlaceByPersonalTieType(PersonalTieType.BornIn); Assert.IsNotNull(Rivia); Assert.AreEqual("Rivia", Rivia.Name); }
public void KnowledgeTest_ConquestOfRedania_AnswerReturned() { //Who conquered Redania? //The Emperor of Nilfgaard conquered Redania //ARRANGE var knowledge = MemoryContentInitializer.CreateItemsAndLinkThem(new ItemLinkFactory()); var guineaPig = new Person("Guinea Pig", Gender.Male, Sex.Male, Orientation.Straight, Guid.NewGuid()); var testCharacter = new global::RNPC.Core.Character(guineaPig, Archetype.None, knowledge) { FileController = new DecisionTreeFileController(), DecisionTreeBuilder = new DecisionTreeBuilder(), KnowledgeRandomizer = new TestKnowledgeRandomization() }; testCharacter.AddContentToLongTermMemory(knowledge); //ACT // ReSharper disable once InconsistentNaming var Redania = testCharacter.MyMemory.Places.FindPlaceByName("Redania"); //ASSERT Assert.IsNotNull(Redania); var theConquest = Redania.FindLinkedEventByType(OccurenceType.Conquest); Assert.IsNotNull(theConquest); var leader = theConquest.FindOccupationsByInvolvementType(OccupationalInvolvementType.Led); Assert.IsNotNull(leader); Assert.IsTrue(leader.Count == 1); Assert.AreEqual("Imperator", leader[0].Name); Debug.Write($"The {leader[0].Name} of the {leader[0].FindLinkedPlaceByType(OccupationalTieType.Led)} led the {theConquest.Name}"); }
public void KnowledgeTest_TheNorthernWars_AnswerReturned() { //What battle did Geralt fight in? //Geralt fought in the battle against Nilfgaard //ARRANGE var knowledge = MemoryContentInitializer.CreateItemsAndLinkThem(new ItemLinkFactory()); var guineaPig = new Person("Guinea Pig", Gender.Male, Sex.Male, Orientation.Straight, Guid.NewGuid()); var testCharacter = new global::RNPC.Core.Character(guineaPig, Archetype.None, knowledge) { FileController = new DecisionTreeFileController(), DecisionTreeBuilder = new DecisionTreeBuilder(), KnowledgeRandomizer = new TestKnowledgeRandomization() }; testCharacter.AddContentToLongTermMemory(knowledge); //ACT // ReSharper disable once InconsistentNaming var Geralt = testCharacter.MyMemory.Persons.FindPersonByName("Geralt"); //ASSERT Assert.IsNotNull(Geralt); var eventsInvolved = Geralt.FindLinkedEventsByInvolvementType(PersonalInvolvementType.FoughtIn); Assert.IsNotNull(eventsInvolved); Assert.IsTrue(eventsInvolved.Count != 0); Assert.AreEqual("The Northern Wars", eventsInvolved[0].Name); }
public void KnowledgeTest_TheConjunction_AnswerReturned() { //Where was the Conjunction of the Spheres? //The Continent saw the Conjunction of the Spheres //ARRANGE var knowledge = MemoryContentInitializer.CreateItemsAndLinkThem(new ItemLinkFactory()); var guineaPig = new Person("Guinea Pig", Gender.Male, Sex.Male, Orientation.Straight, Guid.NewGuid()); var testCharacter = new global::RNPC.Core.Character(guineaPig, Archetype.None, knowledge) { FileController = new DecisionTreeFileController(), DecisionTreeBuilder = new DecisionTreeBuilder(), KnowledgeRandomizer = new TestKnowledgeRandomization() }; testCharacter.AddContentToLongTermMemory(knowledge); //ACT var theConjuction = testCharacter.MyMemory.Events.FindEventByName("Conjunction"); //ASSERT Assert.IsNotNull(theConjuction); var continent = theConjuction.FindLinkedPlaceByOccurenceType(OccurenceType.HappenedIn); Assert.IsNotNull(continent); Assert.AreEqual("The Continent", continent.Name); }
public void New_InstantiateWithNoName_ArgumentNullExceptionRaised() { // ReSharper disable once UnusedVariable var character = new global::RNPC.Core.Character(new Person("", Guid.NewGuid()), Archetype.None) { FileController = new DecisionTreeFileController(), DecisionTreeBuilder = new DecisionTreeBuilder() }; }
private static bool RunRemovingValueLearningTest(global::RNPC.Core.Character character, ILearningStrategy learningStrategy) { int nbOfValues = character.MyTraits.PersonalValues.Count; //Act learningStrategy.AnalyzeAndLearn(character); //Assert return(nbOfValues > character.MyTraits.PersonalValues.Count); }
public void New_PersonIsNull_ArgumentNullExceptionRaised() { // ReSharper disable once UnusedVariable var character = new global::RNPC.Core.Character(null, Archetype.None) { FileController = new DecisionTreeFileController(), DecisionTreeBuilder = new DecisionTreeBuilder() }; }
/// <summary> /// Trains a character for one year /// </summary> /// <param name="charactertoTrain"></param> /// <param name="characterArchetype"></param> /// <returns></returns> private static StatisticalResults TrainCharacterFor10Years(global::RNPC.Core.Character charactertoTrain, Archetype characterArchetype) { //ARRANGE var preTrainingQs = charactertoTrain.MyTraits.GetPersonalQualitiesValues(); int numberOfPretrainingValues = charactertoTrain.MyTraits.PersonalValues.Count; Stopwatch timer = new Stopwatch(); timer.Start(); PersonalTrainer trainer = new PersonalTrainer(new ItemLinkFactory()); //ACT trainer.TrainForXNumberOfYears(charactertoTrain, 10); //ASSERT timer.Stop(); int qualitiesModified = 0; int increaseDelta = 0; int decreaseDelta = 0; foreach (var quality in charactertoTrain.MyTraits.GetPersonalQualitiesValues()) { if (quality.Value == preTrainingQs[quality.Key]) { continue; } qualitiesModified++; if (quality.Value > preTrainingQs[quality.Key]) { increaseDelta += quality.Value - preTrainingQs[quality.Key]; } else { decreaseDelta = preTrainingQs[quality.Key] - quality.Value; } } StatisticalResults results = new StatisticalResults { Archetype = characterArchetype.ToString(), YearsofTraining = 10, TrainingTime = timer.ElapsedMilliseconds / 1000, ValuesAdded = charactertoTrain.MyTraits.PersonalValues.Count - numberOfPretrainingValues, QualitiesModified = qualitiesModified, QualityIncrease = increaseDelta, QualityDecrease = decreaseDelta, DecisionTreesModified = GetNumberOfRecentlyChangedDecisionTrees(charactertoTrain.MyName) }; return(results); }
public void AnalyzeAndLearn_TestDecisionTreeEvolutions_DecisionTreeChanged() { //ARRANGE //"C:\\Sysdev\\RNPC\\RNPC\\DTO\\Learning\\Resources\\DecisionTreeSubstitutions.xml"; var controller = new SubstitutionController(new SubstitutionDocumentConverter(), new DecisionTreeFileController(), new SubstitutionMapper()); MainDecisionTreeLearningStrategy strategy = new MainDecisionTreeLearningStrategy(controller, new DecisionTreeBuilder()); var Morty = new Person("Morty", Gender.Male, Sex.Male, Orientation.Undefined, Guid.NewGuid()); var character = new global::RNPC.Core.Character(Morty, Archetype.TheInnocent) { FileController = new DecisionTreeFileController(), DecisionTreeBuilder = new DecisionTreeBuilder() }; //Initial Action //Friendly Greeting Action greeting = new Action { EventType = EventType.Interaction, ActionType = ActionType.Verbal, Intent = Intent.Friendly, Message = "Hi!", Target = character.MyName, EventName = "Greeting", Source = "The Friend" }; var reaction = new Reaction { Tone = Tone.Neutral, Target = greeting.Source, Intent = Intent.Neutral, ActionType = ActionType.Verbal, InitialEvent = greeting, EventType = EventType.Interaction, ReactionScore = 0, EventName = "Greeting", Message = "Hello.", //TODO: Randomize Source = greeting.Target }; character.MyMemory.AddActionToLongTermMemory(reaction); character.MyMemory.AddActionToLongTermMemory(reaction); character.MyMemory.AddActionToLongTermMemory(reaction); //ACT strategy.AnalyzeAndLearn(character); //ASSERT }
/// <summary> /// Returns a test character - bugs bunny /// </summary> /// <returns></returns> private global::RNPC.Core.Character CreateTestCharacter(List <MemoryItem> knowledge) { var bugs = new Person("Bugs Bunny", Gender.Genderfluid, Sex.Undefined, Orientation.Asexual, Guid.NewGuid()); var character = new global::RNPC.Core.Character(bugs, Archetype.None) { FileController = new DecisionTreeFileController(), DecisionTreeBuilder = new DecisionTreeBuilder(), KnowledgeRandomizer = new TestKnowledgeRandomization() }; character.AddContentToLongTermMemory(knowledge); return(character); }
private static bool RunDecreaseQualityLearningTest(global::RNPC.Core.Character character, MainQualityLearningStrategy learningStrategy, int quality, string qualityName) { //Act learningStrategy.AnalyzeAndLearn(character); Type type = character.MyTraits.GetType(); PropertyInfo info = type.GetProperty(qualityName); if (info == null) { return(false); } int newValue = (int)info.GetValue(character.MyTraits); //Assert return(quality > newValue); }
public void KnowledgeTest_SavingTheKing_AnswerReturned() { //Who saved the king and where? //A mason saved the king from death in Kaedwen //ARRANGE var knowledge = new List <MemoryItem>(); knowledge.AddRange(MemoryContentInitializer.CreateOccupationsAndEventsForTest(new ItemLinkFactory())); var guineaPig = new Person("Guinea Pig", Gender.Male, Sex.Male, Orientation.Straight, Guid.NewGuid()); var testCharacter = new global::RNPC.Core.Character(guineaPig, Archetype.None, knowledge) { FileController = new DecisionTreeFileController(), DecisionTreeBuilder = new DecisionTreeBuilder(), KnowledgeRandomizer = new TestKnowledgeRandomization() }; testCharacter.AddContentToLongTermMemory(knowledge); //ACT // ReSharper disable once InconsistentNaming var king = testCharacter.MyMemory.Occupations.FindOccupationByName("King"); //ASSERT Assert.IsNotNull(king); var linkedEvents = king.FindLinkedEventsByInvolvementType(OccupationalInvolvementType.WasCaughtIn); Assert.IsNotNull(linkedEvents); Assert.IsTrue(linkedEvents.Count == 1); // ReSharper disable once InconsistentNaming var Kaedwen = linkedEvents[0].FindLinkedPlaceByOccurenceType(OccurenceType.HappenedIn); Assert.IsNotNull(Kaedwen); Assert.AreEqual("Kaedwen", Kaedwen.Name); var linkedOccupation = linkedEvents[0].FindOccupationsByInvolvementType(OccupationalInvolvementType.ParticipatedIn); Assert.IsNotNull(linkedOccupation); Assert.IsTrue(linkedOccupation.Count == 1); Assert.AreEqual("Mason", linkedOccupation[0].Name); }
public void AnalyzeAndLearn_NoLearningDone_NoDecisionTreeChanged() { //ARRANGE //"C:\\Sysdev\\RNPC\\RNPC\\DTO\\Learning\\Resources\\DecisionTreeSubstitutions.xml"; var controller = new SubstitutionController(new SubstitutionDocumentConverter(), new DecisionTreeFileController(), new SubstitutionMapper()); MainDecisionTreeLearningStrategy strategy = new MainDecisionTreeLearningStrategy(controller, new DecisionTreeBuilder()); var Morty = new Person("Morty", Gender.Male, Sex.Male, Orientation.Undefined, Guid.NewGuid()); var character = new global::RNPC.Core.Character(Morty, Archetype.TheInnocent) { FileController = new DecisionTreeFileController(), DecisionTreeBuilder = new DecisionTreeBuilder() }; //ACT strategy.AnalyzeAndLearn(character); //ASSERT Assert.IsFalse(strategy.DecisionTreeEvolved); }
public void AnalyzeAndLearn_ShortTermAngerLowered_LongTermAngerLowered() { //Arrange MainEmotionLearningStrategy strategy = new MainEmotionLearningStrategy(); var Rick = new Person("Rick", Gender.Male, Sex.Male, Orientation.Pansexual, Guid.NewGuid()); var character = new global::RNPC.Core.Character(Rick, Archetype.TheCreator) { FileController = new DecisionTreeFileController(), DecisionTreeBuilder = new DecisionTreeBuilder() }; int initialAnger = character.MyTraits.LongTermEmotions.Anger; character.MyTraits.ShortTermEmotions.Anger = 0; //ACT strategy.AnalyzeAndLearn(character); //Assert Assert.IsTrue(character.MyTraits.LongTermEmotions.Anger < initialAnger); }
public void EvaluateNode_WithNoWealthAsPersonalValue_EvaluationCompleted() { //ARRANGE // ReSharper disable once InconsistentNaming var Jess = new Person("Jessica Day", Gender.Female, Sex.Female, Orientation.Straight, Guid.NewGuid()); var character = new global::RNPC.Core.Character(Jess, Archetype.TheCaregiver) { FileController = new DecisionTreeFileController(), DecisionTreeBuilder = new DecisionTreeBuilder() }; if (character.MyTraits.DoIPossessThisPersonalValue(PersonalValues.Wealth)) { character.MyTraits.PersonalValues.Remove(PersonalValues.Wealth); } AmIAfraidOfAFinancialLoss nodeToTest = new AmIAfraidOfAFinancialLoss { RightNode = new DecisionNodeStub(), LeftNode = new DecisionNodeStub() }; Action threat = new Action { EventType = EventType.Interaction, ActionType = ActionType.Verbal, Intent = Intent.Hostile, Message = "I'll make sure you have to beg for the rest of your life!", Target = character.MyName, EventName = "Threat", Source = "The Enemy" }; //ACT var reaction = nodeToTest.Evaluate(character.MyTraits, character.MyMemory, threat); //ASSERT Assert.IsNotNull(reaction); Assert.AreEqual(threat, reaction[0].InitialEvent); }
public void AnalyzeAndLearn_ShortTermDisappointmentRaised_LongTermDisappointmentRaised() { //Arrange MainEmotionLearningStrategy strategy = new MainEmotionLearningStrategy(); var Rick = new Person("Rick", Gender.Male, Sex.Male, Orientation.Pansexual, Guid.NewGuid()); var character = new global::RNPC.Core.Character(Rick, Archetype.TheCreator) { FileController = new DecisionTreeFileController(), DecisionTreeBuilder = new DecisionTreeBuilder() }; int initialDisappointment = character.MyTraits.LongTermEmotions.Disappointment; character.MyTraits.ShortTermEmotions.Disappointment = 20; //ACT strategy.AnalyzeAndLearn(character); //Assert Assert.IsTrue(character.MyTraits.LongTermEmotions.Disappointment > initialDisappointment); Console.WriteLine(@"New value:" + character.MyTraits.LongTermEmotions.Disappointment); }
public void InteractWithMe_QuestionWhatIsLove_RightTreeLoadedAndQuetion() { //ARRANGE // ReSharper disable once InconsistentNaming var JessicaDay = new Person("Jess", Gender.Female, Sex.Female, Orientation.Straight, Guid.NewGuid()); var character = new global::RNPC.Core.Character(JessicaDay, Archetype.TheCaregiver) { FileController = new DecisionTreeFileController(), DecisionTreeBuilder = new DecisionTreeBuilder() }; Action question = GetQuestion("Jessica Day", "What is love?"); //ACT var reaction = character.InteractWithMe(question); //ASSERT Assert.IsNotNull(reaction); Assert.AreEqual(question, reaction[0].InitialEvent); }
public void BuildTreeFromDocument_HostileMocking_TreeIsProperlyBuilt() { //ARRANGE DecisionTreeBuilder builder = new DecisionTreeBuilder(); // ReSharper disable once InconsistentNaming var Morty = new Person("Morty", Gender.Male, Sex.Male, Orientation.Undefined, Guid.NewGuid()); var character = new global::RNPC.Core.Character(Morty, Archetype.TheInnocent) { FileController = new DecisionTreeFileController(), DecisionTreeBuilder = new DecisionTreeBuilder() }; //Hostile Mockery Action mockery = new Action { Tone = Tone.Mocking, EventType = EventType.Interaction, ActionType = ActionType.Verbal, Intent = Intent.Hostile, Message = "Did your mother dress you up this morning?", Target = character.MyName, EventName = "Mocking", Source = "The Bully" }; //ACT var rootNode = builder.BuildTreeFromDocument(new DecisionTreeFileController(), mockery, "Morty") as AbstractDecisionNode; //ASSERT //ASSERT Assert.IsNotNull(rootNode); //ajusted per event Assert.IsFalse(string.IsNullOrEmpty(rootNode.DefaultTreeReaction)); Assert.AreEqual(60, rootNode.ConfiguredPassFailValue); Assert.IsTrue(rootNode.LeftNode != null); Assert.IsTrue(rootNode.RightNode != null); }
public void WriteToFile_OmniscienceFile_FileWritten() { //ARRANGE OmniscienceFileController controller = new OmniscienceFileController(); if (controller.FileExists()) { controller.DeleteFile(); } var referenceData = MemoryContentInitializer.CreateItemsAndLinkThem(new ItemLinkFactory()); Dictionary <Guid, MemoryItem> dataDictionary = new Dictionary <Guid, MemoryItem>(); foreach (var item in referenceData) { dataDictionary.Add(Guid.NewGuid(), item); } Omniscience allKnowledge = new Omniscience(dataDictionary); for (int i = 0; i < 50; i++) { Person newPerson = new Person("NPC" + i, Gender.Agender, Sex.Undefined, Orientation.Asexual, Guid.Empty); var newNpc = new global::RNPC.Core.Character(newPerson, Archetype.None); for (int j = 0; j < referenceData.Count; j++) { if (RandomValueGenerator.GeneratePercentileIntegerValue() < 34) { newNpc.AddContentToLongTermMemory(dataDictionary.ElementAt(j).Value); } } allKnowledge.AddFollower(newNpc); } //ACT controller.WriteToFile(allKnowledge); //ASSERT controller.FileExists(); }
public void BuildTreeFromDocument_NeutralSalute_TreeIsProperlyBuilt() { //ARRANGE DecisionTreeBuilder builder = new DecisionTreeBuilder(); // ReSharper disable once InconsistentNaming var Morty = new Person("Morty", Gender.Male, Sex.Male, Orientation.Undefined, Guid.NewGuid()); var character = new global::RNPC.Core.Character(Morty, Archetype.TheInnocent) { FileController = new DecisionTreeFileController(), DecisionTreeBuilder = new DecisionTreeBuilder() }; //Neutral Salute Action salute = new Action { EventType = EventType.Interaction, ActionType = ActionType.NonVerbal, Intent = Intent.Neutral, Message = "", Target = character.MyName, EventName = "Salute", Source = "The Ambassador" }; //ACT var rootNode = builder.BuildTreeFromDocument(new DecisionTreeFileController(), salute, "Morty") as AbstractDecisionNode; //ASSERT //ASSERT Assert.IsNotNull(rootNode); //ajusted per event Assert.IsFalse(string.IsNullOrEmpty(rootNode.DefaultTreeReaction)); Assert.AreEqual(0, rootNode.ConfiguredPassFailValue); Assert.IsTrue(rootNode.LeftNode != null); Assert.IsTrue(rootNode.RightNode != null); }
public void FindEventByTypeAndRelatedPerson_MemoryLoadedWithEventsAndPersons_EventFound() { //ARRANGE var knowledge = MemoryContentInitializer.CreateEventsAndPersons(new ItemLinkFactory()); var guineaPig = new Person("Guinea Pig", Gender.Male, Sex.Male, Orientation.Straight, Guid.NewGuid()); var testCharacter = new global::RNPC.Core.Character(guineaPig, Archetype.None) { FileController = new DecisionTreeFileController(), DecisionTreeBuilder = new DecisionTreeBuilder(), KnowledgeRandomizer = new TestKnowledgeRandomization() }; testCharacter.AddContentToLongTermMemory(knowledge); //ACT var conflicts = testCharacter.MyMemory.Events.FindEventsByTypeAndRelatedPerson(PastEventType.Conflict, "Rilbert"); //ASSERT Assert.IsNotNull(conflicts); Assert.AreEqual(2, conflicts.Count); }
public void KnowledgeTest_BattleOfCintra_AnswerReturned() { //Who conquered Cintra? //Nilfgaard conquered Cintra at the battle of Cintra //ARRANGE var knowledge = MemoryContentInitializer.CreateItemsAndLinkThem(new ItemLinkFactory()); var guineaPig = new Person("Guinea Pig", Gender.Male, Sex.Male, Orientation.Straight, Guid.NewGuid()); var testCharacter = new global::RNPC.Core.Character(guineaPig, Archetype.None, knowledge) { FileController = new DecisionTreeFileController(), DecisionTreeBuilder = new DecisionTreeBuilder(), KnowledgeRandomizer = new TestKnowledgeRandomization() }; testCharacter.AddContentToLongTermMemory(knowledge); //ACT // ReSharper disable once InconsistentNaming var Cintra = testCharacter.MyMemory.Places.FindPlaceByName("Cintra"); //ASSERT Assert.IsNotNull(Cintra); var conquest = Cintra.FindLinkedEventByType(OccurenceType.Conquest); Assert.IsNotNull(conquest); var conqueringKing = conquest.FindOccupationsByInvolvementType(OccupationalInvolvementType.Led); Assert.IsNull(conqueringKing); var emperator = Cintra.FindOccupationsByOccupationalTieType(OccupationalTieType.Conquered); Assert.IsNotNull(emperator); Assert.IsTrue(emperator.Count == 1); Assert.AreEqual("Imperator", emperator[0].Name); }
public void FindEventByName_MemoryLoadedWithEventsAndPersons_EventFound() { string eventName = "The Conjunction of the Spheres"; //ARRANGE var knowledge = MemoryContentInitializer.CreateEventsAndPersons(new ItemLinkFactory()); var guineaPig = new Person("Guinea Pig", Gender.Male, Sex.Male, Orientation.Straight, Guid.NewGuid()); var testCharacter = new global::RNPC.Core.Character(guineaPig, Archetype.None) { FileController = new DecisionTreeFileController(), DecisionTreeBuilder = new DecisionTreeBuilder(), KnowledgeRandomizer = new TestKnowledgeRandomization() }; testCharacter.AddContentToLongTermMemory(knowledge); //ACT var conjunction = testCharacter.MyMemory.Events.FindEventByName(eventName); //ASSERT Assert.IsNotNull(conjunction); Assert.AreEqual(eventName, conjunction.Name); }
public void KnowledgeTest_AnyasBoyfriend_AnswerReturned() { //Who is Anya dating? //Anya and Henselt are dating //ARRANGE var knowledge = new List <MemoryItem>(); knowledge.AddRange(MemoryContentInitializer.CreatePersonsAndOccupationsForTest(new ItemLinkFactory())); var guineaPig = new Person("Guinea Pig", Gender.Male, Sex.Male, Orientation.Straight, Guid.NewGuid()); var testCharacter = new global::RNPC.Core.Character(guineaPig, Archetype.None) { FileController = new DecisionTreeFileController(), DecisionTreeBuilder = new DecisionTreeBuilder(), KnowledgeRandomizer = new TestKnowledgeRandomization() }; testCharacter.AddContentToLongTermMemory(knowledge); //ACT // ReSharper disable once InconsistentNaming var Anya = testCharacter.MyMemory.Persons.FindPersonByName("Anya"); //ASSERT Assert.IsNotNull(Anya); // ReSharper disable once InconsistentNaming var relationships = Anya.FindRelationshipsByType(PersonalRelationshipType.Romantic); Assert.IsNotNull(relationships); Assert.IsTrue(relationships.Count == 1); var boyfriend = relationships[0].RelatedPerson; Assert.IsNotNull(boyfriend); Assert.AreEqual("Hanselt", boyfriend.Name); }