public void TryToPopulateIncident_SinglePrereqFails() { Setup_Basic_Prerequisites(); var currentCast = new SocietySnapshot(); for (int i = 0; i < 10; i++) { currentCast.AllCharacters.Add(new Character(i, "name" + i)); } foreach (Character c in currentCast.AllCharacters) { c.BaseMorality = Morality.Exploit; c.BaseSuspicion = SuspicionScale.Guarded; for (int i = 0; i < 10; i++) { if (c.Id != i) { c.CreateRelationshipWith(currentCast.AllCharacters[i], null); } } } Assert.IsFalse(theIncident.TryToPopulateIncident(currentCast, null)); }
public SocietySnapshot CreateStartingCast(int characterCount, Random rng) { if (characterCount < 1) { throw new ArgumentOutOfRangeException(); } var s = new SocietySnapshot(); RandomNameSelector nameFactory = new RandomNameSelector(); List <string> allNames = nameFactory.SelectRandomNamesFromDefaultNameList(characterCount, rng); RandomCharacterGenerator_Default characterFactory = new RandomCharacterGenerator_Default(); for (int i = 0; i < characterCount; i++) { s.AllCharacters.Add(characterFactory.CreateCharacter(i, allNames[i], rng)); } if (characterCount > 1) { CreateStartingRelationships(s, rng); } return(s); }
public void TestInitialize() { var theCast = new SocietySnapshot(); thePlot = new Plot(theCast); throw new NotImplementedException(); }
public void aaa__ScratchPaper_PlotFromScratch() { //Create a simple plot from scratch Random rng = new Random(); int characterCount = 15; StartingCastGenerator_Default characterFactory = new StartingCastGenerator_Default(); SocietySnapshot currentCast = characterFactory.CreateStartingCast(characterCount, rng); Plot thePlot = new Plot(currentCast); //Prepare psuedo "event library" var accidentalOffense = createIncidentManually_AccidentalOffense(); var socialAgression = createIncidentManually_Agression_Social(); var socialCooperation = createIncidentManually_Cooperation_Social(); //NOTE - must create NEW instace of event for each use (or create a way to reset participants) //Create sequence of events //Event #1 var ableToFillRoles = accidentalOffense.TryToPopulateIncident(currentCast, rng); Assert.IsTrue(ableToFillRoles); thePlot.ExecuteIncidentAndStoreAfter(accidentalOffense, currentCast, rng); //Event #2 ableToFillRoles = socialAgression.TryToPopulateIncident(currentCast, rng); Assert.IsTrue(ableToFillRoles); thePlot.ExecuteIncidentAndStoreAfter(socialAgression, currentCast, rng); //Event #3 ableToFillRoles = socialCooperation.TryToPopulateIncident(currentCast, rng); Assert.IsTrue(ableToFillRoles); thePlot.ExecuteIncidentAndStoreAfter(socialCooperation, currentCast, rng); //Event #4 socialAgression = createIncidentManually_Agression_Social(); ableToFillRoles = socialAgression.TryToPopulateIncident(currentCast, rng); Assert.IsTrue(ableToFillRoles); thePlot.ExecuteIncidentAndStoreAfter(socialAgression, currentCast, rng); //Event #5 socialCooperation = createIncidentManually_Cooperation_Social(); ableToFillRoles = socialCooperation.TryToPopulateIncident(currentCast, rng); Assert.IsTrue(ableToFillRoles); thePlot.ExecuteIncidentAndStoreAfter(socialCooperation, currentCast, rng); //Display narrative var theTextNarrative = thePlot.CompileTextNarrative(); foreach (string s in theTextNarrative) { Debug.WriteLine(s); } Assert.IsTrue(true); }
public List <string> LoadNames_OfGivenTrust(SocietySnapshot society, EthicsScale givenTrust) { var theRelations = MyBase.AllRelations.Where(r => r.Trust == givenTrust); var theNames = new List <string>(); foreach (Relationship r in theRelations) { theNames.Add(society.AllCharacters.First(c => c.Id == r.OtherId).Name); } return(theNames); }
public Plot GenerateNewPlot(LibraryOfIncidents givenPossibleIncidents, SocietySnapshot startingCast = null, int?maxIncidentCount = null) { Random rng = new Random(); this.possibleIncidents = givenPossibleIncidents; currentCast = startingCast != null ? startingCast : GetStartingCast(rng); int maxIncidents = maxIncidentCount != null ? maxIncidentCount.Value : MAX_INCIDENT_COUNT; plotInProgress = new Plot(currentCast); CreateSequenceOfEvents(maxIncidents, rng); return(plotInProgress); }
protected void CreateStartingRelationships(SocietySnapshot s, Random rng) { Character.RelationshipGenerator = new RelationshipGenerator_RandomTrust(); //Each character given min of 1 relationship, diminishing odds for each additional relationship foreach (Character c in s.AllCharacters) { if (c.AllRelations.Count >= MAX_RELATIONSHIP_COUNT) { continue; } int diminishingChance = 100 / MAX_RELATIONSHIP_COUNT; for (int percentChance = 100 - (diminishingChance * c.AllRelations.Count); percentChance > 0; percentChance -= diminishingChance) { var unrelated = s.AllCharacters.Where(o => (c.IsAcquaintedWith(o.Id) == false) && o.Id != c.Id).ToList(); if (unrelated.Any() == false) { break; } var diceRoll = rng.Next(0, 100); if (diceRoll < percentChance) { var other = unrelated[rng.Next(0, unrelated.Count)]; c.CreateRelationshipWith(other, rng); if (other.IsAcquaintedWith(c.Id) == false) { //Most relationships are two way // rare for one person to trust another when other doesn't even know them if (rng.Next(0, 100) < PERCENT_CHANCE_FOR_ONEWAY_RELATIONSHIP) { other.CreateRelationshipWith(c, rng); } } } else { break; } } } //During plot generation, when characters meet each other, use base suspicion & morality to create starting relation Character.RelationshipGenerator = new RelationshipGenerator_Default(); }
public void OpenFromFile() { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "Character file (*.cast)|*.cast"; openFileDialog.Multiselect = false; openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); if (openFileDialog.ShowDialog() == true) { MyBase = SocietySnapshot.LoadFromFile(openFileDialog.FileName); OnPropertyChanged(nameof(AllCharacters)); SelectedId = 0; OnPropertyChanged(nameof(SelectedId)); } }
public void LoadAllNames(SocietySnapshot society) { names_Confide = LoadNames_OfGivenTrust(society, EthicsScale.Confide); names_Friend = LoadNames_OfGivenTrust(society, EthicsScale.Befriend); names_Cooperate = LoadNames_OfGivenTrust(society, EthicsScale.Cooperate); names_Coexist = LoadNames_OfGivenTrust(society, EthicsScale.Coexist); names_Exploit = LoadNames_OfGivenTrust(society, EthicsScale.Exploit); names_Beat = LoadNames_OfGivenTrust(society, EthicsScale.Beat); names_Murder = LoadNames_OfGivenTrust(society, EthicsScale.Murder); OnPropertyChanged("names_Confide"); OnPropertyChanged("names_Friend"); OnPropertyChanged("names_Cooperate"); OnPropertyChanged("names_Coexist"); OnPropertyChanged("names_Exploit"); OnPropertyChanged("names_Beat"); OnPropertyChanged("names_Murder"); }
public void TryToPopulateIncident_WithNoPrerequisites_IsSuccessful() { var currentCast = new SocietySnapshot(); for (int i = 0; i < 10; i++) { currentCast.AllCharacters.Add(new Character(i, "name" + i)); } foreach (Character c in currentCast.AllCharacters) { for (int i = 0; i < 10; i++) { if (c.Id != i) { c.CreateRelationshipWith(currentCast.AllCharacters[i], null); } } } Assert.IsTrue(theIncident.TryToPopulateIncident(currentCast, null)); }
public CharacterVM(Character givenBase, SocietySnapshot givenSociety) { storedSociety = givenSociety; MyBase = givenBase; }
public SocietyVM(SocietySnapshot givenBase) { MyBase = givenBase; UpdateSelectedCharacter(); }