Last active
June 26, 2022 19:02
-
-
Save Joseph94m/3ef18f0ae6312002041496690fdc5f5a to your computer and use it in GitHub Desktop.
Class of the game of life
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Game: | |
def __init__(self, initial_state, rules,max_size): | |
self.initial_state = initial_state | |
self.rules = rules | |
self.max_size = max_size | |
def run_game(self, it): | |
state = self.initial_state | |
previous_state = None | |
progression = [] | |
i = 0 | |
while (not state.equals(previous_state) and i < it): | |
i += 1 | |
previous_state = state.copy() | |
progression.append(previous_state.grid) | |
state = state.apply_rules(self.rules,self.max_size) | |
progression.append(state.grid) | |
return progression |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment