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 virtual double getThreat(List <ReasonMsg> reasons) { ReasonMsg msg; double threat = 5; if (reasons != null) { msg = new ReasonMsg("Base", 5); reasons.Add(msg); } threat += (currentMilitary + (maxMilitary / 2)) * 0.2; if (reasons != null) { msg = new ReasonMsg("Current Military", currentMilitary * 0.2); reasons.Add(msg); msg = new ReasonMsg("Max Military", (maxMilitary / 2) * 0.2); reasons.Add(msg); } if (this.threat_mult != 0) { int percent = (int)(100 * this.threat_mult); double addT = threat * this.threat_mult; threat += addT; if (reasons != null) { string sign = addT > 0 ? "+" : "";//An advanced programing thingy to make Wyatt think I know how to program msg = new ReasonMsg(sign + percent + "% from type", addT); reasons.Add(msg); } } threat += temporaryThreat; if (reasons != null) { msg = new ReasonMsg("Temporary Threat", temporaryThreat); reasons.Add(msg); } //threat += permanentThreat; //if (reasons != null) //{ // msg = new ReasonMsg("Permanent Threat", permanentThreat); // reasons.Add(msg); //} return(threat); }
public VoteOption getVote(VoteSession voteSession) { if (World.logging) { this.log.takeLine("Voting on " + voteSession.issue); } 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 (World.logging) { log.takeLine(" " + option.fixedLenInfo() + " " + u); foreach (ReasonMsg msg in msgs) { log.takeLine(" " + Eleven.toFixedLen(msg.value, 5) + msg.msg); } } } if (this.forcedVoteSession == voteSession) { World.log("Forced voting"); return(forcedVoteOption); } return(bestChoice); }