https://github.com/hunar4321/particle-life Skip to content Toggle navigation Sign in * Product + Actions Automate any workflow + Packages Host and manage packages + Security Find and fix vulnerabilities + Codespaces Instant dev environments + Copilot Write better code with AI + Code review Manage code changes + Issues Plan and track work + Discussions Collaborate outside of code Explore + All features + Documentation + GitHub Skills + Blog * Solutions For + Enterprise + Teams + Startups + Education By Solution + CI/CD & Automation + DevOps + DevSecOps Resources + Learning Pathways + White papers, Ebooks, Webinars + Customer Stories + Partners * Open Source + GitHub Sponsors Fund open source developers + The ReadME Project GitHub community articles Repositories + Topics + Trending + Collections * Pricing Search or jump to... Search code, repositories, users, issues, pull requests... Search [ ] Clear Search syntax tips Provide feedback We read every piece of feedback, and take your input very seriously. [ ] [ ] Include my email address so I can be contacted Cancel Submit feedback Saved searches Use saved searches to filter your results more quickly Name [ ] Query [ ] To see all available qualifiers, see our documentation. Cancel Create saved search Sign in Sign up You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert {{ message }} hunar4321 / particle-life Public * Notifications * Fork 253 * Star 2.2k A simple program to simulate artificial life using attraction/ reuplsion forces between many particles License MIT license 2.2k stars 253 forks Activity Star Notifications * Code * Issues 13 * Pull requests 0 * Discussions * Actions * Projects 0 * Security * Insights Additional navigation options * Code * Issues * Pull requests * Discussions * Actions * Projects * Security * Insights hunar4321/particle-life This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository. main Switch branches/tags [ ] Branches Tags Could not load branches Nothing to show {{ refName }} default View all branches Could not load tags Nothing to show {{ refName }} default View all tags Name already in use A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch? Cancel Create 1 branch 3 tags Code * Local * Codespaces * Clone HTTPS GitHub CLI [https://github.com/h] Use Git or checkout with SVN using the web URL. [gh repo clone hunar4] Work fast with our official CLI. Learn more about the CLI. * Open with GitHub Desktop * Download ZIP Sign In Required Please sign in to use Codespaces. Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Launching Xcode If nothing happens, download Xcode and try again. Launching Visual Studio Code Your codespace will open once ready. There was a problem preparing your codespace, please try again. Latest commit @hunar4321 hunar4321 winidows binary ... 8b64fcc Dec 21, 2022 winidows binary 8b64fcc Git stats * 309 commits Files Permalink Failed to load latest commit information. Type Name Latest commit message Commit time images Add files via upload August 24, 2022 12:49 particle_life winidows binary December 21, 2022 15:31 .gitignore binary without avx512 for you guys with cpu gen > 11 December 19, 2022 18:45 LICENSE Initial commit August 10, 2022 10:28 README.md QB64-PE port added December 1, 2022 01:27 particle_life.html Merge branch 'main' into pulse October 12, 2022 12:22 particle_life.py commented September 5, 2022 17:33 particle_life_3d.html Revert "Rename particle_life_3d.html to javascript/ particle_life_3d.h... September 5, 2022 17:30 View code [ ] Particle Life Simulation Learn More Here (YouTube video tutorial): Online Demo (JavaScript version): Interface (C++ version) Example Results Some Interesting Patterns to Reproduce: To use: Code: Other Ports: The JavaScript code is as simple as this: Todos: README.md GitHub repo size GitHub Particle Life Simulation A simple program to simulate primitive Artificial Life using simple rules of attraction or repulsion among atom-like particles, producing complex self-organzing life-like patterns. Excluding the GUI elements, the code is less than a page. The video tutorial and walkthrough are available below. Learn More Here (YouTube video tutorial): https://youtu.be/0Kx4Y9TVMGg Online Demo (JavaScript version): Click here for a live demo (JavaScript): * 2d - https://hunar4321.github.io/particle-life/particle_life.html * 3d - https://hunar4321.github.io/particle-life/ particle_life_3d.html Interface (C++ version) [interface] Example Results [big_pic] Some Interesting Patterns to Reproduce: You do not need to be exact with the parameters to reproduce these patterns. The best way to get interesting patterns is to first try random parameter explorations, once you find an interesting pattern, try fine-tuning it gradually. To avoid becoming stuck at a local maximum, you can make some occasional big parameter jumps. In this way interesting and different patterns shall keep poping up. [some_patte] To use: Download this repo. unzip the file then go to /particle_life/bin/ folder and click on particle_life.exe Code: The source code is available in C++, JavaScript, and Python. Watch this YouTube video for a walkthrough tutorial: https://youtu.be/ 0Kx4Y9TVMGg If you would like to contribute to the C++ program, the core algorithm is the first 100 lines of code at: "/particle_life/src/ ofApp.cpp". The rest are GUI components and rendering controls which are provided by the openFrameworks library an opensource and easy-to-use image rendering library. To start, download this repository then download openFrameworks library from here: https://openframeworks.cc/. Use openFramework's projectGenerator and import /particle_life/ folder to the project. Alternatively, generate a new openFramework project and add ofxGui. Once the project files are generated replace the /src/ folder with the one provided here. You can now compile the C++ code on your machine. Other Ports: * Godot * Rust * Go-1, Go-2, Go-3 * Python * Lua * QB64-PE * Webgl * Java * C# Winforms * FreeBasic The JavaScript code is as simple as this: Also, look at the particle_life.html file for a more optimized version - thanks to those who have contributed. Related topics: Particle Life Simulation, Primordial Soup - Evolution, Conway's game of life, Cellular automata, Self organzing patterns, This project was inspired by: Jeffery Ventrella's Clusters http:// www.ventrella.com/Clusters/. I do not have access to Ventrella's code but I guess the main difference of this project from the other particle life projects is that I did not implement collision detection and this made simulating thousands of particles possible in real-time. Also, I added GUI controls to change the parameters in real-time allowing easy fine-tuning and exploration, hence, I was able to find some never-seen-before patterns emerge form some extremely simple models of relations. The code here is probably an order of magnitude simpler than any other Artificial Life codes out there because I started this code solely as an educational material for non-programmers and general audience to prove the point that complexity can arise from simplicity. Todos: 1. Adding the ability to save and load parameters (so that people can easily share the interesting models they find) 2. Ability to add more particle types (currently it is fixed to four particle types) 3. Currently, the biggest bottleneck is the nested for-loops (which calculate the pairwise distance among all particles) making the computational complexity quadratic. It would be amazing if we could find a way around. 4. Alternative to point 3, computing the pairwise distances are embarrassingly parallel so it can be computed on GPU. 5. Adding the ability to resize the screen and improving boundary-checking as many fast moving particles can escape the screen bounds. 6. Adding a more intuitive UI so that it gives the ability for a finer control over the parameters. 7. Adding a randomize button or, even better, having a simple meta rule to mutate the initial rule continously and recursively. This way the patterns will never get stuck on a local maximum and will keep changing! 8. A better way to fine-tune is to use an evolutionary algorithm to select and optimize the parameters but one needs to write a fitness function for that. I currently don't know what fitness function corresponds to in the realm of this program. In our world the fitness function is competition and survival of the fittest. However, here we fine-tune and select the parameters that produce interesting patterns for us but the word "interesting" is easier to say than to define! About A simple program to simulate artificial life using attraction/ reuplsion forces between many particles Topics javascript game-of-life cpp simulation cellular-automata particles educational generative-art particle-life Resources Readme License MIT license Activity Stars 2.2k stars Watchers 28 watching Forks 253 forks Report repository Releases 3 Particle Life (C++) Latest Nov 16, 2022 + 2 releases Packages 0 No packages published Contributors 12 * @hunar4321 * @ker2x * @AnasQiblawi * @skal65535 * @dangarfield * @dlatikaynen * @rpominov * @esrrhs * @brandleesee * @arduano * @TheKiromen * @EDB02 Languages * HTML 61.5% * C++ 35.6% * Python 2.9% Footer (c) 2023 GitHub, Inc. Footer navigation * Terms * Privacy * Security * Status * Docs * Contact * Manage cookies * Do not share my personal information You can't perform that action at this time.