本文整理汇总了Python中agent.Agent.getLocation方法的典型用法代码示例。如果您正苦于以下问题:Python Agent.getLocation方法的具体用法?Python Agent.getLocation怎么用?Python Agent.getLocation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类agent.Agent
的用法示例。
在下文中一共展示了Agent.getLocation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestLocation
# 需要导入模块: from agent import Agent [as 别名]
# 或者: from agent.Agent import getLocation [as 别名]
class TestLocation(unittest.TestCase):
def setUp(self):
exchange1 = Exchange()
exchange2 = Exchange()
self.location1 = Location(exchange1)
self.location2 = Location(exchange2)
self.agent1 = Agent(location=self.location1)
self.agent2 = Agent(location=self.location2)
def test_setUp(self):
self.assertTrue(self.agent1.exchange == self.location1.exchange)
self.assertTrue(self.agent2.exchange == self.location2.exchange)
self.assertTrue(self.agent1 in self.location1.population)
self.assertTrue(self.agent2 in self.location2.population)
self.assertTrue(self.agent1.getLocation() == self.location1)
self.assertTrue(self.agent2.getLocation() == self.location2)
示例2: Environment
# 需要导入模块: from agent import Agent [as 别名]
# 或者: from agent.Agent import getLocation [as 别名]
if __name__ == '__main__' :
env = Environment(gridSize)
# add radial food site
env.addFoodSite(northSite, maxCapacity)
# add radial food site
env.addFoodSite(southSite, maxCapacity)
# grow to max capacity
if ruleGrow:
env.grow(maxCapacity)
# create a lit of agents and place them in env
agents = []
for (numAgents, tags, distribution) in distributions:
for i in range(numAgents):
agent = Agent(env)
if initAgent(agent, tags, distribution):
env.setAgent(agent.getLocation(), agent)
agents.append(agent)
# Create a view with an env and a list of agents in env
view = View(screenSize, env, agents)
# iterate
view.mainLoop()