Conway's Life: Iterate over a closed universe in Python -
I have just started learning python, and I'm trying to write a program for Conway's Game of Life . I am trying to create a closed universe with boundary conditions (which are the opposite sides / corners) I think I have done this, but when I run, I'm not walking on the loop, and how it works It does not work Thank you very much in advance! Def iterate_conway_closed (universe_t0, n_iter = 1, display = false): # This function is like your iterate_conway_open function # But instead of adding a zero protector body instead of as explained earlier Add a #ping 'ringing ring' Once you combine into the universe, use the same apply_rules # function as part 1 to actually implement the rules. # Note that unlike the 0 ring ring always for the open universe, the #ping ring will need to be updated after each call # Apply the rule to display the change in the height of the universe, width = universe_t0.shape universe_array = numpy .zeros ((height + 2, width + 2), dtype = numpy.uint8) cosmos_array [1: -1, -1: -1] = cosmos_t 0 dr calculation (niiter): n = 0 while n & lt; = N_iter: overhead n n + (0, niIeter): cosmos_are [: 1,1: -1] = cosmos_t 0 [-1:,:] # map to the bottom line cosmos_ [0,1: -1] = cosmos_t 0 [ -1:, 0:] # map top row universe_array [1: -1,0] = cosmod_t 0 [, 0] # map to left column universe_array [1: -1, -1] = cosmos_t 0 [:, - 1] # The right column of the map Cosmic_array [0,0] = cosmos_t 0 [-1,0] #maps bottom left corner cosmos_arre [0, -1] = cosmod_t 0 [-1, -1] #maps below Where the cosmic universe_re [-1,0] = cosmos_t0 [0,0] #map top left corner universe_array [-1, -1] = cosmos_t 0 [0, -1] #maps in top right corner (0, N_ Iter): Universe_array = apply_rules (universe_array) if display == correct: b_print (universe_array) back to cosmos_arre [1: -1, 1: -1]
EDIT: Besides, you probably want just 1 loop, you can start universe_array
first. The n_iter
bar is not doing anything after the first time, then you apply the rules to n_iter
times, you want to put them in the same loop so that the universe moves After the update is updated properly
Comments
Post a Comment