1515"""
1616
1717import numpy as np
18- import matplotlib .pyplot as plt
1918from matplotlib import animation
19+ import matplotlib .pyplot as plt
2020from matplotlib .colors import ListedColormap
2121
2222
@@ -571,7 +571,7 @@ def run_interactive_simulation(
571571# Helper demo functions
572572# -------------------------------------------------------------------------
573573
574- def demo_game_of_life ():
574+ def demo_game_of_life () -> None :
575575 """Example 1: Conway's Game of Life (B3/S23)."""
576576 try :
577577 visualize_cellular_automaton (
@@ -585,7 +585,7 @@ def demo_game_of_life():
585585 print (f"Error in Game of Life demo: { e } " )
586586
587587
588- def demo_highlife ():
588+ def demo_highlife () -> None :
589589 """Example 2: HighLife (B36/S23)."""
590590 try :
591591 visualize_cellular_automaton (
@@ -599,7 +599,7 @@ def demo_highlife():
599599 print (f"Error in HighLife demo: { e } " )
600600
601601
602- def demo_oscillator ():
602+ def demo_oscillator () -> None :
603603 """Example 3: Oscillator (blinker)."""
604604 try :
605605 initial_state = np .zeros ((10 , 10 ), dtype = int )
@@ -615,7 +615,7 @@ def demo_oscillator():
615615 print (f"Error in Oscillator demo: { e } " )
616616
617617
618- def demo_randomized ():
618+ def demo_randomized () -> None :
619619 """Example 4: Randomized automaton (B2/S23)."""
620620 try :
621621 visualize_cellular_automaton (
@@ -629,10 +629,10 @@ def demo_randomized():
629629 print (f"Error in Randomized demo: { e } " )
630630
631631
632- def demo_statistics ():
632+ def demo_statistics () -> None :
633633 """Example 5: Print statistics about automaton evolution."""
634634 try :
635- final_state = run_cellular_automaton (
635+ final_state = simulate_cellular_automaton (
636636 rule_b = [3 ],
637637 rule_s = [2 , 3 ],
638638 size = 50 ,
@@ -641,9 +641,10 @@ def demo_statistics():
641641 )
642642 alive_counts = [np .sum (state ) for state in final_state ]
643643 density = [count / (50 * 50 ) * 100 for count in alive_counts ]
644+ average_population = f"{ np .mean (alive_counts ):.1f} cells"
644645
645646 print ("Statistics Example:" )
646- print (f"-Average population: { np . mean ( alive_counts ):.1f } cells " )
647+ print (f"-Average population: { average_population } " )
647648 print (f"-Average density: { np .mean (density ):.1f} %" )
648649 print (f"-Max population: { np .max (alive_counts )} " )
649650 print (f"-Min population: { np .min (alive_counts )} " )
@@ -655,7 +656,7 @@ def demo_statistics():
655656# Main demo orchestrator
656657# -------------------------------------------------------------------------
657658
658- def demonstrate_cellular_automaton_features ():
659+ def demonstrate_cellular_automaton_features () -> None :
659660 """Runs a set of cellular automaton demonstrations."""
660661 print ("=" * 80 )
661662 print ("VON NEUMANN CELLULAR AUTOMATON - FEATURE DEMONSTRATION" )
@@ -672,7 +673,7 @@ def demonstrate_cellular_automaton_features():
672673 print ("=" * 80 )
673674
674675
675- def quick_demo (rule_name : str = "conway" ):
676+ def quick_demo (rule_name : str = "conway" ) -> None :
676677 """
677678 Quick demonstration function for specific rule sets.
678679
0 commit comments