本文整理汇总了Python中game_of_life.GameOfLife.randomize_board方法的典型用法代码示例。如果您正苦于以下问题:Python GameOfLife.randomize_board方法的具体用法?Python GameOfLife.randomize_board怎么用?Python GameOfLife.randomize_board使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类game_of_life.GameOfLife
的用法示例。
在下文中一共展示了GameOfLife.randomize_board方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: board
# 需要导入模块: from game_of_life import GameOfLife [as 别名]
# 或者: from game_of_life.GameOfLife import randomize_board [as 别名]
# Get a board size from the user.
default_size = 30
str_prompt = "Specify a number of {0} for the board (default " \
+ str(default_size) + "): "
fcn_parse = lambda string: (True, default_size) if string == '' else parse_positive_int(string)
num_rows = my_prompt(str_prompt.format('rows'), fcn_parse)
num_cols = my_prompt(str_prompt.format('columns'), fcn_parse)
# Should we play on a torus?
fcn_parse_torus = lambda string: (True, False) if string == '' else parse_yes_no(string)
on_torus = my_prompt("Make the board a torus (a la Pac-Man)? y/[n]: ", parse_yes_no)
# Initialize a random game.
game = GameOfLife(num_rows, num_cols, on_torus = on_torus)
game.randomize_board()
# ========================================================================
# A simple GUI demo
# ========================================================================
#
# Draw the board we created above, and update it every 250 milliseconds as long
# as there is life on the board. No additional interaction is supported.
# Create a canvas for drawing to.
master = tk.Tk()
master.title("Conway's Game of Life")
w = tk.Canvas(master, width = 10 * num_cols, height = 10 * num_rows)
w.pack()
# Create the rectangles with which we'll draw the game.