A JavaScript-based simulation of the Vicsek model, showcasing collective behavior and self-organization in particle systems. The project includes interactive controls to modify simulation parameters and visualize the effects in real time.
- Play/Pause Simulation: Start or pause the simulation.
- Dynamic Controls: Adjust parameters such as interaction radius, particle speed, and noise.
- Restart Button: Regenerate the simulation with a new set of random particles.
Represents individual particles with attributes:
- x, y: Position on the canvas.
- angle: Direction of movement.
Includes a
move()method to update the particle's position based on its angle and speed.
Generates a randomized set of particles with initial positions and directions.
Identifies particles within a defined radius of the given particle.
Computes the average direction of neighbors to align the particle's direction.
Updates each particle's angle based on the average direction of neighbors, with added randomness (noise), and moves them accordingly.
Clears the canvas and draws particles as small circles.
Runs the simulation, updating and drawing particles continuously. Pauses if the simulation is toggled off.
Toggles the running state, controlling whether the simulation updates.
Resets the simulation with a fresh set of randomized particles.
- Radius: Adjusts the interaction range for neighbor detection.
- Speed: Changes particle movement speed.
- Noise: Controls randomness in direction changes.
- Buttons and sliders are linked to functions that modify simulation parameters in real time.
- Open
index.htmlin a web browser. - Use the provided controls to interact with the simulation:
- Start or stop the animation.
- Adjust sliders to observe effects on behavior.
- Restart the simulation to generate a new particle set.
This project is inspired by concepts from the Vicsek model. For more details, refer to the article:
Original Reference Material
- Add more particle interaction rules.
- Implement additional visualization options.
- Optimize performance for larger particle systems.
Enjoy experimenting with the Vicsek model simulation!