Skip to content

Commit f8fe72d

Browse files
PzaThieftianyizheng02pre-commit-ci[bot]
authored
Update game_of_life.py (TheAlgorithms#4921)
* Update game_of_life.py docstring error fix delete no reason delete next_gen_canvas code(local variable) * Update cellular_automata/game_of_life.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: Tianyi Zheng <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 5cf34d9 commit f8fe72d

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

Diff for: cellular_automata/game_of_life.py

+5-7
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
- 3.5
1111
1212
Usage:
13-
- $python3 game_o_life <canvas_size:int>
13+
- $python3 game_of_life <canvas_size:int>
1414
1515
Game-Of-Life Rules:
1616
@@ -52,15 +52,16 @@ def seed(canvas: list[list[bool]]) -> None:
5252

5353

5454
def run(canvas: list[list[bool]]) -> list[list[bool]]:
55-
"""This function runs the rules of game through all points, and changes their
55+
"""
56+
This function runs the rules of game through all points, and changes their
5657
status accordingly.(in the same canvas)
5758
@Args:
5859
--
5960
canvas : canvas of population to run the rules on.
6061
6162
@returns:
6263
--
63-
None
64+
canvas of population after one step
6465
"""
6566
current_canvas = np.array(canvas)
6667
next_gen_canvas = np.array(create_canvas(current_canvas.shape[0]))
@@ -70,10 +71,7 @@ def run(canvas: list[list[bool]]) -> list[list[bool]]:
7071
pt, current_canvas[r - 1 : r + 2, c - 1 : c + 2]
7172
)
7273

73-
current_canvas = next_gen_canvas
74-
del next_gen_canvas # cleaning memory as we move on.
75-
return_canvas: list[list[bool]] = current_canvas.tolist()
76-
return return_canvas
74+
return next_gen_canvas.tolist()
7775

7876

7977
def __judge_point(pt: bool, neighbours: list[list[bool]]) -> bool:

0 commit comments

Comments
 (0)