Skip to content

Update game_of_life.py #4921

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 31, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions cellular_automata/game_of_life.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ def seed(canvas):


def run(canvas):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding type hints for Game of Life?

"""This function runs the rules of game through all points, and changes their
"""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
List
"""
canvas = np.array(canvas)
next_gen_canvas = np.array(create_canvas(canvas.shape[0]))
Expand All @@ -71,9 +71,7 @@ def run(canvas):
pt, canvas[r - 1 : r + 2, c - 1 : c + 2]
)

canvas = next_gen_canvas
del next_gen_canvas # cleaning memory as we move on.
return canvas.tolist()
return next_gen_canvas.tolist()


def __judge_point(pt, neighbours):
Expand Down