Example #1
0
 def didvote(self, issue):
     self.opinion = self.getOpinionOn(issue)
     if self.public:
         return not srandom.randint(
             -10, 0) < self.opinion < srandom.randint(1, 10)
     else:
         return not srandom.randint(-1, 0) < self.opinion < srandom.randint(
             1, 5)
Example #2
0
 def __init__(self, name, topic, fund, effects, outrage=None):
     'a gov program, possibly more than 1 per topic'
     self.name = name
     self.topic = topic
     self.annualFund = fund
     self.outrageThreshold = outrage if outrage else srandom.randint(10, 70)
     self.effects = effects
Example #3
0
    def doPolitk(self, topic, degree):
        'bribe with money, political cap, or a rider bill'
        politiks = 'money pc rider'.split(' ')
        p = srandom.choice(politiks)
        message = p + ' '
        bribe = None
        if p == 'money':
            bribe = srandom.randint(1, 5) * abs(degree)
            message += str(bribe)
        elif p == 'pc':
            bribe = srandom.randint(1, 5) * abs(degree)
            message += str(bribe)
        elif p == 'rider':
            # TODO check bribe_topic:amount is not less in magnitude than bill
            print self.programs['Discretionary'].keys()
            bribe_topic = srandom.choice(self.itbounds.keys())
            while bribe_topic in self.bill:
                bribe_topic = srandom.choice(self.itbounds.keys())
            bribe_amount = srandom.randint(1, 4) * abs(degree)
            message += bribe_topic + ' with ' + str(bribe_amount)
        else:
            raise ValueError('not a valid political move')
        answer = 'c'
        while answer != 'y' and answer != 'n':
            answer = raw_input('Spend ' + message + '? y/n\n> ')

        if answer == 'y':
            if p == 'money' and self.darkmoney > bribe:
                self.darkmoney -= bribe
            elif p == 'pc' and self.politicalcapital > bribe:
                self.politicalcapital -= bribe
            elif p == 'rider':
                if not self.senate.bill:
                    self.senate.bill = {}
                for pref in self.programs['Discretionary'][bribe_topic][
                        'effects']:
                    if pref in self.senate.bills:
                        self.senate.bill[pref] += bribe_amount
                    else:
                        self.senate.bill[pref] = bribe_amount
            else:
                print 'cant follow through on politk'
                return False  # if can't do any of the following
            return True
        else:
            return False
Example #4
0
def spin():
    spinner = spinning_cursor()
    period = srandom.randint(1, 6) * 5
    print 'working... ',
    for _ in range(period):
        sys.stdout.write(spinner.next())
        sys.stdout.flush()
        time.sleep(0.1)
        sys.stdout.write('\b')
    print ''
Example #5
0
 def __init__(self, itb=itbounds, kv=None, public=True):
     super(Citizen, self).__init__(itb, kv)  # Issue.__init__(self)
     self.public = public
     self.productivity = srandom.randint(1, 10)
     self.health = srandom.randint(4, 10)
     self.belly = srandom.randint(0, 10)  # == 1 - hunger
     self.privacy = srandom.randint(0, 10)  # 10 cares a lot about privacy
     self.wealth = srandom.randint(0, 1000)
     self.income = srandom.randint(0, 140)  # $71k average income
     # todo retirees...
     self.wealth = srandom.randint(0, 10)
Example #6
0
 def __init__(self, itb=itbounds, kv=None):
     self.topics = {}
     self.threshold = 0  # could be tweaked based on hate against gov
     if kv:
         # self.topics = dict.fromkeys(self.topics, 0)  # reset entries to 0
         for k, v in kv.items():
             self.topics[k] = v
     else:
         for topic, b in itb.items():
             self.topics[topic] = srandom.randint(b[0], b[1])
             # TODO: try numpy bimodal distribution (some how? multivariate? mix normal?)
             # or just make up my own distribution with this:
             # np.random.choice(ny.arange(1, 7), p=[0.1, 0.05, 0.05, 0.2, 0.4, 0.2])
         return
Example #7
0
 def didvote(self, topics):
     'simulates voter suppression or voter apathy'
     self.opinion = self.getOpinionOn(topics)
     return not srandom.randint(-10, 0) < self.opinion < srandom.randint(
         1, 10)