def create_agent(self, status): """ Create a new agent with the given status :param status: a value of agents.Status enum :return: the newly created agent """ x, y = self.random_position() age = int(np.random.beta(2, 5, 1) * 100) social_stratum = int(np.random.rand(1) * 100 // 20) # modify if age <= 40: s = ['h', 'h', 'h', 'h', 'h', 'h', 'r', 'd'] health = np.random.choice(s) elif age > 40 and age <= 60: s = ['h', 'h', 'h', 'h', 'r', 'd'] health = np.random.choice(s) else: s = ['h', 'h', 'r', 'd'] health = np.random.choice(s) self.population.append( Agent(x=x, y=y, age=age, status=status, health=health, social_stratum=social_stratum))
def create_agent(self, status): """ Create a new agent with the given status :param status: a value of agents.Status enum :return: the newly created agent """ x, y = self.random_position() age = int(np.random.beta(2, 5, 1) * 100) social_stratum = int(np.random.rand(1) * 100 // 20) self.population.append(Agent(x=x, y=y, age=age, status=status, social_stratum=social_stratum))
def create_agent(self, status): x = np.clip( int(self.length / 2 + (np.random.randn(1) * (self.length / 3))), 0, self.length) y = np.clip( int(self.height / 2 + (np.random.randn(1) * (self.height / 3))), 0, self.height) age = int(np.random.beta(2, 5, 1) * 100) social_stratum = int(np.random.rand(1) * 100 // 20) self.population.append( Agent(x=x, y=y, age=age, status=status, social_stratum=social_stratum))
def create_agent(self, status): """ Create a new agent with the given status :param status: a value of agents.Status enum :return: the newly created agent """ x, y = self.random_position() if self.bespoke_agent is not None: age = int(self.bespoke_agent()) raise NotImplementedError("Testing! Bespoke Agent.") print("Generated agent using bespoke age function!") else: age = int(np.random.beta(2, 5, 1) * 100) social_stratum = int(np.random.rand(1) * 100 // 20) self.population.append(Agent(x=x, y=y, age=age, status=status, social_stratum=social_stratum))