You encountered a common matplotlib animation problem where the display only updates when you resize the window. This happens because:
- Animation framework issues: Some
FuncAnimationsettings cause refresh problems - Backend compatibility: The matplotlib backend may not handle automatic updates
- Event loop conflicts: Display events aren't being processed correctly
I've created a fixed version that solves this problem:
python automata_interactive_gui.pyKey fixes implemented:
blit=Falsein FuncAnimation (critical!)cache_frame_data=Falseto prevent cachingfig.canvas.draw_idle()for proper event-driven updates- Proper event handling for controls
-
self_replicating_automata.py- Original simulator- 4 automaton types: Langton Loop, Evolving Loop, Von Neumann, Wire World
- Basic visualization with matplotlib
- Command-line interface
- Can be imported as a library
-
automata_interactive_gui.py⭐ RECOMMENDED- Interactive matplotlib-based GUI
- Fixes the display refresh issue
- Play/Pause/Step/Reset controls
- Speed and grid size sliders
- Real-time statistics
- Save snapshots
- Works with standard matplotlib (no extra dependencies)
-
automata_gui.py- Advanced tkinter GUI- Professional GUI framework
- Threaded simulation
- Progress bars for saving
- More polished interface
- Requires:
python3-tkpackage
-
quick_start.py⚡ EASIEST TO USE- Just run this!
- Launches the interactive GUI with helpful instructions
- Checks dependencies
- Provides troubleshooting tips
-
display_diagnostic.py- Diagnostic tool- Tests different animation settings
- Identifies backend issues
- Provides specific recommendations
- Run this if you have problems
-
README_automata.md- Original README- Theoretical background
- Von Neumann's concepts
- Current research (2024-2025)
- Usage examples
- Extension guide
-
GUI_GUIDE.md- Comprehensive GUI guide- Detailed explanation of the refresh fix
- Comparison of GUI versions
- Controls and features
- Advanced usage
- Troubleshooting
-
README.md(this file) - Master guide
langton_loop_snapshot.png- Example outputevolving_loop_snapshot.png- Example outputvon_neumann_snapshot.png- Example outputwireworld_snapshot.png- Example output
python quick_start.pyClick on the radio buttons:
- Langton Loop - Classic self-replicator
- Evolving Loop - With mutations (adjust rate with slider)
- Von Neumann - Universal constructor demo
- Wire World - Signal propagation
- ▶ Play - Start running
- ⏸ Pause - Pause
- ⏭ Step - Advance one generation
- 🔄 Reset - Create fresh automaton
- Sliders - Adjust speed (10-500 ms) and grid size (50-300)
- 📸 Save - Save current state as PNG
┌─────────────────────────────────────────────────────────┐
│ START HERE → python quick_start.py │
└─────────────────────────────────────────────────────────┘
│
├─ Works? ──→ ✓ You're done!
│
└─ Issues? ──┐
│
┌──────────────────────────────────────┘
│
├─ Try: python automata_interactive_gui.py
│ (Fixed matplotlib version)
│
├─ Still issues? → python display_diagnostic.py
│ (Diagnose the problem)
│
└─ Have tkinter? → python automata_gui.py
(Professional version)
Use automata_interactive_gui.py (recommended) if:
- ✅ You want it to just work
- ✅ You don't want extra dependencies
- ✅ You had the refresh issue
- ✅ You want built-in controls
Use automata_gui.py if:
- ✅ You have tkinter installed
- ✅ You want the most polished interface
- ✅ You need threaded performance
- ✅ You want progress bars for saving
Use self_replicating_automata.py if:
- ✅ You want to import as a library
- ✅ You're writing your own GUI
- ✅ You need programmatic control
- ✅ You want to extend the classes
Original animation code that can fail:
# ❌ Can cause refresh issues
anim = FuncAnimation(fig, update, interval=50, blit=True)
plt.show()Fixed animation code:
# ✅ Reliable refresh
anim = FuncAnimation(
fig,
update,
interval=50,
blit=False, # Critical!
cache_frame_data=False # Also important!
)
plt.show()blit=False:
- Disables "blitting" optimization
- Blitting can skip screen updates on some systems
- Slower but more reliable
cache_frame_data=False:
- Prevents matplotlib from caching frames
- Ensures fresh data every update
- Fixes stale display issues
Event-driven updates:
- Uses
fig.canvas.draw_idle()instead ofdraw() - Schedules updates properly in the event loop
- Prevents conflicts with window manager
| Feature | Original | Interactive GUI | Tkinter GUI |
|---|---|---|---|
| Refresh fix | ❌ | ✅ | ✅ |
| Play/Pause | ❌ | ✅ | ✅ |
| Step control | ❌ | ✅ | ✅ |
| Speed slider | ❌ | ✅ | ✅ |
| Grid size control | ❌ | ✅ | ✅ |
| Statistics | ❌ | ✅ | ✅ |
| Save snapshots | Manual | ✅ Button | ✅ Button |
| Extra dependencies | None | None | tkinter |
| Threading | ❌ | ❌ | ✅ |
| Polish level | Basic | Good | Professional |
pip install matplotlib numpy
python automata_interactive_gui.py# Install tkinter first
sudo apt-get install python3-tk # Ubuntu/Debian
# or
brew install python-tk # macOS
# Install Python packages
pip install matplotlib numpy
python automata_gui.pypython quick_start.pypython display_diagnostic.pyThis will:
- Check your matplotlib backend
- Test different animation settings
- Provide specific recommendations
- Show what's working/not working
from automata_interactive_gui import InteractiveAutomatonGUI
gui = InteractiveAutomatonGUI()
gui.show() # Should update smoothly when you click Play# Easiest way - just run it!
python quick_start.py
# Or directly
python automata_interactive_gui.pyfrom self_replicating_automata import LangtonLoop
# Create automaton
automaton = LangtonLoop(150, 150)
# Run simulation
for i in range(100):
automaton.step()
print(f"Generation {i}: {np.count_nonzero(automaton.grid)} active cells")
# Access the grid
print(automaton.grid.shape)from automata_interactive_gui import InteractiveAutomatonGUI
import matplotlib.pyplot as plt
# Create custom GUI
gui = InteractiveAutomatonGUI()
# Modify before showing
gui.speed_ms = 25 # Faster updates
gui.grid_size = 200 # Larger grid
gui.show()- Check your backend:
python -c "import matplotlib; print(matplotlib.get_backend())"- Try a different backend:
import matplotlib
matplotlib.use('Qt5Agg') # or TkAgg, GTK3Agg- Run the diagnostic:
python display_diagnostic.py- Update matplotlib:
pip install --upgrade matplotlib- Reduce grid size (use slider or set to 50-100)
- Increase speed interval (slower updates)
- Use Wire World (simplest automaton)
- Close other applications
# Make sure all files are in the same directory
ls -l *.py
# Check dependencies
pip list | grep -E "(matplotlib|numpy)"
# Reinstall if needed
pip install --force-reinstall matplotlib numpySee README_automata.md for:
- Von Neumann's original concepts
- History of self-replicating automata
- Current research (2024-2025)
- Mathematical foundations
- Biological parallels
See GUI_GUIDE.md for:
- Complete feature list
- Advanced usage
- Customization examples
- Integration with your research
- Technical implementation details
Von Neumann's work (1940s-1950s) predated the discovery of DNA but arrived at similar concepts:
- Self-description (genetic code)
- Universal construction (ribosomes)
- Information duplication (replication)
Recent developments (2024-2025):
- 25th anniversary of evoloops
- Renewed interest in open-ended evolution
- Continuous cellular automata
- Physical implementations
- Run the simulator - Start with
quick_start.py - Experiment - Try different automaton types and parameters
- Observe - Watch self-replication in action
- Extend - Create your own automaton variants
- Analyze - Export data and study patterns
Given your microscopy background:
- Adapt for modeling PIEZO1 clustering
- Simulate calcium wave propagation
- Test segmentation algorithms
- Model particle interactions
If you use this code in your research:
Von Neumann Self-Replicating Automata Simulator
Based on: von Neumann, J. (1966). Theory of Self-Reproducing Automata
Implementation: 2024
If you encounter issues:
- Read the error message - Often points to the solution
- Run diagnostics -
python display_diagnostic.py - Check documentation -
GUI_GUIDE.mdhas detailed troubleshooting - Try alternative GUI - If one doesn't work, try the other
- Update packages - Make sure matplotlib/numpy are current
Problem: Display only refreshes when resizing window
Solution: Use automata_interactive_gui.py with fixed animation settings
Quick Start: Run python quick_start.py
Need Help: Run python display_diagnostic.py
The simulator now has:
- ✅ Proper display refresh
- ✅ Interactive controls
- ✅ Real-time statistics
- ✅ Easy parameter adjustment
- ✅ Multiple automaton types
- ✅ Save functionality
Enjoy exploring self-replicating automata! 🔬✨
Created for George Dickinson's Lab - Bioinformatics & Cellular Automata Research
Built with AI assistance from Claude (Anthropic).