GithubHelp home page GithubHelp logo

edouardrolland / boids_simulator Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 139 KB

Predator Prey simulation using the Boids algorithm. Boids are artificial life-forms that exhibit collective behavior by following a set of rules related to separation, alignment, and cohesion. In this simulation, the boids represent prey animals, and there is an option to include a predator, which follows the boids based on these rules.

Python 100.00%
boids-simulation prey-predator pygame simulation

boids_simulator's Introduction

Boids Simulator

This is a simple Python implementation of a Predator Prey simulation using the Boids algorithm. Boids are artificial life-forms that exhibit collective behavior by following a set of rules related to separation, alignment, and cohesion. In this simulation, the boids represent prey animals, and there is an option to include a predator, which follows the boids based on these rules.

Getting Started

Make sure you have Python and Pygame installed on your system. You can install Pygame using pip:

pip install pygame

You'll also need the NumPy library for mathematical operations:

pip install numpy

Running the Simulation

Run the simulation by executing the provided code. This will open a Pygame window that shows a population of boids moving on the screen. You can adjust various parameters using the sliders on the right side of the screen.

  • Separation: Controls how much boids avoid each other.
  • Alignment: Controls how much boids align their velocity with nearby boids.
  • Cohesion: Controls how much boids move towards the center of nearby boids.
  • Turning: Controls how much boids turn when reaching screen edges.
  • Visual Range: Sets the maximum distance at which boids consider other boids in their calculations. You can modify these parameters and observe how they affect the behavior of the boids in the simulation.

Simulator

Key Components

  • Boid class: Represents an individual boid, with attributes like position, velocity, and speed limits. It has methods for avoiding edges, calculating distances between boids, implementing separation, alignment, cohesion, and more.

  • Sliders and Textboxes: These are part of the user interface to adjust the parameters of the simulation interactively.

  • Pygame: Used for creating the simulation window, drawing boids, and updating the display.

Simulation Rules

The boids follow three main rules:

  • Separation: Boids avoid getting too close to each other.
  • Alignment: Boids align their velocity with nearby boids.
  • Cohesion: Boids move towards the center of nearby boids.

By adjusting the parameters using the sliders, you can control how strongly these rules influence the boids' behavior.

Customization

Feel free to customize the code and experiment with different parameters and behaviors. You can also add new features or modify existing ones to create your own variations of the simulation.

Enjoy the Predator Prey Simulation with Boids! ๐Ÿฆ๐Ÿ”ด๐ŸŽฎ

boids_simulator's People

Contributors

edouardrolland avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.