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)
| 57 | |
| 58 | |
| 59 | def 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 | |
| 83 | def __judge_point(pt, neighbours): |
no test coverage detected