Repository: bsatrom/py-conway

Issue:
rename public properties to match terms of the game (seed, generation, etc.)

Discussion:

Patch:
diff --git a/README.md b/README.md
index 82ad6e5..83fa945 100644
--- a/README.md
+++ b/README.md
@@ -21,11 +21,11 @@ To create a game, you'll need to provide dimensions and a starting two-dimensona
 ```python
 from conway.game import Game
 
-beacon = [[0, 1, 0],
+seed = [[0, 1, 0],
           [1, 1, 1],
           [0, 1, 0]]
 
-new_game = Game(3, 3, beacon)
+new_game = Game(3, 3, seed)
 ```
 
 Once the game board is populated, call the `start()` method. The game will start on a background thread and update the full game board as well as a number of informational instance variables:
@@ -33,18 +33,18 @@ Once the game board is populated, call the `start()` method. The game will start
 ```python
 new_game.start()
 
-new_game.board # hold the complete game state after each step
+new_game.current_board # hold the complete game state after each step
 new_game.live_cells # the count of live cells on the board
-new_game.num_steps # the number of steps elapsed in the current game.
+new_game.generations # the number of steps elapsed in the current game.
 ```
 
-It's also possible to call the `step()` method and control the game state yourself from one iteration to the next:
+It's also possible to call the `run_generation()` method and control the game state yourself from one iteration to the next:
 
 ```python
-new_game.step()
+new_game.run_generation()
 ```
 
-Here's an example that runs the game and plots the game board after intialization and the first step:
+Here's an example that runs the game and plots the game board after intialization and the first generation:
 
 ```python
 import matplotlib.pyplot as plt
@@ -54,18 +54,18 @@ def create_zeros(x, y):
     dim_one = [0 for item in range(x)]
     return [dim_one[:] for item in range(y)]
 
-beacon = create_zeros(12, 12)
+seed = create_zeros(12, 12)
 
-beacon[0][1] = 1
-beacon[1][2] = 1
-beacon[2][3] = 1
-game = Game(12, 12, beacon)
+seed[0][1] = 1
+seed[1][2] = 1
+seed[2][3] = 1
+game = Game(12, 12, seed)
 
-plt.imshow(game.beacon, cmap='binary')
+plt.imshow(game.current_board, cmap='binary')
 plt.show()
 
-game.step()
+game.run_generation()
 
-plt.imshow(game.beacon, cmap='binary')
+plt.imshow(game.current_board, cmap='binary')
 plt.show()
 ```
diff --git a/conway/game.py b/conway/game.py
index e69e896..ffb4927 100644
--- a/conway/game.py
+++ b/conway/game.py
@@ -14,33 +14,32 @@ class Game:
     Class for running a game of Conway's Game of Life on a virtual
     two-dimensional board of any size.
     """
-    def __init__(self, width: int = 6, height: int = 6, beacon: list = None):
+    def __init__(self, width: int = 6, height: int = 6, seed: list = None):
         """
-        Intialize the game based on provided board size values and a
-        starter beacon.
+        Intialize the game based on provided board size values and a seed.
 
         Keyword Arguments:
         width -- the width (in columns) of the game board
         height -- the height (in rows) of the game board
