public void clicked(Map map) { //selector.selected(person,agent); if (person.getLocation() != null) { try { GraphicalMap.panTo(person.getLocation().hex.x, person.getLocation().hex.y); } catch { //Ignore } } }
public override void turnTick(Person person) { if (person.title_land == null) { person.action = null; return; } turns += 1; if (turns >= World.staticMap.param.action_letterWritingTurns) { int c = 0; Person chosenTarget = null; foreach (Location loc in person.getLocation().getNeighbours()) { foreach (Location l2 in loc.getNeighbours()) { if (l2.person() != null && l2.person() != person) { if (l2.person().awareness < person.awareness) { c += 1; if (Eleven.random.Next(c) == 0) { chosenTarget = l2.person(); } } } } } if (chosenTarget != null) { double delta = person.map.param.awareness_letterWritingAwarenessGain * chosenTarget.getAwarenessMult() * person.map.param.awareness_master_speed; delta = Math.Min(delta, 1 - chosenTarget.awareness); delta = Math.Min(delta, person.awareness - chosenTarget.awareness);//Can't exceed your own awareness chosenTarget.awareness += delta; person.map.addMessage(person.getFullName() + " writes to " + chosenTarget.getFullName() + " to warn them. " + (int)(delta * 100) + " awareness gained", MsgEvent.LEVEL_ORANGE, false); person.lastLetterTurn = person.map.turn; } person.action = null; } }
public override double computeUtility(Person voter, VoteOption option, List <ReasonMsg> msgs) { double u = option.getBaseUtility(voter); Person p = option.person; double benefitU = voter.getRelation(p).getLiking() * voter.map.param.utility_singleUseCure; msgs.Add(new ReasonMsg("Benefit to " + p.getFullName(), benefitU)); u += benefitU; bool hasDisease = false; foreach (Property pr in voter.getLocation().properties) { if (pr.proto.isDisease) { hasDisease = true; break; } } if (hasDisease && p != voter) { //We're considering giving this cure to another //This option doesn't help me. If I'm corrupt, I'll naturally be angry at not being given help double localU = voter.getSelfInterest() * voter.threat_plague.threat * World.staticMap.param.utility_selfInterestFromThreat * 1.5; if (localU != 0) { msgs.Add(new ReasonMsg("Does not help me personally", localU)); u += localU; } } return(u); }
public override double computeUtility(Person p, VoteOption option, List <ReasonMsg> msgs) { double u = option.getBaseUtility(p); if (option.index == NO_RESPONSE) { msgs.Add(new ReasonMsg("Neutral Option", 0)); } if (option.index == AGENT_TO_MEDIC) { double localU = Unit_Investigator.getSwitchUtility(p, (Unit_Investigator)option.unit, Unit_Investigator.unitState.medic); localU *= p.map.param.utility_swapAgentRolesMult; msgs.Add(new ReasonMsg("Balance of agent skills vs balance of threats", localU)); u += localU; } if (option.index == AGENT_TO_BASIC) { double localU = Unit_Investigator.getSwitchUtility(p, (Unit_Investigator)option.unit, Unit_Investigator.unitState.basic); localU *= p.map.param.utility_swapAgentRolesMult; msgs.Add(new ReasonMsg("Balance of agent skills vs balance of threats", localU)); u += localU; } if (option.index == QUARANTINE) { //First part is your personal utility. How much am I, personally, affected? double localU = p.threat_plague.threat; bool amNeighbour = false; bool hasDisease = false; foreach (Property p2 in p.getLocation().properties) { if (p2.proto.isDisease) { hasDisease = true; break; } } if (hasDisease) { //This option doesn't help me. It's already here. If I'm corrupt, I'll naturally be angry at not being given help localU = p.getSelfInterest() * p.threat_plague.threat * World.staticMap.param.utility_selfInterestFromThreat; if (localU != 0) { msgs.Add(new ReasonMsg("Does not help me personally", localU)); u += localU; } } else { //I do not have the disease. Best to vote to keep it that way. foreach (Location l2 in p.getLocation().getNeighbours()) { foreach (Property p2 in l2.properties) { if (p2.proto.isDisease) { amNeighbour = true; break; } } } if (amNeighbour) { localU *= 1.5; } else { localU *= 0.66; } localU *= p.getSelfInterest() * -1 * World.staticMap.param.utility_selfInterestFromThreat; //Note this param is negative as it is petulance if (localU != 0) { msgs.Add(new ReasonMsg("Desire to keep self safe from disease", localU)); u += localU; } } //Second part is the benefit to the nation int nNeighbours = 0; double nSocLocs = 0; foreach (Location l2 in p.map.locations) { if (l2.soc == p.society) { nSocLocs += 1; } else { continue; } hasDisease = false; foreach (Property p2 in l2.properties) { if (p2.proto.isDisease) { hasDisease = true; break; } } if (hasDisease) { foreach (Location l3 in l2.getNeighbours()) { if (l3.soc != p.society) { continue; } bool l3HasDisease = false; foreach (Property p2 in l3.properties) { if (p2.proto.isDisease) { l3HasDisease = true; break; } } if (!l3HasDisease) { //Location 3 doesn not have the disease, but l2 does. Therefore it is a spread vector //Since we're taking a risk for each link, we can double-count L3s. nNeighbours += 1; } } } } localU = nNeighbours; if (nSocLocs > 0) { localU /= nSocLocs; } //Normalise for society size localU *= p.threat_plague.threat; localU *= p.map.param.utility_plagueResponseMultPerRiskItem; localU *= Math.Max(0, Math.Min(1, 1 - p.getSelfInterest()));//Clamp that between [0,1] if (localU != 0) { msgs.Add(new ReasonMsg("Benefit to nation: Number of locations at risk", localU)); u += localU; } } if (option.index == TREATMENT) { //First part is your personal utility. How much am I, personally, affected? double localU = p.threat_plague.threat; bool hasDisease = false; foreach (Property p2 in p.getLocation().properties) { if (p2.proto.isDisease) { hasDisease = true; break; } } if (hasDisease) { //I have the disease. Gotta invest in that sweet cure localU *= p.getSelfInterest() * -1 * World.staticMap.param.utility_selfInterestFromThreat;//Note this param is negative as it is petulance if (localU != 0) { msgs.Add(new ReasonMsg("Desire to save self from disease", localU)); u += localU; } } else { //This option doesn't help me. It's already here. If I'm corrupt, I'll naturally be angry at not being given help localU = p.getSelfInterest() * p.threat_plague.threat * World.staticMap.param.utility_selfInterestFromThreat; if (localU != 0) { msgs.Add(new ReasonMsg("Does not help me personally", localU)); u += localU; } } //Second part is the benefit to the nation int nDiseased = 0; double nSocLocs = 0; foreach (Location l2 in p.map.locations) { if (l2.soc == p.society) { nSocLocs += 1; } else { continue; } foreach (Property p2 in l2.properties) { if (p2.proto.isDisease) { nDiseased += 1; break; } } } localU = nDiseased; if (nSocLocs > 0) { localU /= nSocLocs; } //Normalise for society size localU *= p.threat_plague.threat; localU *= p.map.param.utility_plagueResponseMultPerRiskItem; localU *= Math.Max(0, Math.Min(1, 1 - p.getSelfInterest()));//Clamp that between [0,1] if (localU != 0) { msgs.Add(new ReasonMsg("Benefit to nation: Number of locations infected", localU)); u += localU; } } return(u); }
public override double computeUtility(Person voter, VoteOption option,List<ReasonMsg> msgs) { double u = option.getBaseUtility(voter); double ourStrength = society.currentMilitary; double theirStrength = option.group.currentMilitary; double localU = 0; //1 if we're 100% of the balance, -1 if they are double relativeStrength = (ourStrength - theirStrength) / (ourStrength + theirStrength); //Don't just always attack the weakest, it causes blobbing. Check military to avoid suicide charges, but attack should be modulated by threat //As such, this modifier only applies when its negative (aversion to attacking stronger targets) localU = society.map.param.utility_militaryTargetRelStrengthOffensive*relativeStrength; if (localU < 0) { msgs.Add(new ReasonMsg("Relative Strength of Current Militaries", localU)); u += localU; } //We want to expand into territory we already partially own bool hasMyTerritory = false; foreach (Location loc in option.group.lastTurnLocs) { if (loc.province == voter.getLocation().province) { hasMyTerritory = true; break; } } if (hasMyTerritory) { localU = society.map.param.utility_militaryTargetCompleteProvince; msgs.Add(new ReasonMsg("Has territory from my province", localU)); u += localU; } bool hasOurTerritory = false; foreach (Location loc in option.group.lastTurnLocs) { foreach (Location l2 in society.lastTurnLocs) { if (loc.province == l2.province) { hasOurTerritory = true; } } } //We want to own more land. Invade weak neighbours bool shouldExpand = true; int nDukes = 0; foreach (Title t in society.titles) { if (t is Title_ProvinceRuler) { nDukes += 1; } } if (nDukes >= society.map.param.society_maxDukes) { shouldExpand = false; } if (shouldExpand && option.group is Society && option.group.currentMilitary*1.5 < this.society.currentMilitary && option.group.getNeighbours().Contains(this.society)) { //Society soc = (Society)option.group; //if (this.society.getCapital() != null && soc.getCapital() != null) //{ // if (soc.getCapital().hex.getHabilitability() > 0.5) // { localU = society.map.param.utility_militaryTargetExpansion; msgs.Add(new ReasonMsg("Expand our holdings", localU)); u += localU; // } //} } foreach (ThreatItem threat in voter.threatEvaluations) { if (threat.group == option.group) { localU = threat.threat*society.map.param.utility_fromThreat; msgs.Add(new ReasonMsg("Perceived Threat", localU)); u += localU; break; } } //If we already have a military target if (society.offensiveTarget != null) { theirStrength = society.offensiveTarget.currentMilitary; localU = 0; //1 if we're 100% of the balance, -1 if they are relativeStrength = (ourStrength - theirStrength) / (ourStrength + theirStrength); if (relativeStrength > 0) { relativeStrength = 0; } //Add current target threat foreach (ThreatItem threat in voter.threatEvaluations) { if (threat.group == society.offensiveTarget) { localU -= threat.threat; break; } } //We want to expand into territory we already partially own hasOurTerritory = false; foreach (Location loc in society.offensiveTarget.lastTurnLocs) { if (loc.province == voter.getLocation().province) { hasOurTerritory = true; break; } } if (hasOurTerritory) { localU -= society.map.param.utility_militaryTargetCompleteProvince; } localU -= society.map.param.utility_militaryTargetRelStrengthOffensive * relativeStrength; msgs.Add(new ReasonMsg("Desirability of current target (" + society.offensiveTarget.getName() + ")", localU)); u += localU; } return u; }
public override double computeUtility(Person voter, VoteOption option, List <ReasonMsg> msgs) { double u = option.getBaseUtility(voter); ThreatItem greatestThreat = voter.getGreatestThreat(); double ourStr = 1 + (voter.society.currentMilitary + (voter.society.maxMilitary / 2)); double offStr = 1; double defStr = 1; if (voter.society.offensiveTarget != null) { offStr = voter.society.offensiveTarget.currentMilitary + (voter.society.offensiveTarget.maxMilitary / 2); } if (voter.society.defensiveTarget != null) { defStr = voter.society.defensiveTarget.currentMilitary + (voter.society.defensiveTarget.maxMilitary / 2); } double defUtility = 0; double defGreatestThreat = 0; if (voter.society.defensiveTarget != null) { //Negative if we are stronger than the one we fear defUtility += (defStr - ourStr) / (ourStr + defStr) * voter.map.param.utility_militaryTargetRelStrengthDefensive; if (defUtility < -50) { defUtility = -50; } if (greatestThreat != null) { if (greatestThreat.group != null && greatestThreat.group.currentMilitary > voter.society.currentMilitary) { defGreatestThreat = World.staticMap.param.utility_greatestThreatDelta; defUtility += defGreatestThreat; if (option.index == 0) { msgs.Add(new ReasonMsg("Our greatest threat (" + greatestThreat.group.getName() + ") is stronger than us, we must defend", defGreatestThreat)); } } } } double offUtility = 0; double offUtilityStr = 0; double offUtilityPersonality = 0; double offUtilityTerritory = 0; double offUtilityInstab = 0; double offGreatestThreat = 0; if (voter.society.offensiveTarget != null) { //Negative if the offensive target is stronger offUtilityStr += (ourStr - offStr) / (ourStr + offStr) * voter.map.param.utility_militaryTargetRelStrengthOffensive; if (voter.society.offensiveTarget is Society) { offUtilityStr = Math.Min(offUtilityStr, voter.map.param.utility_militaryTargetRelStrengthOffensive);//Capped to prevent insanity snowballing } offUtilityPersonality += voter.getMilitarism() * voter.map.param.utility_militarism; //We want to expand into territory we already partially own bool hasOurTerritory = false; foreach (Location loc in voter.society.offensiveTarget.lastTurnLocs) { if (loc.province == voter.getLocation().province) { hasOurTerritory = true; break; } } if (hasOurTerritory) { offUtilityTerritory += society.map.param.utility_militaryTargetCompleteProvince * society.data_societalStability; } if (offUtilityStr > 0 && society.offensiveTarget is Society) { //Counters expansion desire. Value always negative or zero //u = off*stability //u = off + (off*(stability-1)) (Because we are removing 1 from stability mult) //If stab == 0 it's off - off //If stab < 0 it's less than off offUtilityInstab = offUtilityInstab * (society.data_societalStability - 1); } if (greatestThreat != null) { if (greatestThreat.group != null && greatestThreat.group.currentMilitary < voter.society.currentMilitary) { offGreatestThreat += World.staticMap.param.utility_greatestThreatDelta; if (option.index == 1) { msgs.Add(new ReasonMsg("Our greatest threat (" + greatestThreat.group.getName() + ") is weaker than us, we must attack", offGreatestThreat)); } } } offUtility += offGreatestThreat; offUtility += offUtilityStr; offUtility += offUtilityPersonality; offUtility += offUtilityTerritory; offUtility += offUtilityInstab; } double introUtility = 0; double introUtilityStability = 0; if (society.data_societalStability < 0.66) { introUtilityStability = -(society.data_societalStability - 1); //0 if stability is 1, increasing to 1 if civil war is imminent, to 2 if every single person is a traitor } double introGreatestThreat = 0; if (greatestThreat != null) { if (greatestThreat.form == ThreatItem.formTypes.AGENTS || greatestThreat.form == ThreatItem.formTypes.ENSHADOWED_NOBLES) { introGreatestThreat = World.staticMap.param.utility_greatestThreatDelta; introUtility += introGreatestThreat; if (option.index == 2) { msgs.Add(new ReasonMsg("Our greatest threat (" + greatestThreat.getTitle() + ") requires internal security", introGreatestThreat)); } } } introUtilityStability *= voter.map.param.utility_introversionFromInstability; double introFromInnerThreat = voter.threat_enshadowedNobles.threat * voter.map.param.utility_introversionFromSuspicion; introUtility += introUtilityStability; introUtility += introFromInnerThreat; introUtility += 10; //Option 0 is DEFENSIVE //Option 1 is OFFENSIVE //Option 2 is INTROSPECTIVE if (voter.society.posture == Society.militaryPosture.defensive && option.index != 0) { u -= defUtility; msgs.Add(new ReasonMsg("Switching away from defensive", -defUtility)); } if (voter.society.posture == Society.militaryPosture.offensive && option.index != 1) { u -= offUtility; msgs.Add(new ReasonMsg("Switching away from offensive", -offUtility)); } if (voter.society.posture == Society.militaryPosture.introverted && option.index != 2) { u -= introUtility; msgs.Add(new ReasonMsg("Switching away from introversion", -introUtility)); } if (option.index == 0) { if (society.posture != Society.militaryPosture.defensive) { u += defUtility; msgs.Add(new ReasonMsg("Our relative strength against defensive target", defUtility)); if (voter.society.isDarkEmpire) { int value = (int)(-100 * voter.shadow); u += value; msgs.Add(new ReasonMsg("We must expand the Dark Empire", value)); } } else { u += defUtility; msgs.Add(new ReasonMsg("Our relative strength against defensive target", defUtility)); if (voter.society.isDarkEmpire) { int value = (int)(-100 * voter.shadow); u += value; msgs.Add(new ReasonMsg("We must expand the Dark Empire", value)); } msgs.Add(new ReasonMsg("No need to change: It is our current stance", -u)); u = 0; } } if (option.index == 1) { if (society.posture != Society.militaryPosture.offensive) { u += offUtility; msgs.Add(new ReasonMsg("Our relative strength against offensive target", offUtilityStr)); msgs.Add(new ReasonMsg("Risk of instability from expansion", offUtilityInstab)); msgs.Add(new ReasonMsg("Militarism personality", offUtilityPersonality)); msgs.Add(new ReasonMsg("Desire for territory", offUtilityTerritory)); if (voter.society.isDarkEmpire) { int value = (int)(100 * voter.shadow); u += value; msgs.Add(new ReasonMsg("We must expand the Dark Empire", value)); } } else { u += offUtility; msgs.Add(new ReasonMsg("Our relative strength against offensive target", offUtilityStr)); msgs.Add(new ReasonMsg("Risk of instability from expansion", offUtilityInstab)); msgs.Add(new ReasonMsg("Militarism personality", offUtilityPersonality)); msgs.Add(new ReasonMsg("Desire for territory", offUtilityTerritory)); if (voter.society.isDarkEmpire) { int value = (int)(100 * voter.shadow); u += value; msgs.Add(new ReasonMsg("We must expand the Dark Empire", value)); } msgs.Add(new ReasonMsg("No need to change: It is our current stance", -u)); u = 0; } } if (option.index == 2) { msgs.Add(new ReasonMsg("Default position", 10)); if (society.posture != Society.militaryPosture.introverted) { u += introUtility; msgs.Add(new ReasonMsg("Instability internally", introUtilityStability)); msgs.Add(new ReasonMsg("Suspicion of nobles' darkness", introFromInnerThreat)); if (voter.society.isDarkEmpire) { int value = (int)(-100 * voter.shadow); u += value; msgs.Add(new ReasonMsg("We must expand the Dark Empire", value)); } } else { u += introUtility; msgs.Add(new ReasonMsg("Instability internally", introUtilityStability)); msgs.Add(new ReasonMsg("Suspicion of nobles' darkness", introFromInnerThreat)); if (voter.society.isDarkEmpire) { int value = (int)(-100 * voter.shadow); u += value; msgs.Add(new ReasonMsg("We must expand the Dark Empire", value)); } msgs.Add(new ReasonMsg("No need to change: It is our current stance", -u)); u = 0; } } return(u); }
public override double computeUtility(Person voter, VoteOption option, List <ReasonMsg> msgs) { double u = option.getBaseUtility(voter); //double parityMult = 1; //if (option.index == 0) { parityMult = -1; } //return 100 * parityMult; //Option 0 is "Don't declare war" //1 if we're 100% of the balance, -1 if they are double ourStrength = society.currentMilitary + (society.maxMilitary * 0.5); double theirStrength = target.currentMilitary + (target.maxMilitary * 0.5); if (ourStrength + theirStrength == 0) { ourStrength += 0.001; } double relativeStrength = (ourStrength - theirStrength) / (ourStrength + theirStrength + 1); double localU = 0; double relMilU = society.map.param.utility_militaryTargetRelStrengthOffensive * relativeStrength; bool shouldExpand = true; int nDukes = 0; foreach (Title t in society.titles) { if (t is Title_ProvinceRuler) { nDukes += 1; } } if (nDukes >= society.map.param.society_maxDukes) { shouldExpand = false; } bool hasOurTerritory = false; foreach (Location loc in target.lastTurnLocs) { foreach (Location l2 in society.lastTurnLocs) { if (loc.province == l2.province) { hasOurTerritory = true; } } } //Peace if (option.index == 0) { if (ourStrength < 1) { localU = 1000; msgs.Add(new ReasonMsg("We are too weak", localU)); u += localU; return(u); } if (ourStrength * 2 < theirStrength) { localU = 1000; msgs.Add(new ReasonMsg("We stand no chance", localU)); u += localU; return(u); } if (relMilU < 0) { msgs.Add(new ReasonMsg("Relative strength of current militaries", -relMilU)); u += relMilU; } bool tinyComplete = target.lastTurnLocs.Count <= 3 && hasOurTerritory;//You can take over tiny nations to complete your provinces if (!tinyComplete && society.isDarkEmpire == false && shouldExpand == false && target is Society) { localU = society.map.param.utility_militaryOverexpansionHalt; msgs.Add(new ReasonMsg("We have as much as we can control", localU)); u += localU; } localU = voter.getMilitarism() * -100; msgs.Add(new ReasonMsg("Militarism of " + voter.getFullName(), localU)); u += localU; } else //Pro-war { //We want to expand into territory we already partially own bool hasMyTerritory = false; foreach (Location loc in target.lastTurnLocs) { if (loc.province == voter.getLocation().province) { hasMyTerritory = true; break; } } if (hasMyTerritory) { localU = society.map.param.utility_militaryTargetCompleteProvince; msgs.Add(new ReasonMsg("Has territory from my province", localU)); u += localU; } //We want to own more land. Invade weak neighbours if (shouldExpand && target is Society && target.currentMilitary * 1.5 < this.society.currentMilitary && target.getNeighbours().Contains(this.society)) { //Society soc = (Society)target; //if (this.society.getCapital() != null && soc.getCapital() != null) //{ // if (soc.getCapital().hex.getHabilitability() > 0.5) // { localU = society.map.param.utility_militaryTargetExpansion * Math.Max(0, voter.getMilitarism()); msgs.Add(new ReasonMsg("Expand our holdings", localU)); u += localU; // } //} } localU = voter.getMilitarism() * 100; msgs.Add(new ReasonMsg("Militarism of " + voter.getFullName(), localU)); u += localU; foreach (ThreatItem threat in voter.threatEvaluations) { if (threat.group == target) { localU = threat.threat * society.map.param.utility_fromThreat; msgs.Add(new ReasonMsg("Perceived Threat", localU)); u += localU; break; } } } /* * if (relMilU > 0 && target is Society) * { * //0 if stability is full, getting more negative as stability decreases * double stabilityU = (this.society.data_societalStability-1); * stabilityU = relMilU * stabilityU;//More negative the worse stability is, reaches the complement of relMilU when civil war is imminent * msgs.Add(new ReasonMsg("Our societal stability concerns", stabilityU)); * u += stabilityU; * } */ /* * if (this.society.defensiveTarget != null && this.society.defensiveTarget != this.society.offensiveTarget) * { * * theirStrength = society.defensiveTarget.currentMilitary; * //0 if we're 100% of the balance, -1 if they are * relativeStrength = (((ourStrength - theirStrength) / (ourStrength + theirStrength))-1)/2; * * localU = society.map.param.utility_militaryTargetRelStrength * relativeStrength * parityMult; * msgs.Add(new ReasonMsg("Defensive Target's Capabilities (risk of sneak attack)", localU)); * u += localU; * } */ return(u); }
public void lashOut(Person p) { if (Eleven.random.NextDouble() > p.map.param.insanity_lashOutProbability) { return; } int c = 0; Person victim = null; foreach (Person p2 in p.society.people) { if (p2 == p) { continue; } c += 1; if (Eleven.random.Next(c) == 0) { victim = p2; } } if (victim != null) { victim.getRelation(p).addLiking(-30, "Lashed out in madess", p.map.turn); if (p.society.hasEnthralled()) { p.map.addMessage(p.getFullName() + " lashes out against " + victim.getFullName() + " in madness", MsgEvent.LEVEL_DARK_GREEN, p.state != Person.personState.enthralled, p.getLocation().hex); } } }
public void processAwareness() { if (param.useAwareness != 1) { return; } if (awarenessReportings > 0) { data_awarenessSum /= awarenessReportings; } double targetAwareness = worldPanic; targetAwareness = Math.Pow(targetAwareness, 2);//Square it, such that it reaches 100% at 100%, but dawdles before then if (data_awarenessSum < targetAwareness) { if (turn % 7 == 0) { int c = 0; Person target = null; foreach (Location loc in locations) { if (loc.soc is Society && loc.person() != null && loc.settlement != null && loc.settlement is Set_University && loc.person().state == Person.personState.normal) { if (loc.person().awareness < 1) { c += 1; if (Eleven.random.Next(c) == 0) { target = loc.person(); } } } } if (target != null) { target.awareness = 1; addMessage(target.getFullName() + " has gained awareness, having studied the signs", MsgEvent.LEVEL_ORANGE, false, target.getLocation().hex); } } else { double sumGain = 0; foreach (Location loc in locations) { if (loc.person() != null && loc.person().state == Person.personState.normal && loc.person().awareness > 0) { foreach (Location l2 in loc.getNeighbours()) { if (l2.person() != null && l2.person().state == Person.personState.normal && l2.person().awareness < loc.person().awareness) { double maxGain = loc.person().awareness - l2.person().awareness; maxGain *= 1 - l2.person().shadow; double prev = l2.person().awareness; l2.person().nextTurnawareness = l2.person().awareness + (maxGain * Eleven.random.NextDouble()); if (l2.person().nextTurnawareness > 1) { l2.person().nextTurnawareness = 1; } //Should be impossible, but best not risk it sumGain += l2.person().nextTurnawareness - prev; } } } } if (sumGain > 0.9) { addMessage("Awareness of the dark grows", MsgEvent.LEVEL_ORANGE, false); hintSystem.popHint(HintSystem.hintType.AWARENESS); } } } data_awarenessSum = 0; awarenessReportings = 0; }
public override double computeUtility(Person p, VoteOption option, List <ReasonMsg> msgs) { double u = option.getBaseUtility(p); double concernLevel = p.threat_agents.threat; //curr 0 to 200 concernLevel += (100 * p.awareness) + (100 * p.map.worldPanic); //0 to 400 concernLevel /= 4; concernLevel = Math.Min(concernLevel, (p.map.worldPanic * 100) + 20); concernLevel *= (1 - p.shadow); if (p.state == Person.personState.enthralled || p.state == Person.personState.broken) { concernLevel = 0; } //Define the range at which this manner of response is appropriate double responseLevelMin = 0; double responseLevelMax = 0; if (option.index == DEFEND_PROVINCE) { responseLevelMin = 10; responseLevelMax = 40; int evidenceFound = 0; foreach (Evidence ev in foundEvidence) { if (ev.locationFound.province.index == option.province) { evidenceFound += 1; } } double localU = World.staticMap.param.utility_defendEvidenceProvince * evidenceFound * (1 - p.shadow); msgs.Add(new ReasonMsg("Amount of evidence found in " + society.map.provinces[option.province].name + " province", localU)); u += localU; localU = 0; foreach (Person person in society.people) { if (person.getLocation() != null && person.getLocation().province.index == option.province) { localU += p.getRelation(person.index).getLiking() * World.staticMap.param.utility_agentDefendProvinceLikingMult; } } string add = ""; msgs.Add(new ReasonMsg("Liking for nobles in province" + add, localU)); u += localU; if (p.getLocation().province.index != option.province) { localU = p.getSelfInterest() * p.threat_agents.threat * World.staticMap.param.utility_selfInterestFromThreat; if (localU != 0) { msgs.Add(new ReasonMsg("Does not help me personally", localU)); u += localU; } } else { localU = -1 * p.getSelfInterest() * p.threat_agents.threat * World.staticMap.param.utility_selfInterestFromThreat; if (localU != 0) { msgs.Add(new ReasonMsg("Helps me personally", localU)); u += localU; } } } if (option.index == NATIONWIDE_SECURITY) { responseLevelMin = 10; responseLevelMax = 40; double localU = World.staticMap.param.utility_evidenceResonseBaseline * (concernLevel / 100); msgs.Add(new ReasonMsg("Base Desirability", localU)); u += localU; localU = p.getSelfInterest() * p.threat_agents.threat * World.staticMap.param.utility_selfInterestFromThreat / 2; if (localU != 0) { msgs.Add(new ReasonMsg("Doesn't maximise my provinces' defences", localU)); u += localU; } } if (option.index == NO_RESPONSE) { responseLevelMin = 0; responseLevelMax = 10; if (p.getGreatestThreat() != null && p.getGreatestThreat() != p.threat_agents) { double localU = World.staticMap.param.utility_greatestThreatDelta * 0.5; msgs.Add(new ReasonMsg("Not our greatest threat", localU)); u += localU; } else { double localU = -World.staticMap.param.utility_greatestThreatDelta; msgs.Add(new ReasonMsg("Dark Agents are our greatest threat", localU)); u += localU; } } if (option.index == EXPELL_ALL_FOREIGN_AGENTS) { responseLevelMin = 75; responseLevelMax = 100; double n = 0; foreach (Unit unit in society.map.units) { if (unit.society == society) { continue; } if (society.enemies.Contains(unit) == false) { n += 1; } } if (n > 0) { msgs.Add(new ReasonMsg("So many potential enemies!", concernLevel)); u += concernLevel; } } if (option.index == LOCKDOWN_PROVINCE) { responseLevelMin = 40; responseLevelMax = 100; int evidenceFound = 0; foreach (Evidence ev in foundEvidence) { if (ev.locationFound.province.index == option.province) { evidenceFound += 1; } } double localU = World.staticMap.param.utility_defendEvidenceProvince * evidenceFound * (1 - p.shadow); msgs.Add(new ReasonMsg("Amount of evidence found in " + society.map.provinces[option.province].name + " province", localU)); u += localU; localU = 0; foreach (Person person in society.people) { if (person.getLocation() != null && person.getLocation().province.index == option.province) { localU += p.getRelation(person.index).getLiking() * World.staticMap.param.utility_agentDefendProvinceLikingMult; } } string add = "" + (int)(localU); msgs.Add(new ReasonMsg("Liking for nobles in province" + add, localU)); u += localU; if (p.getLocation().province.index != option.province) { localU = p.getSelfInterest() * p.threat_agents.threat * World.staticMap.param.utility_selfInterestFromThreat; if (localU != 0) { msgs.Add(new ReasonMsg("Does not help me personally", localU)); u += localU; } } else { localU = -1 * p.getSelfInterest() * p.threat_agents.threat * World.staticMap.param.utility_selfInterestFromThreat; if (localU != 0) { msgs.Add(new ReasonMsg("Helps me personally", localU)); u += localU; } } } if (option.index == AGENT_TO_INVESTIGATOR) { responseLevelMin = 0; responseLevelMax = 100; Unit_Investigator inv = (Unit_Investigator)option.unit; double localU = Unit_Investigator.getSwitchUtility(p, (Unit_Investigator)option.unit, Unit_Investigator.unitState.investigator); localU *= p.map.param.utility_swapAgentRolesMult; msgs.Add(new ReasonMsg("Balance of agent skills vs balance of threats", localU)); u += localU; bool hasSuspicions = false; foreach (RelObj rel in inv.person.relations.Values) { if (inv.location.map.persons[rel.them] == null) { continue; } if (rel.suspicion > 0 && inv.location.map.persons[rel.them].unit != null && inv.location.map.units.Contains(inv.location.map.persons[rel.them].unit)) { hasSuspicions = true; } } if (hasSuspicions) { localU = 12; msgs.Add(new ReasonMsg("Has a suspect", localU)); u += localU; } } if (option.index == AGENT_TO_BASIC) { responseLevelMin = 0; responseLevelMax = 100; double localU = Unit_Investigator.getSwitchUtility(p, (Unit_Investigator)option.unit, Unit_Investigator.unitState.basic); localU *= p.map.param.utility_swapAgentRolesMult; msgs.Add(new ReasonMsg("Balance of agent skills vs balance of threats", localU)); u += localU; } if (concernLevel > responseLevelMax) { double delta = responseLevelMax - concernLevel; delta *= society.map.param.utility_extremeismScaling; double localU = delta; msgs.Add(new ReasonMsg("Too weak response for current concern level (" + (int)(concernLevel) + "%)", localU)); u += localU; } if (concernLevel < responseLevelMin) { double delta = concernLevel - responseLevelMin; delta *= society.map.param.utility_extremeismScaling; double localU = delta; msgs.Add(new ReasonMsg("Too extreme for current concern level (" + (int)(concernLevel) + "%)", localU)); u += localU; } return(u); }
public override void castInner(Map map, Person person) { cast(map, person.getLocation().hex); }