public double EvaluateOnTold(Character perspectiveCharacter, Character evaluateCharacter, Game game) { //The perspectiveCharacter is the character performing the query. //The evaluateCharacter is the character whose opinion on the information we care about. EventContext observeContext = new EventContext(evaluateCharacter, parameters); return information.OnTold.Evaluate(game, observeContext, evaluateCharacter.GetWeights(perspectiveCharacter)); }
public PlayerCharacter(MainWindow main, string name, int birthdate, Dynasty dynasty, int money, Game game, Gender gender) : base(name, birthdate, dynasty, money, game, gender) { this.main = main; notificator = new Notificator(); notificator.Show(); }
public MainWindow(string playerName, string playerDynasty, int age) { this.FormClosed += MainWindow_FormClosed; InitializeComponent(); logger = new TextBoxLogger(this); game = new Game(logger, NUM_PLAYERS); player = new PlayerCharacter(this, playerName, -Game.GetYearInTicks(age), new Dynasty(playerDynasty), 500, game, Gender.Male); game.AddPlayer(player); UpdateDate(); UpdateStatus(); if (Debugger.IsAttached) { restartButton.Visible = true; debugButton.Visible = true; } speedStep.Visible = false; restartButton.Visible = false; nextButton.Visible = false; playerStatusStrip.Visible = true; gameThread = new Thread(GameThread); gameThread.Start(); }
public double Calculate(EventContext context, Game game) { double result = 0.0; foreach(var part in parts) { result += part.Calculate(context, game); } return result; }
public bool Evaluate(EventContext context, Game game) { for(int i = 0; i < subexpressions.Length; ++i) { if (!subexpressions[i].Evaluate(context, game)) return false; } return true; }
public void GetChangedModifiers(EventContext context, Game game, List<PrestigeModifier> added, List<PrestigeModifier> removed) { foreach (var modifier in prestigeModifiers) { if (modifier.EvaluateRequirements(context, game) && !modifier.EvaluateRequirements(context.CurrentCharacter, game)) { added.Add(modifier); } else if (!modifier.EvaluateRequirements(context, game) && modifier.EvaluateRequirements(context.CurrentCharacter, game)) { removed.Add(modifier); } } }
public void EvaluatePrestigeModifiers(Character character, Game game) { foreach (var modifier in prestigeModifiers) { if (modifier.EvaluateRequirements(character, game)) { character.AddPrestigeModifier(modifier); character.PrestigeChange(modifier.DailyChange); } else { character.RemovePrestigeModifier(modifier); } } }
public DNA CreateChildDNA(Character character, DNA father, DNA mother, Game game) { int face = SelectRandomAllowed(faceImages, character, father.Face, mother.Face, game); int mouth = SelectRandomAllowed(mouthImages, character, father.Mouth, mother.Mouth, game); int nose = SelectRandomAllowed(noseImages, character, father.Nose, mother.Nose, game); int eyes = SelectRandomAllowed(eyeImages, character, father.Eyes, mother.Eyes, game); int eyebrows = SelectRandomAllowed(eyebrowImages, character, father.Eyebrows, mother.Eyebrows, game); int ears = SelectRandomAllowed(earImages, character, father.Ears, mother.Ears, game); int hair = SelectRandomAllowed(hairImages, character, father.Hair, mother.Hair, game); int skinColor = SelectRandomAllowedColor(skinColors, character, father.SkinColor, mother.SkinColor, game); int eyeColor = SelectRandomAllowedColor(eyeColors, character, father.EyeColor, mother.EyeColor, game); int hairColor = SelectRandomAllowedColor(hairColors, character, father.HairColor, mother.HairColor, game); int shirtColor = CharacterVisualizationManager.GetRandomShirtColor(game); return new DNA(face, mouth, nose, eyes, eyebrows, ears, hair, skinColor, eyebrows, hairColor, shirtColor); }
public static double GetTestValue(EventContext context, Game game, string value) { //These values must match the special cases on IsSpecialName if (value == "TIME") return game.CurrentTime; else if (value == "AGE") return context.CurrentCharacter.Age; else if (value == "GOLD") return context.CurrentCharacter.Money; double dValue; if (double.TryParse(value, out dValue)) return dValue; return context.GetVariable(context.CurrentCharacter, value); }
public void Execute(EventResults result, Game game, EventContext context) { //TODO: Start with random index. for(int i = 0; i < context.CurrentCharacter.Children.Count; ++i) { Character character = context.CurrentCharacter.Children[i]; context.PushScope(character); if (requirements.Evaluate(context, game)) { operation.Execute(result, game, context); //AnyChild stops after a single interation. context.PopScope(); return; } context.PopScope(); } }
public bool Evaluate(EventContext context, Game game) { //No children means its never true. Used in CHILDREN_WELLDRESS_PRESTIGE_MOD. if (context.CurrentCharacter.Children.Count == 0) return false; for (int i = 0; i < context.CurrentCharacter.Children.Count; ++i) { context.PushScope(context.CurrentCharacter.Children[i]); if (!requirements.Evaluate(context, game)) { //We've found a child that doesn't the requirements. This is a failure context.PopScope(); return false; } context.PopScope(); } return true; }
public MainWindow() { this.FormClosed += MainWindow_FormClosed; InitializeComponent(); logger = new TextBoxLogger(this); game = new Game(logger, NUM_PLAYERS); UpdateDate(); if(Debugger.IsAttached) { restartButton.Visible = true; debugButton.Visible = true; } speedStep.Visible = true; restartButton.Visible = true; nextButton.Visible = true; playerStatusStrip.Visible = false; }
public JournalForm(Character[] characters, Game game, Character fixedPerspective) { InitializeComponent(); this.game = game; this.characters = characters; this.fixedPerspective = fixedPerspective; knownCharacters.Items.AddRange(characters); knownCharacters.SelectedIndex = 0; if(fixedPerspective != null) { debugPerspectiveBox.Visible = false; } else { debugPerspectiveBox.Items.AddRange(characters); debugPerspectiveBox.SelectedIndex = 0; } }
public void AssignInitialTraits(Game game, Character character, int maxInitialTraits) { ISet<string> banned = new HashSet<string>(); for (int i = 0; i < maxInitialTraits; ++i) { Trait nextTrait = traits.Values.ElementAt(game.GetRandom(traits.Values.Count)); if (banned.Contains(nextTrait.Identifier)) { continue; } foreach (var opposite in nextTrait.Opposites) { banned.Add(opposite); } banned.Add(nextTrait.Identifier); character.AddTrait(nextTrait); } }
public Character(string name, int birthdate, Dynasty dynasty, int money, Game game, Gender gender) { Name = name; BirthDate = birthdate; Dynasty = dynasty; Money = money; WillPower = Game.MAX_WILLPOWER; Game = game; Gender = gender; KnownInformation = new List<InformationInstance>(); traits = new Dictionary<string, Trait>(); jobs = new Dictionary<string, Job>(); prestigeModifiers = new HashSet<PrestigeModifier>(); Children = new List<Character>(); //TODO: have actual personality in the weights. //TODO: public and private weights should be different publicWeights = new Weights(this); privateWeights = new Weights(this); }
public double Evaluate(Game game, EventContext context, Weights weights) { //TODO: Start with random index. // TODO: Should we be doing some average here instead of just stopping // at the first one that works? for (int i = 0; i < context.CurrentCharacter.Children.Count; ++i) { Character character = context.CurrentCharacter.Children[i]; context.PushScope(character); if (requirements.Evaluate(context, game)) { double result = operation.Evaluate(game, context, weights); //AnyChild stops after a single interation. context.PopScope(); return result; } context.PopScope(); } return 0.0; }
public bool Evaluate(EventContext context, Game game) { Event e = game.GetEventById(eventId); if (e == null) return false; Dictionary<string, object> computedParameters = new Dictionary<string, object>(); foreach (var pair in parameters) { computedParameters.Add(pair.Key, context.GetScopedObjectByName(pair.Value)); } EventContext newContext = new EventContext(context.CurrentCharacter, computedParameters); return e.GetAvailableOptions(newContext, game).Length > 0; }
public bool Evaluate(EventContext context, Game game) { context.PushScope(context.GetScopedObjectByName(scopeName)); bool result = logic.Evaluate(context, game); context.PopScope(); return result; }
public bool Evaluate(EventContext context, Game game) { return context.CurrentCharacter.PrestigeRank <= prestigeRank; }
public bool Evaluate(EventContext context, Game game) { return !logic.Evaluate(context, game); }
public bool Evaluate(EventContext context, Game game) { return game.GetJobById(jobId).CanPerformJob(context.CurrentCharacter, game); }
public bool Evaluate(EventContext context, Game game) { return (context.GetScopedObjectByName(otherCharacter) as Character).Spouse == context.CurrentCharacter; }
public bool Evaluate(EventContext context, Game game) { return context.CurrentCharacter.Gender == Gender.Male; }
public bool Evaluate(EventContext context, Game game) { return game.CurrentTime == game.CurrentDay; }
public bool Evaluate(EventContext context, Game game) { return (context.GetScopedObjectByName(otherCharacter) as Character).Children.Contains(context.CurrentCharacter); }
public bool Evaluate(EventContext context, Game game) { return true; }
public bool Evaluate(EventContext context, Game game) { double myValue = XmlHelper.GetTestValue(context, game, varName); return myValue < testValue.Calculate(context, game); }
public bool Evaluate(EventContext context, Game game) { return context.CurrentCharacter.HasTrait(traitId); }
public bool Evaluate(EventContext context, Game game) { double myValue = XmlHelper.GetTestValue(context, game, varName); return Math.Abs(myValue - testValue.Calculate(context, game)) >= Logic.EPSILON; }
public bool Evaluate(EventContext context, Game game) { return context.CurrentCharacter.Age >= 21; }