-        beacon -- A two-dimensional list with 1 and 0 values that
+        seed -- A two-dimensional list with 1 and 0 values that
                   should be set to the initial game state.
         """
         self.board_size = (width, height)
         self.live_cells = 0
-        self.num_steps = 0
+        self.generations = 0
         self._thread_active = False
 
-        if beacon is None:
-            self.beacon = self._create_zeros()
+        if seed is None:
+            self.seed = self._create_zeros()
         else:
-            if len(beacon) != height or len(beacon[0]) != width:
-                raise Exception("Please make sure that the beacon matches \
+            if len(seed) != height or len(seed[0]) != width:
+                raise Exception("Please make sure that the seed matches \
                                  the provided width and height values.")
 
-            self.beacon = beacon
-            self.live_cells = self._count_live_cells(self.beacon)
+            self.seed = seed
+            self.live_cells = self._count_live_cells(self.seed)
 
-        self.board = deepcopy(self.beacon)
+        self.current_board = deepcopy(self.seed)
         self.state = GameState.READY
 
     def _count_live_cells(self, grid_state: list) -> int:
@@ -97,7 +96,7 @@ class Game:
             elif n_row == num_rows or n_col == num_cols:
                 continue
             else:
-                if self.board[n_row][n_col] == 1:
+                if self.current_board[n_row][n_col] == 1:
                     neighbors += 1
 
         return neighbors
@@ -110,7 +109,7 @@ class Game:
                 if (self.live_cells == 0 or not self._thread_active):
                     self.state = GameState.FINISHED
                     break
-                self.step()
+                self.run_generation()
 
     def start(self):
         """Run the game automatically on a background thread."""
@@ -120,9 +119,10 @@ class Game:
         self._thread_active = True
 
     def stop(self):
+        """Stop a game currently running on a background thread."""
         self._thread_active = False
 
-    def step(self):
+    def run_generation(self):
         """
         Enumerate over every element and determine its number of neighbors
         For each cell, check all eight neighbors and turn on or off.
