public IParty MakeGParty() { var billAttitudeMap = new Dictionary <IBill, VoteResult>(); VoteResult raiseResidentTax = new VoteResult(10, 80, 10); VoteResult reduceResidentTax = new VoteResult(80, 10, 10); VoteResult raiseCommercialTax = new VoteResult(40, 50, 10); VoteResult reduceCommercialTax = new VoteResult(50, 40, 10); VoteResult raiseIndustryTax = new VoteResult(50, 50, 0); VoteResult reduceIndustryTax = new VoteResult(50, 50, 0); VoteResult raiseBenefitOffset = new VoteResult(70, 20, 10); VoteResult reduceBenefitOffset = new VoteResult(20, 70, 10); billAttitudeMap.Add(Bills.RiseResidentTax, raiseResidentTax); billAttitudeMap.Add(Bills.ReduceResidentTax, reduceResidentTax); billAttitudeMap.Add(Bills.RiseCommercialTax, raiseCommercialTax); billAttitudeMap.Add(Bills.ReduceCommercialTax, reduceCommercialTax); billAttitudeMap.Add(Bills.RiseIndustryTax, raiseIndustryTax); billAttitudeMap.Add(Bills.ReduceIndustryTax, reduceIndustryTax); billAttitudeMap.Add(Bills.RiseBenefit, raiseBenefitOffset); billAttitudeMap.Add(Bills.ReduceResidentTax, reduceBenefitOffset); IParty party = new Party( "GREEN", this.NextPartyId++, PartyType.Green, new PartyInterestData( new byte[4] { 0, 10, 20, 25 }, new byte[15] { 0, 20, 10, 15, 20, 30, 10, 0, 5, 10, 5, 30, 35, 40, 50, }, new byte[3] { 0, 10, 30 }, new byte[3] { 20, 15, 10 }, new byte[2] { 10, 15 } ), billAttitudeMap ); return(party); }
public IParty MakeNParty() { var billAttitudeMap = new Dictionary <IBill, VoteResult>(); VoteResult raiseResidentTax = new VoteResult(35, 55, 10); VoteResult reduceResidentTax = new VoteResult(55, 35, 10); VoteResult raiseCommercialTax = new VoteResult(45, 45, 100); VoteResult reduceCommercialTax = new VoteResult(45, 45, 10); VoteResult raiseIndustryTax = new VoteResult(30, 70, 0); VoteResult reduceIndustryTax = new VoteResult(70, 30, 0); VoteResult raiseBenefitOffset = new VoteResult(30, 60, 10); VoteResult reduceBenefitOffset = new VoteResult(60, 30, 10); billAttitudeMap.Add(Bills.RiseResidentTax, raiseResidentTax); billAttitudeMap.Add(Bills.ReduceResidentTax, reduceResidentTax); billAttitudeMap.Add(Bills.RiseCommercialTax, raiseCommercialTax); billAttitudeMap.Add(Bills.ReduceCommercialTax, reduceCommercialTax); billAttitudeMap.Add(Bills.RiseIndustryTax, raiseIndustryTax); billAttitudeMap.Add(Bills.ReduceIndustryTax, reduceIndustryTax); billAttitudeMap.Add(Bills.RiseBenefit, raiseBenefitOffset); billAttitudeMap.Add(Bills.ReduceResidentTax, reduceBenefitOffset); IParty party = new Party( "NATIONAL", this.NextPartyId++, PartyType.National, new PartyInterestData( new byte[4] { 50, 25, 10, 5 }, new byte[15] { 35, 0, 20, 10, 0, 0, 35, 50, 30, 15, 25, 10, 5, 0, 0, }, new byte[3] { 30, 10, 15 }, new byte[3] { 15, 20, 25 }, new byte[2] { 10, 5 } ), billAttitudeMap ); return(party); }
public void Start() { VoteResult r = new VoteResult(); int seatCount = this.gov.AllSeatCount; int resiTaxOffset = 10 - (Politics.residentTax); int commTaxOffset = 10 - (Politics.commercialTax); int induTaxOffset = 10 - (Politics.industryTax); int beneOffset = 10 - (Politics.benefitOffset / 5); int moneyOffset = 0; // money offset int citizenOffset = 0; // citizen offset int industrialBuildingOffset = 0; //industrial building offset int commercialBuildingOffset = 0; //commercial building offset VoteOffset(ref moneyOffset, ref citizenOffset, ref industrialBuildingOffset, ref commercialBuildingOffset); r.AppendChange( +this.parties.Sum(p => p.BillAttitudes[this.Bill].Agree), +this.parties.Sum(p => p.BillAttitudes[this.Bill].Disagree), +this.parties.Sum(p => p.BillAttitudes[this.Bill].Neutral) ); // offset the value of agree by the class of IBill // bad codes if (this.Bill is RiseResidentTaxBill) { //agree += resiTaxOffset * this.parties.Length; //agree -= moneyOffset; //agree -= citizenOffset; //disagree -= resiTaxOffset * this.parties.Length; r.AppendChange( +(resiTaxOffset * this.parties.Length - moneyOffset - citizenOffset), -(resiTaxOffset * this.parties.Length) ); } else if (this.Bill is ReduceResidentTaxBill) { //agree -= resiTaxOffset * this.parties.Length; //agree += moneyOffset; //agree += citizenOffset; //disagree += resiTaxOffset * this.parties.Length; r.AppendChange( -(resiTaxOffset * this.parties.Length - moneyOffset - citizenOffset), +(resiTaxOffset * this.parties.Length) ); } else if (this.Bill is RiseCommercialTaxBill) { //agree += commTaxOffset * this.parties.Length; //agree -= moneyOffset; //agree += commercialBuildingOffset; //disagree -= commTaxOffset * this.parties.Length; r.AppendChange( +(commTaxOffset * this.parties.Length - moneyOffset + commercialBuildingOffset), -(resiTaxOffset * this.parties.Length) ); } else if (this.Bill is ReduceCommercialTaxBill) { //agree -= commTaxOffset * this.parties.Length; //agree += moneyOffset; //agree -= commercialBuildingOffset; //disagree += commTaxOffset * this.parties.Length; r.AppendChange( -(commTaxOffset * this.parties.Length - moneyOffset + commercialBuildingOffset), +(resiTaxOffset * this.parties.Length) ); } else if (this.Bill is RiseIndustryTaxBill) { //agree += induTaxOffset * this.parties.Length; //agree -= moneyOffset; //agree += industrialBuildingOffset; //disagree -= induTaxOffset * this.parties.Length; r.AppendChange( +(induTaxOffset * this.parties.Length - moneyOffset + industrialBuildingOffset), -(induTaxOffset * this.parties.Length) ); } else if (this.Bill is ReduceIndustryTaxBill) { //agree -= induTaxOffset * this.parties.Length; //agree += moneyOffset; //agree -= industrialBuildingOffset; //disagree += induTaxOffset * this.parties.Length; r.AppendChange( -(induTaxOffset * this.parties.Length - moneyOffset + industrialBuildingOffset), +(induTaxOffset * this.parties.Length) ); } else if (this.Bill is RiseBenefitBill) { //agree += beneOffset * this.parties.Length; //agree += moneyOffset; //disagree -= beneOffset * this.parties.Length; r.AppendChange( +(beneOffset * this.parties.Length + moneyOffset), -(beneOffset * this.parties.Length) ); } else if (this.Bill is ReduceBenefitBill) { //agree -= beneOffset * this.parties.Length; //agree -= moneyOffset; //disagree += beneOffset * this.parties.Length; r.AppendChange( -(beneOffset * this.parties.Length + moneyOffset), +(beneOffset * this.parties.Length) ); } this.VoteResult = r; }
public bool IsVoteResultApprovable(VoteResult voteResult) { return(voteResult.Agree >= (voteResult.Sum >> 1)); }