Beispiel #1
0
 public void logVote(VoteIssue issue)
 {
     if (World.logging)
     {
         string line = "  " + issue.ToString() + " for soc " + issue.society.getName();
         log.takeLine(line);
         foreach (VoteOption opt in issue.options)
         {
             line  = "     " + opt.fixedLenInfo();
             line += " U " + Eleven.toFixedLen(issue.computeUtility(this, opt, new List <ReasonMsg>()), 12);
             log.takeLine(line);
         }
     }
 }
Beispiel #2
0
        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);
        }