MCPcopy Index your code
hub / github.com/geekcomputers/Python / run

Function run

game_of_life/game_o_life.py:59–80  ·  view source on GitHub ↗

This function runs the rules of game through all points, and changes their status accordingly.(in the same canvas) @Args: -- canvas : canvas of population to run the rules on. @returns: -- None

(canvas)

Source from the content-addressed store, hash-verified

57
58
59def run(canvas):
60 """This function runs the rules of game through all points, and changes their status accordingly.(in the same canvas)
61 @Args:
62 --
63 canvas : canvas of population to run the rules on.
64
65 @returns:
66 --
67 None
68 """
69 canvas = np.array(canvas)
70 next_gen_canvas = np.array(create_canvas(canvas.shape[0]))
71 for r, row in enumerate(canvas):
72 for c, pt in enumerate(row):
73 # print(r-1,r+2,c-1,c+2)
74 next_gen_canvas[r][c] = __judge_point(
75 pt, canvas[r - 1 : r + 2, c - 1 : c + 2]
76 )
77
78 canvas = next_gen_canvas
79 del next_gen_canvas # cleaning memory as we move on.
80 return canvas.tolist()
81
82
83def __judge_point(pt, neighbours):

Callers 1

game_o_life.pyFile · 0.85

Calls 2

create_canvasFunction · 0.85
__judge_pointFunction · 0.85

Tested by

no test coverage detected