当前位置: 首页>>代码示例>>Python>>正文


Python Agent.getLocation方法代码示例

本文整理汇总了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)
开发者ID:delbalso,项目名称:MarketSim,代码行数:19,代码来源:testLocation.py

示例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()

开发者ID:Inaughenth,项目名称:sugarscape,代码行数:30,代码来源:sugarscape.py


注:本文中的agent.Agent.getLocation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。