{"id":28446479,"url":"https://github.com/phmatray/lenia","last_synced_at":"2025-06-30T01:31:58.446Z","repository":{"id":296087391,"uuid":"992243515","full_name":"phmatray/lenia","owner":"phmatray","description":"A high-performance, real-time implementation of Lenia - a fascinating continuous cellular automaton that creates complex, lifelike patterns. Built with Blazor WebAssembly and MudBlazor for a modern, interactive web experience.","archived":false,"fork":false,"pushed_at":"2025-05-28T22:32:01.000Z","size":11237,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-06T10:46:44.728Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phmatray.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2025-05-28T21:03:20.000Z","updated_at":"2025-05-28T22:30:45.000Z","dependencies_parsed_at":"2025-05-28T23:34:07.450Z","dependency_job_id":null,"html_url":"https://github.com/phmatray/lenia","commit_stats":null,"previous_names":["phmatray/lenia"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/phmatray/lenia","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phmatray%2Flenia","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phmatray%2Flenia/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phmatray%2Flenia/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phmatray%2Flenia/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phmatray","download_url":"https://codeload.github.com/phmatray/lenia/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phmatray%2Flenia/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262693217,"owners_count":23349695,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-06T10:41:40.193Z","updated_at":"2025-06-30T01:31:58.414Z","avatar_url":"https://github.com/phmatray.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🧬 Lenia - Artificial Life Simulation\n\n[![.NET](https://img.shields.io/badge/.NET-9.0-blue.svg)](https://dotnet.microsoft.com/download/dotnet/9.0)\n[![Blazor](https://img.shields.io/badge/Blazor-WebAssembly-purple.svg)](https://blazor.net/)\n[![MudBlazor](https://img.shields.io/badge/MudBlazor-8.6.0-orange.svg)](https://mudblazor.com/)\n[![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)\n\nA high-performance, real-time implementation of **Lenia** - a fascinating continuous cellular automaton that creates complex, lifelike patterns. Built with Blazor WebAssembly and MudBlazor for a modern, interactive web experience.\n\n![Lenia Demo](screenshots/lenia.png)\n\n## ✨ Features\n\n### 🚀 High-Performance Engine\n- **60 FPS Target**: Optimized for smooth real-time simulation\n- **Adaptive Quality**: Automatically adjusts processing quality to maintain performance\n- **Multi-threaded Processing**: Utilizes all CPU cores for maximum speed\n- **Scalable Grid**: Dynamic grid sizing from 24×24 to 128×128\n- **Memory Optimized**: Efficient algorithms with minimal allocations\n\n### 🎨 Modern UI\n- **Dark Theme**: Professional dark interface with custom purple accent\n- **Real-time Metrics**: Live FPS, update time, and render time monitoring\n- **Responsive Design**: Works beautifully on desktop and mobile\n- **Material Design**: Clean, intuitive interface using MudBlazor components\n- **Interactive Controls**: Sliders, buttons, and toggles for all parameters\n\n### 🧪 Scientific Accuracy\n- **Authentic Lenia Mathematics**: Implements the original Lenia formulas\n- **Configurable Physics**: Adjust radius (R), time step (Δt), growth parameters (μ, σ)\n- **Pattern Presets**: Pre-configured Orbium and Geminium patterns\n- **Custom Initialization**: Circle patterns and random seeding\n\n## 🎮 Demo\n\nTry the live demo: **[Lenia Simulation](https://phmatray.github.io/Lenia/)**\n\n## 🛠️ Technologies\n\n- **[.NET 9.0](https://dotnet.microsoft.com/)** - Modern, cross-platform framework\n- **[Blazor WebAssembly](https://blazor.net/)** - Client-side web UI with C#\n- **[MudBlazor](https://mudblazor.com/)** - Material Design component library\n- **[JavaScript Interop](https://docs.microsoft.com/en-us/aspnet/core/blazor/javascript-interoperability)** - High-performance canvas rendering\n\n## 🚀 Getting Started\n\n### Prerequisites\n- [.NET 9.0 SDK](https://dotnet.microsoft.com/download/dotnet/9.0)\n- A modern web browser (Chrome, Firefox, Safari, Edge)\n\n### Installation\n\n1. **Clone the repository**\n   ```bash\n   git clone https://github.com/phmatray/lenia.git\n   cd lenia\n   ```\n\n2. **Restore dependencies**\n   ```bash\n   dotnet restore\n   ```\n\n3. **Run the application**\n   ```bash\n   cd Lenia/Lenia\n   dotnet run\n   ```\n\n4. **Open your browser**\n   Navigate to `https://localhost:5001` or `http://localhost:5000`\n\n## 🎯 Usage\n\n### Basic Controls\n- **Play/Pause**: Click the play button in the top bar or main controls\n- **Reset**: Clear the grid and start fresh\n- **Patterns**: Choose from Circle, Orbium, or Geminium presets\n\n### Physics Parameters\n- **Radius (R)**: Neighborhood size for cell interactions (2.0 - 10.0)\n- **Time Step (Δt)**: Simulation speed multiplier (0.01 - 0.5)\n- **Growth μ**: Peak of the growth function (0.0 - 0.5)\n- **Growth σ**: Width of the growth function (0.001 - 0.1)\n\n### Performance Settings\n- **Grid Size**: Adjust from 24×24 to 128×128 cells\n- **Target FPS**: Set desired frame rate (10-120 FPS)\n- **Adaptive Quality**: Auto-adjust processing quality for consistent performance\n\n## 🔬 About Lenia\n\nLenia is a continuous cellular automaton discovered by Bert Wang-Chak Chan. Unlike traditional cellular automata (like Conway's Game of Life), Lenia uses:\n\n- **Continuous values** instead of binary states\n- **Smooth kernels** for neighborhood calculations  \n- **Differential equations** for state updates\n- **Real-valued time** for fluid evolution\n\nThis creates remarkably lifelike behaviors including:\n- Self-organization and emergence\n- Glider-like moving patterns\n- Complex interactions and collisions\n- Adaptive and evolutionary dynamics\n\n### Mathematical Foundation\n\n```\nUpdate Rule: A^(t+Δt)(x) = clip(A^t(x) + Δt × G(U^t(x)), 0, 1)\n\nWhere:\n- A^t(x): Cell state at time t and position x\n- U^t(x): Local neighborhood potential\n- G(u): Growth function G(u; μ, σ) = 2×exp(-((u-μ)/σ)²/2) - 1\n- Δt: Time step size\n```\n\nFor more details, see the [original paper](https://arxiv.org/abs/1812.05433).\n\n## 🏗️ Architecture\n\n```\n├── Lenia/                          # Server-side Blazor Web App\n│   ├── Components/\n│   │   └── App.razor              # Main application shell\n│   ├── Program.cs                 # Server configuration\n│   └── Lenia.csproj              # Server project file\n│\n├── Lenia.Client/                   # Client-side Blazor WebAssembly\n│   ├── Components/\n│   │   └── LeniaCanvas.razor      # Canvas rendering component\n│   ├── Pages/\n│   │   └── Home.razor             # Main simulation page\n│   ├── Layout/\n│   │   └── MainLayout.razor       # App layout with dark theme\n│   ├── wwwroot/\n│   │   └── leniaCanvas.js         # High-performance canvas rendering\n│   ├── LeniaScalable.cs          # Optimized simulation engine\n│   ├── Program.cs                 # Client configuration\n│   └── Lenia.Client.csproj       # Client project file\n│\n└── README.md                       # This file\n```\n\n## ⚡ Performance Optimizations\n\n### Simulation Engine\n- **Float Precision**: Uses `float` instead of `double` for 2× memory bandwidth\n- **Pre-computed Kernels**: Kernel weights calculated once and cached\n- **Parallel Processing**: Multi-threaded updates using `Parallel.For`\n- **Chunked Processing**: Large grids processed across multiple frames\n- **Adaptive Quality**: Dynamic reduction of processed cells when needed\n\n### Rendering\n- **JavaScript Interop**: Direct canvas manipulation for maximum speed\n- **ImageData Optimization**: Efficient pixel buffer updates\n- **Hardware Scaling**: GPU-accelerated canvas scaling\n- **Minimal Allocations**: Reused buffers and optimized memory access\n\n## 🤝 Contributing\n\nContributions are welcome! Here's how to get started:\n\n1. **Fork the repository**\n2. **Create a feature branch**: `git checkout -b feature/amazing-feature`\n3. **Make your changes**: Follow the existing code style\n4. **Add tests**: Ensure your changes don't break existing functionality\n5. **Commit your changes**: `git commit -m 'Add amazing feature'`\n6. **Push to the branch**: `git push origin feature/amazing-feature`\n7. **Open a Pull Request**: Describe your changes and why they're awesome\n\n### Development Guidelines\n- Follow C# coding conventions\n- Use MudBlazor components for UI consistency\n- Maintain 60 FPS performance target\n- Add XML documentation for public APIs\n- Include unit tests for new features\n\n## 📝 License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## 🙏 Acknowledgments\n\n- **Bert Wang-Chak Chan** - Original Lenia research and discovery\n- **MudBlazor Team** - Excellent Blazor component library\n- **Microsoft** - .NET and Blazor frameworks\n- **Blazor Community** - Inspiration and best practices\n\n## 📚 References\n\n- [Lenia - Biology of Artificial Life](https://arxiv.org/abs/1812.05433) - Original paper\n- [Lenia and Expanded Universe](https://arxiv.org/abs/2005.03742) - Extended research\n- [Bert Chan's YouTube Channel](https://www.youtube.com/c/BertChakovsky) - Lenia demonstrations\n- [MudBlazor Documentation](https://mudblazor.com/) - UI component reference\n\n## 🐛 Issues \u0026 Support\n\n- **Bug Reports**: [GitHub Issues](https://github.com/phmatray/lenia/issues)\n- **Feature Requests**: [GitHub Discussions](https://github.com/phmatray/lenia/discussions)\n- **Documentation**: [Wiki](https://github.com/phmatray/lenia/wiki)\n\n---\n\n\u003cdiv align=\"center\"\u003e\n\n**[⭐ Star this repository](https://github.com/phmatray/lenia/stargazers)** if you find it interesting!\n\nMade with ❤️ and lots of ☕ by [Philippe Matray](https://github.com/phmatray)\n\n\u003c/div\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphmatray%2Flenia","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphmatray%2Flenia","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphmatray%2Flenia/lists"}