public VoteOption getVote(VoteSession voteSession) { double highestWeight = 0; VoteOption bestChoice = null; foreach (VoteOption option in voteSession.issue.options) { List <ReasonMsg> msgs = new List <ReasonMsg>(); double u = voteSession.issue.computeUtility(this, option, msgs); if (forcedVoteSession == voteSession && option == forcedVoteOption) { ReasonMsg msg = new ReasonMsg("Obligated to vote for this option", 0); msgs.Add(msg); } if (u > highestWeight || bestChoice == null) { bestChoice = option; highestWeight = u; } } if (this.forcedVoteSession == voteSession) { return(forcedVoteOption); } return(bestChoice); }
public override void castInner(Map map, Unit u) { Unit_HeadlessHorseman head = (Unit_HeadlessHorseman)u; Society soc = (Society)u.location.soc; VoteIssue_JudgeSuspect issue = new VoteIssue_JudgeSuspect(soc, u.location.person(), u.location.person()); VoteSession session = new VoteSession(); session.issue = issue; soc.voteSession = session; VoteOption option_0 = new VoteOption(); option_0.index = 0; issue.options.Add(option_0); VoteOption option_1 = new VoteOption(); option_1.index = 1; issue.options.Add(option_1); session.timeRemaining = map.param.society_votingDuration; issue.reluctanceModifier = 0.66; string add = ""; if (u.location.person().shadow <= 0.3 && u.location.person().state == Person.personState.normal) { add = "\nAs they are innocent, their head will become a pumpkin the horseman can gather."; } u.location.map.world.prefabStore.popImgMsg("A trial has begun. " + u.location.person().getFullName() + " is facing judgement. If you can convince enough nobles to vote guilty they will be beheaded." + add, u.location.map.world.wordStore.lookup("ABILITY_HEADLESS_BEGIN_TRIAL"), img: 3); }
public double getLikingDelta(Person p, VoteOption option, VoteIssue issue) { if (issue.options.Count < 2) { return(0); } //Special case voting if (issue is VoteIssue_AssignTitle) { bool votedForSelf = false; foreach (VoteOption opt in issue.options) { if (opt.person == p && opt.votesFor.Contains(p)) { //I voted for myself votedForSelf = true; } } if (votedForSelf) { if (option.person != p) { //Didn't vote for me! Loathesome! return(p.map.param.person_dislikeFromNotBeingVotedFor); } } } double utility = computeUtility(p, option, new List <ReasonMsg>()); double deltaRel = utility; if (deltaRel > 0) { deltaRel *= p.map.param.person_votingRelChangePerUtilityPositive; } else { deltaRel *= p.map.param.person_votingRelChangePerUtilityNegative; } if (deltaRel > p.map.param.person_maxLikingGainFromVoteAccordance) { deltaRel = p.map.param.person_maxLikingGainFromVoteAccordance; } if (deltaRel < p.map.param.person_maxLikingLossFromVoteDiscord) { deltaRel = p.map.param.person_maxLikingLossFromVoteDiscord; } if (deltaRel < 0) { //You can't hate someone for voting the same way you did, that's just nuts. if (option.votesFor.Contains(p)) { deltaRel = 0; } } return(deltaRel); }
public override void implement(VoteOption option) { base.implement(option); if (option.index == 1) { bool canVassalise = false; Society receiever = (Society)target; List <Location> trans = new List <Location>(); foreach (Location loc in society.map.locations) { if (loc.soc == society) { trans.Add(loc); } if (loc.soc == target && loc.settlement != null) { canVassalise = true; } } if (canVassalise) { World.log(society.getName() + " VASSALISES UNDER " + target.getName()); society.map.turnMessages.Add(new MsgEvent(society.getName() + " vassalises under " + target.getName() + ", transferring all lands and landed nobles.", MsgEvent.LEVEL_RED, true)); foreach (Location loc in trans) { receiever.map.takeLocationFromOther(receiever, society, loc); } } } }
public override void implement(VoteOption option) { base.implement(option); society.lastNobleCrisis = society.map.turn; society.crisisNobles = false; foreach (Evidence ev in foundEvidence) { society.handledEvidence.Add(ev); } if (option.index == WITCH_HUNT) { society.crisisWitchHunt = true; } if (option.index == AGENT_TO_INQUISITOR) { Unit_Investigator inv = (Unit_Investigator)option.unit; inv.changeState(Unit_Investigator.unitState.inquisitor); World.self.prefabStore.popMsgAgent(option.unit, option.unit, option.unit.getName() + " has been assigned the role of Inquisitor, by the nobles of " + option.unit.society.getName() + " in response to external threats. Inquisitors are experts at combatting your finding enthralled, enshadowed, broken or corrupt nobles."); } if (option.index == AGENT_TO_BASIC) { Unit_Investigator inv = (Unit_Investigator)option.unit; inv.changeState(Unit_Investigator.unitState.basic); if (inv.person.isWatched()) { World.self.prefabStore.popMsgAgent(option.unit, option.unit, option.unit.getName() + " has been assigned the role of Agent, by the nobles of " + option.unit.society.getName() + " in response to external threats. Standard agents are general-purpose units. They can investigate your agents' evidence, and can assist in wars. They can be promoted " + " to specalists by vote."); } } }
public void changeLikingForVotes(VoteOption option) { //Everyone affected/concerned about the vote now changes their opinion of all the voters for the winning option //depending on how much they care and how much they were affected foreach (Person p in society.people) { double utility = computeUtility(p, option, new List <ReasonMsg>()); double deltaRel = utility; if (deltaRel > 0) { deltaRel *= p.map.param.society_votingRelChangePerUtilityPositive; } else { deltaRel *= p.map.param.society_votingRelChangePerUtilityNegative; } if (deltaRel > p.map.param.person_maxLikingGainFromVoteAccordance) { deltaRel = p.map.param.person_maxLikingGainFromVoteAccordance; } if (deltaRel < p.map.param.person_maxLikingLossFromVoteDiscord) { deltaRel = p.map.param.person_maxLikingLossFromVoteDiscord; } foreach (Person voter in option.votesFor) { p.getRelation(voter).addLiking(deltaRel, "Vote on issue " + this.ToString(), society.map.turn); } } }
public virtual void implement(VoteOption option) { bool positive = true; int priority = (society.hasEnthralled()) ? 1 : 3; string msg = society.getName() + ": chose " + option.info(this) + " for " + this.ToString(); World.staticMap.addMessage(msg, priority, positive, society.getCapitalHex()); bool proposerPassed = false; foreach (Person p in option.votesFor) { if (option.votesFor.Contains(p)) { proposerPassed = true; } } if (proposerPassed) { proposer.prestige += World.staticMap.param.society_prestigeFromVotingSuccess; } else { proposer.prestige += World.staticMap.param.society_prestigeFromVotingFailure; if (proposer.prestige < 0) { proposer.prestige = 0; } } }
public void changeLikingForVotes(VoteOption option, VoteIssue issue) { if (issue.options.Count < 2) { return; } //No reason to hate someone for voting for the only permitted option //Everyone affected/concerned about the vote now changes their opinion of all the voters for the winning option //depending on how much they care and how much they were affected foreach (Person p in society.people) { double deltaRel = getLikingDelta(p, option, issue); if (issue.proposer == p && (option.votesFor.Contains(p) == false)) { foreach (Person voter in option.votesFor) { p.getRelation(voter).addLiking(society.map.param.society_dislikeFromFailedProposal, "Did not vote on my proposed measure " + this.ToString(), society.map.turn, RelObj.STACK_NONE); } } foreach (Person voter in option.votesFor) { p.getRelation(voter).addLiking(deltaRel, "Vote on issue " + this.ToString(), society.map.turn, RelObj.STACK_REPLACE); } } }
public override void implement(VoteOption option) { base.implement(option); society.crisisWarLong = null; society.crisisWarShort = null; society.lastEvidenceResponse = society.map.turn; if (option.index == AGENT_TO_KNIGHT) { Unit_Investigator inv = (Unit_Investigator)option.unit; inv.changeState(Unit_Investigator.unitState.knight); if (inv.person.isWatched()) { World.self.prefabStore.popMsgAgent(option.unit, option.unit, option.unit.getName() + " has been assigned the role of Knight, by the nobles of " + option.unit.society.getName() + " in response to external threats. Knights are combat specialists, who grant bonuses to nearby military units' damage (both attacking and defending)."); } } if (option.index == AGENT_TO_BASIC) { Unit_Investigator inv = (Unit_Investigator)option.unit; inv.changeState(Unit_Investigator.unitState.basic); if (inv.person.isWatched()) { World.self.prefabStore.popMsgAgent(option.unit, option.unit, option.unit.getName() + " has been assigned the role of Agent, by the nobles of " + option.unit.society.getName() + " in response to external threats. Standard agents are general-purpose units. They can investigate your agents' evidence, and can assist in wars. They can be promoted " + " to specalists by vote."); } } }
public override void implement(VoteOption option) { if (society.people.Contains(option.person) == false) { World.log("Invalid option. Person cannot hold title."); return; } base.implement(option); if (title.heldBy == option.person) { World.log("Title: " + title.getName() + " remains held by " + option.person.getFullName()); } //Title already has a person if (title.heldBy != null) { World.log(title.heldBy.getFullName() + " is losing title " + title.getName()); title.heldBy.titles.Remove(title); title.heldBy = null; } World.log(option.person.getFullName() + " has been granted the title of " + title.getName()); title.heldBy = option.person; option.person.titles.Add(title); society.turnSovreignAssigned = society.map.turn; title.turnLastAssigned = society.map.turn; }
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_KNIGHT) { double localU = Unit_Investigator.getSwitchUtility(p, (Unit_Investigator)option.unit, Unit_Investigator.unitState.knight); 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; } return(u); }
public override double computeUtility(Person voter, VoteOption option, List <ReasonMsg> msgs) { double u = option.getBaseUtility(voter); //Option 1 is "Kill suspect" //Multiply values based on this, as they should be symmetric for most parts double parityMult = 1; if (option.index == 0) { parityMult = -1; } RelObj rel = voter.getRelation(option.person); double apathy = (1 - voter.shadow); /* * This is actually already covered by liking, but caps out at 100. This adds another bonus, purely from suspicion */ double proKill = rel.suspicion * apathy * voter.map.param.utility_killSuspectFromSuspicion * parityMult; msgs.Add(new ReasonMsg("Suspicion towards " + option.person.getFullName(), proKill)); u += proKill; //double reluctance = -voter.map.param.utility_killSuspectRelucatance* parityMult * reluctanceModifier; //msgs.Add(new ReasonMsg("Base reluctance to kill noble", reluctance)); //u += reluctance; double liking = -rel.getLiking() * parityMult; msgs.Add(new ReasonMsg("Opinion of " + option.person.getFullName(), liking)); u += liking; return(u); }
public override double computeUtility(Person voter, VoteOption option, List <ReasonMsg> msgs) { double u = option.getBaseUtility(voter); double localU = 0; if (option.group == null) { //Null case is "remain independent" localU = -voter.map.param.utility_vassaliseReluctance; msgs.Add(new ReasonMsg("Inherent reluctance", localU)); u += localU; return(u); } localU = voter.map.param.utility_vassaliseReluctance; msgs.Add(new ReasonMsg("Inherent reluctance", localU)); u += localU; Society socTarget = (Society)option.group; foreach (KillOrder order in socTarget.killOrders) { if (order.person == voter) { localU = -1000; msgs.Add(new ReasonMsg("Kill order against " + voter.getFullName(), localU)); u += localU; } } double awarenessU = society.map.param.utility_lightAllianceMult * voter.awareness; msgs.Add(new ReasonMsg("Awareness", awarenessU)); u += awarenessU; double militaryU = option.group.currentMilitary - voter.society.currentMilitary; militaryU *= society.map.param.utility_lightAllianceMilMult * voter.awareness; msgs.Add(new ReasonMsg("Their military might", militaryU)); u += militaryU; double totalSuspicion = 0; foreach (Person p in socTarget.people) { RelObj rel = voter.getRelation(p); totalSuspicion += rel.suspicion; } double susU = -totalSuspicion; susU *= society.map.param.utility_lightAlliancSusMult; msgs.Add(new ReasonMsg("Suspicion of their nobles", susU)); u += susU; return(u); }
public void SetInfo(VoteOption v) { foreground.sprite = votesIcon; background.enabled = false; nameTxt.text = "For " + v.info(); infoTxt.text = v.votingWeight + " Influence"; }
public PopOptBar getVoteOptBar(VoteOption opt, VoteSession sess) { GameObject obj = Instantiate(prefabPopOptBar) as GameObject; PopOptBar part = obj.GetComponent <PopOptBar>(); part.setTo(opt, sess); return(part); }
public override void implement(VoteOption option) { base.implement(option); EconEffect effect = new EconEffect(society.map, option.econ_from, option.econ_to); World.log(society.getName() + " implements economic policy, moving focus from " + option.econ_from.name + " to " + option.econ_to.name); society.econEffects.Add(effect); }
public virtual void implement(VoteOption option) { bool positive = true; int priority = (society.hasEnthralled()) ? 1 : 3; string msg = society.getName() + ": chose " + option.info(this) + " for " + this.ToString(); World.staticMap.addMessage(msg, priority, positive); }
public override void implement(VoteOption option) { base.implement(option); if (option.index == 1 && society.posture == Society.militaryPosture.offensive) { society.map.declareWar(society, target); } }
public void checkData() { sess.assignVoters(); textVoterName.text = "Voter: " + voterBars[0].voter.getFullName(); textVPower.text = "" + (int)(world.map.overmind.power); if (agent != null) { textVLiking.text = "" + (int)voterBars[0].voter.getRelation(agent).getLiking(); } else { textVLiking.text = "N/A"; } double uSel = sess.issue.computeUtility(voterBars[0].voter, voteOptBars[0].opt, new List <ReasonMsg>()); double uCurr = sess.issue.computeUtility(voterBars[0].voter, voterBars[0].voter.getVote(sess), new List <ReasonMsg>()); textVoterUtility.text = "Opinion of selected option: " + (int)uSel; textVoterCurrUtility.text = "Opinion of their current option: " + (int)uCurr; if (voterBars[0].voter.state != Person.personState.enthralled && voterBars[0].voter.getVote(sess) != voteOptBars[0].opt) { double utilityDelta = uCurr - uSel; if (utilityDelta < 0) { utilityDelta = 0; } textSwitchCostPower.text = "" + (int)((utilityDelta * world.map.param.voting_powerToSwitchPerU) + world.map.param.voting_powerToSwitchMin); textSwitchCostLiking.text = "" + (int)((utilityDelta * world.map.param.voting_likingToSwitchPerU) + world.map.param.voting_likingToSwitchMin); switchLiking.gameObject.SetActive(true); switchPower.gameObject.SetActive(true); } else { textSwitchCostPower.text = "N/A"; textSwitchCostLiking.text = "N/A"; switchLiking.gameObject.SetActive(false); switchPower.gameObject.SetActive(false); } foreach (PopVoterBar bar in voterBars) { bar.checkData(); } double highest = voteOptBars[0].opt.votingWeight; VoteOption winner = voteOptBars[0].opt; for (int i = 1; i < voteOptBars.Count; i++) { if (voteOptBars[i].opt.votingWeight > highest) { highest = voteOptBars[i].opt.votingWeight; winner = voteOptBars[i].opt; } } textWinningOpt.text = winner.info(sess.issue); }
public PopupBoxVote getVoteBox(VoteSession sess, VoteOption option) { GameObject obj = Instantiate(voteBox) as GameObject; PopupBoxVote specific = obj.GetComponent <PopupBoxVote>(); specific.setTo(sess, option); return(specific); }
public override void implement(VoteOption option) { if (society.people.Contains(option.person) == false) //World.log("Invalid option. Person cannot hold title."); { return; } base.implement(option); society.turnSovereignAssigned = society.map.turn; title.turnLastAssigned = society.map.turn; Person incumbent = title.heldBy; if (title.heldBy == option.person) { //World.log("Title: " + title.getName() + " remains held by " + option.person.getFullName()); } else { //Title already has a person if (title.heldBy != null) { //World.log(title.heldBy.getFullName() + " is losing title " + title.getName()); title.heldBy.titles.Remove(title); title.heldBy = null; } if (title == society.sovereign) { society.addHistory("#GLD_" + title.getName() + " title now held by " + option.person.getFullName()); } } //Clear all titles, assign this new one foreach (Title t in option.person.titles) { if (t != title) { if (incumbent != null && option.person != incumbent) { t.heldBy = incumbent; incumbent.titles.Add(t); } else { t.heldBy = null; } if (t.society.hasEnthralled()) { t.society.map.addMessage("Title: " + t.getName() + " is now reassigned", 1, false, t.society.getCapitalHex()); } } } option.person.titles.Clear(); //World.log(option.person.getFullName() + " has been granted the title of " + title.getName()); title.heldBy = option.person; option.person.titles.Add(title); }
public PopupXBoxThreat getVoteReasonBox(VoteIssue vi, VoteOption vo, Person p) { GameObject obj = Instantiate(xBoxThreat) as GameObject; PopupXBoxThreat specific = obj.GetComponent <PopupXBoxThreat>(); specific.setTo(vi, vo, p); specific.body = "The available vote options and the reasons behind each choice."; return(specific); }
public override double computeUtility(Person voter, VoteOption option, List <ReasonMsg> msgs) { double u = option.getBaseUtility(voter); RelObj rel = voter.getRelation(option.person); double liking = -rel.getLiking() * World.staticMap.param.utility_dismissFromCourt; msgs.Add(new ReasonMsg("Opinion of " + option.person.getFullName(), liking)); u += liking; return(u); }
public override void implement(VoteOption option) { base.implement(option); Person target = option.person; bool isGood = (target.state != Person.personState.enthralled) && (target.state != Person.personState.broken) && (target.shadow < 0.5); society.map.turnMessages.Add(new MsgEvent(society.getName() + " has voted to dismiss " + target.getFullName() + " from court.", MsgEvent.LEVEL_RED, isGood)); World.log("Dismiss from court"); //World.staticMap.world.prefabStore.popMsg("Dismiss from court " + option.person.getFullName()); option.person.removeFromGame("Dismissed from court"); }
public void setTo(VoteSession session, VoteOption option) { //title.text = session.issue.ToString(); title.text = option.info(session.issue); body.text = "Voters: " + option.votesFor.Count + " Total Prestige: " + (int)(option.votingWeight); if (option.votesFor.Contains(World.staticMap.overmind.enthralled)) { body.text += "\n[Your enthralled is voting for this option]"; } this.option = option; this.sess = session; this.sess.assignVoters(); }
public override void implement(VoteOption option) { base.implement(option); society.crisisWitchHunt = false; KillOrder order = new KillOrder(option.person, "Judged guilty of conspiracy with dark forces"); order.votedByNobles = true; society.killOrders.Add(order); bool isGood = (option.person.state != Person.personState.enthralled) && (option.person.state != Person.personState.broken) && (option.person.shadow < 0.5); society.map.turnMessages.Add(new MsgEvent(society.getName() + " has voted to execute " + option.person.getFullName() + ", having judged them guilty of conspiracy with dark forces", MsgEvent.LEVEL_RED, isGood)); World.log("EXECUTION ORDER GONE THROUGH FOR SUSPICION OF DARKNESS " + society.getName() + " " + option.person.getFullName() + " true shadow (" + option.person.shadow + ")"); }
public override void implement(VoteOption option) { base.implement(option); SocialGroup prev = society.offensiveTarget; society.offensiveTarget = option.group; society.cooldownLastOffTargetSwitch = society.map.turn; if (option.group is Society && prev != option.group) { Society vic = (Society)option.group; vic.crisisWarShort = "Crisis: War Threatens"; vic.crisisWarLong = society.getName() + " has set our society as their offensive target, a probable prelude to invasion. We must prepare outselves for war."; } }
public override void implement(VoteOption option) { base.implement(option); if (option.index == 1) { society.map.world.prefabStore.popMsg(society.getName() + " Found " + target.getName() + " guilty and condemned them. Their agents can now attack " + target.getName() + "," + " and " + target.getName() + " will take damage each turn they are in the nation's borders."); society.enemies.Add(target); } else { World.log("Failure to find guilty " + target.getName()); } }
public override void implement(VoteOption option) { if (society.people.Contains(option.person) == false) //World.log("Invalid option. Person cannot hold title."); { return; } if (title.settlement == null) { return; } if (title.settlement.location.settlement != title.settlement) { return; } //It was removed before we arrived base.implement(option); if (title.heldBy == option.person) { //World.log("Title: " + title.getName() + " remains held by " + option.person.getFullName()); } //Person already has a title if (option.person.title_land != null) { TitleLanded prev = option.person.title_land; prev.heldBy = null; option.person.title_land = null; //World.log(prev.getName() + " has lost its lord as they have been reassigned"); } //Title already has a person if (title.heldBy != null) { //World.log(title.heldBy.getFullName() + " is losing title " + title.getName()); title.heldBy.title_land = null; title.heldBy = null; } //World.log(option.person.getFullName() + " has been granted the title of " + title.getName()); title.heldBy = option.person; title.settlement.infiltration = 0; option.person.title_land = title; if (title.settlement != null) { title.settlement.lastAssigned = title.settlement.location.map.turn; } }
public override void implement(VoteOption option) { base.implement(option); if (option.index == 0) { society.posture = Society.militaryPosture.defensive; } else if (option.index == 1) { society.posture = Society.militaryPosture.offensive; } else if (option.index == 2) { society.posture = Society.militaryPosture.introverted; } }