本文整理匯總了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.