Skip to content

Commit a4ac38b

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 98287a5 commit a4ac38b

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

cellular_automata/von_neumann.py

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -595,8 +595,7 @@ def demo_game_of_life(size: int = 50, steps: int = 100):
595595
"""Demo using Game of Life rules on a Von Neumann grid."""
596596
initial_state = np.random.Generator(0, 2, size=(size, size))
597597
history = simulate_von_neumann_cellular_automaton(
598-
initial_state, generations=steps,
599-
birth_rules={3}, survival_rules={2, 3}
598+
initial_state, generations=steps, birth_rules={3}, survival_rules={2, 3}
600599
)
601600
visualize_cellular_automaton(history)
602601

@@ -605,8 +604,7 @@ def demo_highlife(size: int = 50, steps: int = 100):
605604
"""Demo using HighLife rules (B36/S23)."""
606605
initial_state = np.random.Generator(0, 2, size=(size, size))
607606
history = simulate_von_neumann_cellular_automaton(
608-
initial_state, generations=steps,
609-
birth_rules={3, 6}, survival_rules={2, 3}
607+
initial_state, generations=steps, birth_rules={3, 6}, survival_rules={2, 3}
610608
)
611609
visualize_cellular_automaton(history)
612610

@@ -625,28 +623,26 @@ def demo_oscillator(steps: int = 20):
625623
history = simulate_von_neumann_cellular_automaton(
626624
initial_state,
627625
generations=steps,
628-
birth_rules={3}, # Standard Game of Life birth rule
629-
survival_rules={2, 3} # Standard Game of Life survival rule
626+
birth_rules={3}, # Standard Game of Life birth rule
627+
survival_rules={2, 3}, # Standard Game of Life survival rule
630628
)
631629
visualize_cellular_automaton(history)
632630

633631

634632
def demo_random_rules(size: int = 50, steps: int = 100):
635633
"""Demo with random birth/survival rules."""
636634
birth_rules = set(
637-
np.random.Generator(range(5),
638-
size=np.random.Generator(1, 5),
639-
replace=False)
635+
np.random.Generator(range(5), size=np.random.Generator(1, 5), replace=False)
640636
)
641637
survival_rules = set(
642-
np.random.Generator(range(5),
643-
size=np.random.Generator(1, 5),
644-
replace=False)
638+
np.random.Generator(range(5), size=np.random.Generator(1, 5), replace=False)
645639
)
646640
initial_state = np.random.Generator(0, 2, size=(size, size))
647641
history = simulate_von_neumann_cellular_automaton(
648-
initial_state, generations=steps,
649-
birth_rules=birth_rules, survival_rules=survival_rules
642+
initial_state,
643+
generations=steps,
644+
birth_rules=birth_rules,
645+
survival_rules=survival_rules,
650646
)
651647
visualize_cellular_automaton(history)
652648

@@ -659,7 +655,7 @@ def demo_statistics(size: int = 50, steps: int = 100):
659655
# collect statistics
660656
live_counts = [np.sum(state > 0) for state in history]
661657
plt.figure(figsize=(6, 4))
662-
plt.plot(range(steps + 1), live_counts, label='Live Cells')
658+
plt.plot(range(steps + 1), live_counts, label="Live Cells")
663659
plt.xlabel("Generation")
664660
plt.ylabel("Number of live cells")
665661
plt.title("Cell Count Over Time")

0 commit comments

Comments
 (0)