{"id":19825538,"url":"https://github.com/capeddemon/particle-life","last_synced_at":"2025-06-14T00:05:31.879Z","repository":{"id":138097154,"uuid":"551838672","full_name":"CapedDemon/Particle-life","owner":"CapedDemon","description":"Particle life with Python","archived":false,"fork":false,"pushed_at":"2023-09-26T08:24:03.000Z","size":4031,"stargazers_count":12,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-06T14:12:51.698Z","etag":null,"topics":["ai","gui","math","particles","physics","python","simulation"],"latest_commit_sha":null,"homepage":"","language":"Python","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/CapedDemon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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}},"created_at":"2022-10-15T07:43:31.000Z","updated_at":"2025-03-30T12:00:26.000Z","dependencies_parsed_at":null,"dependency_job_id":"6b498a18-b21c-4152-9150-0c898e8e6099","html_url":"https://github.com/CapedDemon/Particle-life","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/CapedDemon/Particle-life","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CapedDemon%2FParticle-life","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CapedDemon%2FParticle-life/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CapedDemon%2FParticle-life/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CapedDemon%2FParticle-life/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CapedDemon","download_url":"https://codeload.github.com/CapedDemon/Particle-life/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CapedDemon%2FParticle-life/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259737919,"owners_count":22903873,"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":["ai","gui","math","particles","physics","python","simulation"],"created_at":"2024-11-12T11:08:00.866Z","updated_at":"2025-06-14T00:05:31.617Z","avatar_url":"https://github.com/CapedDemon.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n    \u003ch1\u003eParticle Life\u003c/h1\u003e\u003ch5\u003e An A.I. simulation of particles 🎇\u003c/h5\u003e\n    \u003cimg src=\"https://img.shields.io/github/stars/Shreejan-35/Particle-life?style=for-the-badge\"\u003e\u003c/img\u003e \u003cimg src=\"https://img.shields.io/readthedocs/pip?style=for-the-badge\"\u003e\u003c/img\u003e \u003cimg src=\"https://img.shields.io/maintenance/yes/2022?style=for-the-badge\"\u003e\u003c/img\u003e \u003cimg src=\"https://img.shields.io/github/license/Shreejan-35/Particle-life?style=for-the-badge\"\u003e\u003c/img\u003e\u003c/br\u003e\n    \u003ca href=\"#\"\u003e\u003cimg src=\"https://forthebadge.com/images/badges/built-with-love.svg\" /\u003e\u003c/a\u003e\u0026nbsp;\u0026nbsp;\n  \u003ca href=\"#\"\u003e\u003cimg src=\"https://forthebadge.com/images/badges/made-with-python.svg\" /\u003e\u003c/a\u003e\u0026nbsp;\u0026nbsp;\n\u003c/div\u003e\n\n\n\u003cdetails\u003e\n  \u003csummary\u003eTable of Contents\u003c/summary\u003e\n  \u003col\u003e\n    \u003cli\u003e\n      \u003ca href=\"#documentation\"\u003eDocumentation\u003c/a\u003e\n      \u003cul\u003e\n        \u003cli\u003e\u003ca href=\"#libraries\"\u003eLibraries\u003c/a\u003e\u003c/li\u003e\n\t\t\u003cli\u003e\u003ca href=\"#code-explanation\"\u003eCode Explanation\u003c/a\u003e\u003c/li\u003e\n\t\t\u003cli\u003e\u003ca href=\"#rendering-particles\"\u003eRendering Particles\u003c/a\u003e\u003c/li\u003e\n\t        \u003cli\u003e\u003ca href=\"#main-rules\"\u003eMain Rules\u003c/a\u003e\u003c/li\u003e\n\t\t\u003cli\u003e\u003ca href=\"#simulation\"\u003eSimulation\u003c/a\u003e\u003c/li\u003e\n      \u003c/ul\u003e\n    \u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#examplestests\"\u003eExamples/Tests\u003c/a\u003e\n\t\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#installation\"\u003eInstallation\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#contributing\"\u003eContributing\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#support\"\u003eSupport\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#license\"\u003eLicense\u003c/a\u003e\u003c/li\u003e\n  \u003c/ol\u003e\n\u003c/details\u003e\n\n## Documentation\n\nParticle Life is just a simple python script.\nIt makes a window and shows different movement of particles,\nwhose rules are defined by us while writing the code. It is a simple\npython script in which I have implemented OOP.\n\n### Libraries\n\nThe python libraries that are used are :-\n\n- pygame\n\n  - `pip3 install pygame`\n\n- math\n- random\n\n### Code explanation\n\n- A `Particle` class is there which takes -\n  - true for running the while loop\n  - width of screen\n  - height of screen\n  - color of screen in rgb in this case - `rgb(0,0,0)`\n- `createParticle` function - This renders a particle in the screen with specific color and coordinates\n- `returnParticle` function - Returns a dict consisting of x,y,color,velocityX,velocityY\n- `manyParticles` function - Returns a list of particles consisting of the above dictionary with random x and y positions\n- `createParticles` function - Creates all the particles in the list returned above using the `createParticle` function\n- `mainRule` function - Uses physics and maths formula to attract the particles towards each other and reflect back the particles by using the value of `g`\n  - Formula Used:-\n    - F = GMm/r^2\n    - squareroot[(x2-x1)^2 + (y2-y1)^2]\n    - F = ma\n  - Important things -\n    - g is -ve if the particles are attracted\n    - g is +ve if the particles are repelling each other\n\n### Rendering Particles\n- To render particles two things we need to run -\n\n  - `self.yellowParticles = self.manyParticles(200, self.yellow)` - To get the list of particles\n  - `self.createParticles(self.yellowParticles)` - To render the particles, used in the while loop\n  \n### Main Rules\n- To write the mainrules, we need to give 3 arguements - particles list1, particle list2, g\n  - `self.mainRule(self.yellowParticles, self.yellowParticles, -0.1)` - Here yellow particles are attracted by each other by a small force of 0.1\n\n### Simulation\n\nYou can simulate the particle animation by writing the mainrule, rendering particles and defining colors.\n\n- Define colors\n\n  - `self.yellow = (255, 255, 0)` - It should be written in `def __init__`\n\n- About Rendering particles you can get the information above\n- Write your mainrules as you want in the while loop\n\n## Examples/Tests\n*This are some of the tests that are done.*\n\n|                                                                                                                                                    First Test Case                                                                                                                                                     |                                                                                                                                                                                                             Second Test Case                                                                                                                                                                                                              |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               Third Test Case                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |\n| :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |\n|                                                                                                                     ![](https://github.com/Shreejan-35/Particle-life/blob/master/images/first.gif)                                                                                                                     |                                                                                                                                                                              ![](https://github.com/Shreejan-35/Particle-life/blob/master/images/second.gif)                                                                                                                                                                               |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               ![](https://github.com/Shreejan-35/Particle-life/blob/master/images/third.gif)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |\n| `self.mainRule(self.redParticles, self.redParticles, -0.1) self.mainRule(self.yellowParticles, self.redParticles, 0.01) self.mainRule(self.redParticles, self.yellowParticles, -0.01) self.mainRule(self.yellowParticles, self.yellowParticles, -0.1) self.mainRule(self.yellowParticles, self.yellowParticles, 0.01)` | `self.mainRule(self.redParticles, self.redParticles, 0.1) self.mainRule(self.yellowParticles, self.redParticles, -0.12) self.mainRule(self.greenParticles, self.greenParticles, -0.7) self.mainRule(self.greenParticles, self.redParticles, -0.2) self.mainRule(self.redParticles, self.greenParticles, -0.1) self.mainRule(self.greenParticles, self.greenParticles, 0.10) self.mainRule(self.redParticles, self.yellowParticles, 0.09)` | `self.mainRule(self.yellowParticles, self.yellowParticles, 0.1) self.mainRule(self.blueParticles, self.blueParticles, 0.1) self.mainRule(self.blueParticles, self.yellowParticles, -0.12) self.mainRule(self.yellowParticles, self.blueParticles, 0.01) self.mainRule(self.yellowParticles, self.greenParticles, 0.1) self.mainRule(self.blueParticles, self.greenParticles, -0.23) self.mainRule(self.blueParticles, self.redParticles, -0.2) self.mainRule(self.redParticles, self.blueParticles, -0.1) self.mainRule(self.greenParticles, self.blueParticles, 0.12) self.mainRule(self.redParticles, self.redParticles, 0.1) self.mainRule(self.yellowParticles, self.redParticles, -0.12) self.mainRule(self.greenParticles, self.greenParticles, -0.7) self.mainRule(self.greenParticles, self.redParticles, -0.2) self.mainRule(self.redParticles, self.greenParticles, -0.1) self.mainRule(self.greenParticles, self.yellowParticles, 0.13) self.mainRule(self.greenParticles, self.greenParticles, 0.10) self.mainRule(self.redParticles, self.yellowParticles, 0.09) self.mainRule(self.yellowParticles, self.redParticles, -0.2)` |\n\n## Installation\n\nThe Installation is pretty easy.\n\n- Make a directory in your computer to store the files.\n- Go into the directory and clone the git repository\n\n```\ngit clone https://github.com/CapedDemon/Particle-life.git\n```\n\n- Open your favourite terminal, and type this commands\n\n```\npip3 install requirements.txt\n```\n\nThen,\n\n```\npython3 particle.py\n```\n\n## Contributing\n\nContributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.\n\nIf you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag \"enhancement\".\nDon't forget to give the project a star! Thanks again!\n\n1. Fork the Project\n2. Create your Feature Branch (`git checkout -b any-name`)\n3. Commit your Changes (`git commit -m 'Add some advices'`)\n4. Push to the Branch (`git push origin`)\n5. Open a Pull Request\n\n## Support\nSupport me by following me and giving a ✨ to this repo.\n\n## License\n\nMIT LICENSE\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcapeddemon%2Fparticle-life","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcapeddemon%2Fparticle-life","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcapeddemon%2Fparticle-life/lists"}