@@ -130,23 +130,24 @@ class Game:
         the entire state grid is updated at once.
         """
         # Get a deep copy of the state to track cells that will need
-        # to change without affecting the outcome for other cells in-step
-        intermediate_state = deepcopy(self.board)
-        upcoming_live_cells = self._count_live_cells(self.board)
+        # to change without affecting the outcome for other cells
+        # in-generation
+        intermediate_state = deepcopy(self.current_board)
+        upcoming_live_cells = self._count_live_cells(self.current_board)
 
-        for row_index, row in enumerate(self.board):
+        for row_index, row in enumerate(self.current_board):
             for col_index in range(len(row)):
                 neighbors = self._num_neighbors(row_index, col_index)
 
                 if (neighbors < 2 or neighbors > 3):
-                    if (self.board[row_index][col_index] == 1):
+                    if (self.current_board[row_index][col_index] == 1):
                         upcoming_live_cells -= 1
                     intermediate_state[row_index][col_index] = 0
                 elif (neighbors == 3):
-                    if (self.board[row_index][col_index] == 0):
+                    if (self.current_board[row_index][col_index] == 0):
                         upcoming_live_cells += 1
                     intermediate_state[row_index][col_index] = 1
 
-        self.board = deepcopy(intermediate_state)
-        self.num_steps += 1
+        self.current_board = deepcopy(intermediate_state)
+        self.generations += 1
         self.live_cells = upcoming_live_cells
diff --git a/example/run.py b/example/run.py
index 38e167b..1da4190 100644
--- a/example/run.py
+++ b/example/run.py
@@ -14,21 +14,17 @@ def create_zeros(x, y):
     return [dim_one[:] for item in range(y)]
 
 
-beacon = create_zeros(12, 12)
+seed = create_zeros(12, 12)
 
-beacon[0][1] = 1
-beacon[1][2] = 1
-beacon[2][3] = 1
-game = Game(12, 12, beacon)
+seed[0][1] = 1
+seed[1][2] = 1
+seed[2][3] = 1
+game = Game(12, 12, seed)
 
-pprint(beacon)
-
-plt.imshow(game.beacon, cmap='binary')
+plt.imshow(game.current_board, cmap='binary')
 plt.show()
 
-game.step()
-
-pprint(beacon)
+game.run_generation()
 
-plt.imshow(game.beacon, cmap='binary')
+plt.imshow(game.current_board, cmap='binary')
 plt.show()


Test patch:
diff --git a/tests/tests.py b/tests/tests.py
index 496e156..515052c 100644
--- a/tests/tests.py
+++ b/tests/tests.py
@@ -19,155 +19,159 @@ class TestConway():
         test_game = Game(12, 12)
         assert test_game.board_size == (12, 12)
 
-    # Add a beacon with a single cell active
-    def test_test_game_init_beacon(self):
-        beacon = create_zeros(6, 6)
-        beacon[1][1] = 1
-        test_game = Game(6, 6, beacon)
-        assert test_game.beacon == beacon
+    # Add a seed with a single cell active
+    def test_test_game_init_seed(self):
+        seed = create_zeros(6, 6)
+        seed[1][1] = 1
+        test_game = Game(6, 6, seed)
+        assert test_game.seed == seed
 
     # Test for defaults
     def test_test_game_init_defaults(self):
         test_game = Game()
         assert test_game.board_size == (6, 6)
-        assert test_game.beacon == create_zeros(6, 6)
+        assert test_game.seed == create_zeros(6, 6)
 
-    # Test for default board_size on set beacon
-    def test_test_game_init_board_default_beacon(self):
+    # Test for default board_size on set seed
+    def test_test_game_init_board_default_seed(self):
         test_game = Game(12, 12)
-        assert test_game.beacon == create_zeros(12, 12)
+        assert test_game.seed == create_zeros(12, 12)
 
     # Test that check cell returns a valid value
     def test_test_game_3_x_3_check_cell_with_one_neighbor(self):
-        beacon = [[0, 1, 0],
-                  [0, 1, 0],
-                  [0, 0, 0]]
-        test_game = Game(3, 3, beacon)
+        seed = [[0, 1, 0],
+                [0, 1, 0],
+                [0, 0, 0]]
+
+        test_game = Game(3, 3, seed)
         assert test_game._num_neighbors(1, 1) == 1
 
     def test_test_game_3_x_3_check_cell_with_two_neighbors(self):
-        beacon = [[0, 1, 0],
-                  [0, 1, 0],
-                  [0, 0, 0]]
-        test_game = Game(3, 3, beacon)
+        seed = [[0, 1, 0],
+                [0, 1, 0],
+                [0, 0, 0]]
+
+        test_game = Game(3, 3, seed)
         assert test_game._num_neighbors(1, 2) == 2
 
     def test_test_game_3_x_3_check_cell_with_three_neighbors(self):
-        beacon = [[1, 0, 0],
-                  [1, 1, 0],
-                  [0, 0, 0]]
-        test_game = Game(3, 3, beacon)
+        seed = [[1, 0, 0],
+                [1, 1, 0],
+                [0, 0, 0]]
+
+        test_game = Game(3, 3, seed)
         assert test_game._num_neighbors(0, 1) == 3
 
     # Run on an array of a single column
     def test_single_column_array(self):
-        beacon = [[0], [0], [1]]
-        test_game = Game(1, 3, beacon)
+        seed = [[0], [0], [1]]
+        test_game = Game(1, 3, seed)
         assert test_game._num_neighbors(1, 0) == 1
 
     # Run the test_game for one iteration on a single cell
     def test_3_x_3_single_cell_single_run(self):
-        beacon = [[0, 0, 0],
-                  [0, 1, 0],
-                  [0, 0, 0]]
-        test_game = Game(3, 3, beacon)
-        test_game.step()
-        assert test_game.board == create_zeros(3, 3)
+        seed = [[0, 0, 0],
+                [0, 1, 0],
+                [0, 0, 0]]
+
+        test_game = Game(3, 3, seed)
+        test_game.run_generation()
+        assert test_game.current_board == create_zeros(3, 3)
 
     # Run the test_game for one iteration on three cells
     def test_3_x_3_three_neighbors_single_run(self):
-        beacon = [[1, 0, 0],
-                  [1, 1, 0],
-                  [0, 0, 0]]
+        seed = [[1, 0, 0],
+                [1, 1, 0],
+                [0, 0, 0]]
 
         expected_state = [[1, 1, 0],
                           [1, 1, 0],
                           [0, 0, 0]]
 
-        test_game = Game(3, 3, beacon)
-        test_game.step()
+        test_game = Game(3, 3, seed)
+        test_game.run_generation()
 
-        assert test_game.board == expected_state
+        assert test_game.current_board == expected_state
 
     # Run the test_game for one iteration on four cells
     def test_3_x_3_four_neighbors_single_run(self):
-        beacon = [[0, 1, 0],
-                  [1, 1, 1],
-                  [0, 1, 0]]
+        seed = [[0, 1, 0],
+                [1, 1, 1],
+                [0, 1, 0]]
 
         expected_state = [[1, 1, 1],
                           [1, 0, 1],
                           [1, 1, 1]]
 
-        test_game = Game(3, 3, beacon)
-        test_game.step()
+        test_game = Game(3, 3, seed)
+        test_game.run_generation()
 
-        assert test_game.board == expected_state
+        assert test_game.current_board == expected_state
 
     # Run the test_game for one iteration on four cells
     def test_4_x_3_three_neighbors_single_run(self):
-        beacon = [[1, 0, 1, 0],
-                  [0, 1, 0, 0],
-                  [1, 0, 1, 1]]
+        seed = [[1, 0, 1, 0],
+                [0, 1, 0, 0],
+                [1, 0, 1, 1]]
 
         expected_state = [[0, 1, 0, 0],
                           [1, 0, 0, 1],
                           [0, 1, 1, 0]]
 
-        test_game = Game(4, 3, beacon)
-        test_game.step()
+        test_game = Game(4, 3, seed)
+        test_game.run_generation()
 
-        assert test_game.board == expected_state
+        assert test_game.current_board == expected_state
 
-    # Test the number of live cells on an empty beacon
-    def test_3_x_3_empty_beacon_no_live_cells(self):
+    # Test the number of live cells on an empty seed
+    def test_3_x_3_empty_seed_no_live_cells(self):
         test_game = Game(3, 3)
 
         assert test_game.live_cells == 0
 
-    # Test the live cells count on a beacon with 4 lve cells
-    def test_3_x_3_beacon_five_live_cells(self):
-        beacon = [[0, 1, 0],
-                  [1, 1, 1],
-                  [0, 1, 0]]
+    # Test the live cells count on a seed with 4 lve cells
+    def test_3_x_3_seed_five_live_cells(self):
+        seed = [[0, 1, 0],
+                [1, 1, 1],
+                [0, 1, 0]]
 
-        test_game = Game(3, 3, beacon)
+        test_game = Game(3, 3, seed)
 
         assert test_game.live_cells == 5
 
     def test_increment_live_cells_after_update(self):
-        beacon = [[0, 1, 0],
-                  [1, 1, 1],
-                  [0, 1, 0]]
+        seed = [[0, 1, 0],
+                [1, 1, 1],
+                [0, 1, 0]]
 
-        test_game = Game(3, 3, beacon)
-        test_game.step()
+        test_game = Game(3, 3, seed)
+        test_game.run_generation()
 
         assert test_game.live_cells == 8
 
-    def test_update_steps_after_each_step(self):
+    def test_update_generations_count_after_each_generation(self):
         test_game = Game(2, 2, [[1, 0], [0, 1]])
 
-        test_game.step()
-        test_game.step()
+        test_game.run_generation()
+        test_game.run_generation()
 
-        assert test_game.num_steps == 2
+        assert test_game.generations == 2
 
     # Run the test_game for one iteration on four cells
     def test_3_x_3_four_neighbors_two_runs(self):
-        beacon = [[0, 1, 0],
-                  [1, 1, 1],
-                  [0, 1, 0]]
+        seed = [[0, 1, 0],
+                [1, 1, 1],
+                [0, 1, 0]]
 
         expected_state = [[1, 0, 1],
                           [0, 0, 0],
                           [1, 0, 1]]
 
-        test_game = Game(3, 3, beacon)
-        test_game.step()
-        test_game.step()
+        test_game = Game(3, 3, seed)
+        test_game.run_generation()
+        test_game.run_generation()
 
-        assert test_game.board == expected_state
+        assert test_game.current_board == expected_state
 
     def test_default_game_state_ready(self):
         test_game = Game()
@@ -175,11 +179,11 @@ class TestConway():
         assert test_game.state == GameState.READY
 
     def test_start_game_changes_state_to_running(self):
-        beacon = [[0, 1, 0],
-                  [1, 1, 1],
-                  [0, 1, 0]]
+        seed = [[0, 1, 0],
+                [1, 1, 1],
+                [0, 1, 0]]
 
-        test_game = Game(3, 3, beacon)
+        test_game = Game(3, 3, seed)
         test_game.state = GameState.READY
         test_game._thread_active = True
         test_game._run()
@@ -194,56 +198,56 @@ class TestConway():
 
         assert test_game.state == GameState.FINISHED
 
-    def test_ensure_that_width_height_and_beacon_match(self):
-        beacon = [[0, 0, 0, 0],
-                  [0, 1, 1, 0],
-                  [0, 1, 1, 0],
-                  [0, 0, 0, 0]]
+    def test_ensure_that_width_height_and_seed_match(self):
+        seed = [[0, 0, 0, 0],
+                [0, 1, 1, 0],
+                [0, 1, 1, 0],
+                [0, 0, 0, 0]]
 
         with pytest.raises(Exception):
-            Game(3, 4, beacon)
+            Game(3, 4, seed)
 
     def test_ensure_that_live_cells_count_is_accurate_before_run(self):
-        beacon = [[0, 0, 0, 0],
-                  [0, 1, 1, 0],
-                  [0, 1, 1, 0],
-                  [0, 0, 0, 0]]
+        seed = [[0, 0, 0, 0],
+                [0, 1, 1, 0],
+                [0, 1, 1, 0],
+                [0, 0, 0, 0]]
 
-        test_game = Game(4, 4, beacon)
-        test_game.board[0][0] = 1
+        test_game = Game(4, 4, seed)
+        test_game.current_board[0][0] = 1
 
-        test_game.step()
+        test_game.run_generation()
 
         assert test_game.live_cells == 5
 
-    def test_no_beacon_ensure_live_cells_count_is_accurate_before_run(self):
+    def test_no_seed_ensure_live_cells_count_is_accurate_before_run(self):
         test_game = Game(4, 4)
-        test_game.board[0][0] = 1
-        test_game.board[0][1] = 1
-        test_game.board[0][2] = 1
+        test_game.current_board[0][0] = 1
+        test_game.current_board[0][1] = 1
+        test_game.current_board[0][2] = 1
 
-        test_game.step()
+        test_game.run_generation()
 
         assert test_game.live_cells == 2
 
     def test_still_life_game_will_continue_to_run(self):
-        beacon = [[0, 0, 0, 0],
-                  [0, 1, 1, 0],
-                  [0, 1, 1, 0],
-                  [0, 0, 0, 0]]
+        seed = [[0, 0, 0, 0],
+                [0, 1, 1, 0],
+                [0, 1, 1, 0],
+                [0, 0, 0, 0]]
 
-        test_game = Game(4, 4, beacon)
+        test_game = Game(4, 4, seed)
         test_game.start()
 
         assert test_game.state, GameState.RUNNING
 
     def test_still_life_game_can_be_stopped(self):
-        beacon = [[0, 0, 0, 0],
-                  [0, 1, 1, 0],
-                  [0, 1, 1, 0],
-                  [0, 0, 0, 0]]
+        seed = [[0, 0, 0, 0],
+                [0, 1, 1, 0],
+                [0, 1, 1, 0],
+                [0, 0, 0, 0]]
 
-        test_game = Game(4, 4, beacon)
+        test_game = Game(4, 4, seed)
         test_game.start()
 
         assert test_game.state, GameState.RUNNING