{"id":27211534,"url":"https://github.com/sverrenystad/boids-in-python","last_synced_at":"2025-04-10T01:29:41.160Z","repository":{"id":206992167,"uuid":"707429357","full_name":"SverreNystad/boids-in-python","owner":"SverreNystad","description":"A boids simulation made in python with dynamic scales for adjusting runtime alignment, cohesion and separation forces","archived":false,"fork":false,"pushed_at":"2023-12-17T15:52:55.000Z","size":1904,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-06T08:47:11.867Z","etag":null,"topics":["boids-simulation","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SverreNystad.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-10-19T22:06:36.000Z","updated_at":"2025-01-03T08:13:02.000Z","dependencies_parsed_at":"2023-11-13T15:50:05.710Z","dependency_job_id":null,"html_url":"https://github.com/SverreNystad/boids-in-python","commit_stats":null,"previous_names":["sverrenystad/boids-in-python"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SverreNystad%2Fboids-in-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SverreNystad%2Fboids-in-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SverreNystad%2Fboids-in-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SverreNystad%2Fboids-in-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SverreNystad","download_url":"https://codeload.github.com/SverreNystad/boids-in-python/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248140111,"owners_count":21054236,"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":["boids-simulation","python"],"created_at":"2025-04-10T01:29:40.575Z","updated_at":"2025-04-10T01:29:41.133Z","avatar_url":"https://github.com/SverreNystad.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Boid Simulation \n\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"boids.png\" width=\"400\" height=\"400\"\u003e\n\u003c/div\u003e\n\n## Description\nThis Python script simulates the complex behavior of a flock of birds, known as \"Boids\", using a few simple rules: separation, alignment, and cohesion, along with wandering behavior. The simulation utilizes the Pygame library for visualization and runs in real-time, displaying Boids as they interact with each other according to the defined parameters and behaviors.\nOne can change the three different forces during simulation by adjusting the sliders.\n\u003cdiv align=\"center\"\u003e\n  \n[![Boids moving](https://i.gyazo.com/f37a7d8c3102542ca7804a0fe605fd69.gif)](https://gyazo.com/f37a7d8c3102542ca7804a0fe605fd69)\n\u003c/div\u003e\n\n## Dependencies\n- Python 3.x\n- Pygame\n- Pygame GUI\n\n## Installation\nTo run the simulation, you need to install the dependencies. You can do this by running the following command in your terminal:\n```bash\npip install -r requirements.txt\n```\n\n## Usage\nAfter installing the dependencies, you can run the simulation by executing the script in your terminal:\n\n```bash\npython boids.py\n```\n\nThis will open a new window where you can see the Boids moving around the screen.\n\n## Configuration\nThe script contains several parameters that you can tweak to change the behavior of the Boids:\n\n- `NUM_BOIDS`: The number of Boids in the simulation.\n- `BOID_SIZE`: The size of each Boid on the screen.\n- `SPEED`: The speed at which Boids move.\n- `MAX_FORCE`: The maximum force that can be applied to a Boid for it to change direction.\n- `BOID_FRICTION`: The resistance the Boids experience, akin to friction, slowing them down over time.\n- `WANDER_RADIUS`: The radius within which a Boid will wander randomly.\n- `SEPARATION`: The degree to which Boids try to maintain distance from one another.\n- `SEPARATION_RADIUS`: The radius within which Boids will begin to experience separation force.\n- `ALIGNMENT`: The degree to which Boids try to align themselves with the average direction of nearby Boids.\n- `ALIGNMENT_RADIUS`: The radius within which Boids will begin to experience alignment force.\n- `COHESION`: The degree to which Boids try to move towards the average position of nearby Boids.\n- `COHESION_RADIUS`: The radius within which Boids will begin to experience cohesion force.\n\nFeel free to experiment with these values to observe different behaviors in the Boid flock.\n\n## How it Works\n- The script initializes a Pygame window and populates it with a number of Boid objects.\n- Each Boid has properties that determine how it interacts with others:\n  - **Separation**: Boids try to avoid crowding their neighbors.\n  - **Alignment**: Boids try to align their direction with the average heading of their neighbors.\n  - **Cohesion**: Boids try to move towards the average position of their neighbors.\n- These forces are calculated for each Boid, and a resultant force changes the Boid's direction.\n- A \"wandering\" behavior is also implemented to make the Boid's movement more natural and less uniform.\n- Boids are drawn on the screen as simple triangles, the orientation of which depends on their current velocity.\n\n## Key Components\n- `class Simulation`: Handles the initialization and running of the simulation, managing events, and updating the Pygame screen.\n- `class PhysicsObject`: An abstract class representing an object following simple physics laws.\n- `class Boid(PhysicsObject)`: Represents a Boid, inheriting from PhysicsObject, and containing methods for each behavioral rule (separation, alignment, cohesion, and wandering).\n\n## Exiting the Simulation\nYou can exit the simulation by closing the Pygame window or pressing Ctrl+C in the terminal.\n\n## License\nThis project is licensed under the MIT License. See the LICENSE file for details.\n\n## Acknowledgements\n- Craig Reynolds for the original concept of Boids.\n- The course assistant in TDT4137 Kognitive arkitekturer that the setup.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsverrenystad%2Fboids-in-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsverrenystad%2Fboids-in-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsverrenystad%2Fboids-in-python/lists"}