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


Python Library.load_organism方法代码示例

本文整理汇总了Python中library.Library.load_organism方法的典型用法代码示例。如果您正苦于以下问题:Python Library.load_organism方法的具体用法?Python Library.load_organism怎么用?Python Library.load_organism使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在library.Library的用法示例。


在下文中一共展示了Library.load_organism方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __run_simulation_process

# 需要导入模块: from library import Library [as 别名]
# 或者: from library.Library import load_organism [as 别名]
  def __run_simulation_process(self):
    # The grid for this simulation.
    self.__grid = automata.Grid(self.__x_size, self.__y_size)
    # The visualization of the grid for this simulation.
    self.__grid_vis = visualization.GridVisualization(
        self.__x_size, self.__y_size)

    # The list of objects on the grid.
    self.__grid_objects = []

    # The frequency for updating the graphics.
    graphics_limiter = PhasedLoop(30)
    # The frequency for updating the simulation.
    # TODO(danielp): Make this rate user-settable.
    simulation_limiter = PhasedLoop(1)

    # Load all the organisms that we needed to load.
    for organism in self.__to_load:
      library_name = organism[0]
      name = organism[1]
      x_pos = organism[2]
      y_pos = organism[3]

      library = Library(library_name)
      organism = library.load_organism(name, self.__grid, (x_pos, y_pos))
      logger.info("Adding new grid object at (%d, %d)." % (x_pos, y_pos))

      self.__grid_objects.append(organism)

      # Add a visualization for the organism.
      visualization.GridObjectVisualization(self.__grid_vis, organism)

    # Update the grid to bake everything in its initial position.
    if not self.__grid.Update():
      logger.log_and_raise(SimulationError, "Initial grid update failed.")

    # Now that the visualization is populated, draw a key for it.
    self.__key = visualization.Key(self.__grid_vis)

    # Now run the simulation.
    while True:
      PhasedLoop.limit_fastest()

      if simulation_limiter.should_run():
        # Run the simulation.
        self.__run_iteration()
      if graphics_limiter.should_run():
        self.__grid_vis.update()
        self.__key.update()
开发者ID:djpetti,项目名称:ecosystem,代码行数:51,代码来源:simulation.py


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