本文整理汇总了Python中population.Population.random方法的典型用法代码示例。如果您正苦于以下问题:Python Population.random方法的具体用法?Python Population.random怎么用?Python Population.random使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类population.Population
的用法示例。
在下文中一共展示了Population.random方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from population import Population [as 别名]
# 或者: from population.Population import random [as 别名]
def main():
parser = argparse.ArgumentParser(description="Digital germs %(prog)s", prog="digerms")
parser.add_argument("--fps", "-f", type=int, help="Frames per second")
parser.add_argument("--fullscreen", "-F", action="store_true", help="Fullscreen mode")
parser.add_argument("--screen", "-S", action="store", help="Screen number")
parser.add_argument("--show-fps", action="store_true", help="Display FPS count")
parser.add_argument("--paused", action="store_true", help="Start paused")
parser.add_argument("--debug", "-d", action="store_true", help="Debug mode")
group = parser.add_mutually_exclusive_group()
group.add_argument("--size", "-s", type=str, help="Field size")
group.add_argument("--random-maze", "-r", action="store_true", help="Random maze")
group.add_argument("--maze", "-m", type=argparse.FileType('r'), help="Maze name or path to a file")
parser.set_defaults(**DEFAULTS)
options = parser.parse_args()
params = dict(fullscreen=options.fullscreen,
visible=False,
vsync=False,
fps=options.fps,
show_fps=options.show_fps,
screen=int(options.screen))
maze = None
grid_size = None
# guessing dimensions:
# from fullscreen dimensions
# from maze
# from size parameter
if options.maze:
maze = Walls.load(options.maze)
grid_size = maze.shape
elif options.random_maze:
maze = Walls.load(choice(list(glob('mazes/*.npy'))))
grid_size = maze.shape
if options.fullscreen:
app = Application(**params)
else:
# TODO понять, как определять высоту из высоты лабиринта и высоты статистики
if maze is None:
size = map(int, options.size.split('x'))
grid_size = (size[1] // GRID_SCALE, size[0] // GRID_SCALE)
width = grid_size[1] * GRID_SCALE
height = grid_size[0] * GRID_SCALE
params.update(dict(width=width, height=height+160,))
app = Application(**params)
# population = PolulationWithMessia.random(POPULATION_SIZE)
population = Population.random(POPULATION_SIZE)
env_view = ExperimentMode(app.window, population, maze, stats_height=160, debug=options.debug)
env_view.paused = options.paused
app.set_mode(env_view, 1./2000)
app.run()
示例2: setup
# 需要导入模块: from population import Population [as 别名]
# 或者: from population.Population import random [as 别名]
def setup():
n = 100
population = Population.random(n)
assert len(population) == n
env = Environment(10, 20, 8)
env.set_population(population)
population.set_X(
np.hstack([np.linspace(0, 20 * 8 - 1, 100)[:, np.newaxis], np.linspace(0, 10 * 8 - 1, 100)[:, np.newaxis]])
)
a = population._agents
a.ax = 1
a.ay = 0
a.speed = 1
return population