An interactive simulation platform in Java and Processing exploring gravitational N-body physics and biologically-inspired autonomous flocking behaviors.
Explore the Documentation »
Report Bug
·
Request Feature
Table of Contents
solarsystemDemo.mp4
Solar System Gravitational N-Body Simulation featuring the Sun, Earth, Mercury, Venus, Mars, and Halley's Comet
If the embedded video above is not displaying correctly, click here to watch/download the Solar System video demo »
boidsDemo.mp4
Individual Autonomous Steering Behaviors including Seek, Flee, Wander, Arrive, Patrol, and Evade
If the embedded video above is not displaying correctly, click here to watch/download the Boids video demo »
flocksDemo.mp4
Collective Flocking Behavior with Cohesion, Separation, Alignment, and a User-Controlled Leader
If the embedded video above is not displaying correctly, click here to watch/download the Flocking video demo »
focksPREYDemo.mp4
Multi-Agent Ecological Simulation of Flocking Prey and Pursuing Predators
If the embedded video above is not displaying correctly, click here to watch/download the Predator-Prey video demo »
This repository contains Natural Systems Simulation: Solar System & Autonomous Agents, an academic project developed from scratch in 2024 for the Modelação e Simulação de Sistemas Naturais course at ISEL (Instituto Superior de Engenharia de Lisboa), in collaboration with Martim Ramos.
The primary goal of this project is to explore computational modeling of natural phenomena by implementing physics engines and biologically-inspired artificial intelligence from scratch. The work covers four core concepts:
- Gravitational N-Body Simulation: Models celestial mechanics and orbital trajectories for the Sun, Earth, Mercury, Venus, Mars, and Halley's Comet using Newtonian gravity and numerical integration.
- Autonomous Steering Behaviors: Implements individual movement algorithms where agents calculate steering forces for seek, flee, arrive, wander, patrol, and evade behaviors.
- Flocking with Leadership: Simulates group coordination based on Craig Reynolds' Boids algorithm combining cohesion, separation, and alignment rules, extended with real-time user-controlled leadership.
- Predator and Prey Ecosystems: Integrates multi-agent ecological interactions where flocking prey agents actively avoid pursuing predators.
A comprehensive academic report written in Portuguese detailing the mathematical models, physical formulas, and algorithmic implementations is available in the repository under the doc/ directory as doc/MSSN_TP2_A51736_A51827.pdf.
- Solar System Simulation: Interactive orbital modeling of celestial bodies with realistic mass and velocity relations using Newtonian gravitational attraction.
- Autonomous Steering Agents: Modular implementation of steering behaviors including seek, flee, arrive, wander, patrol, and evade.
- Collective Flocking Algorithm: Group simulation combining cohesion, separation, and alignment to generate natural flocking dynamics.
- Interactive Leadership Control: Real-time keyboard control of a leader boid that guides the surrounding flock trajectory.
- Predator and Prey Ecosystem: Ecological simulation combining flocking prey with autonomous pursuing predators and evasion mechanics.
- Newtonian Mechanics: Consolidated practical physics concepts such as gravitational forces, mass relations, and velocity vectors to simulate orbital motion.
- Vector Mathematics: Applied 2D vectors to calculate steering forces, velocity modifications, and distances between multiple entities.
- Autonomous Agent Architecture: Built modular behavior classes that can be combined with custom weights to generate complex movement patterns.
- Simulation Loop Design: Structured a clean frame-by-frame update loop separating physics calculations from visual rendering in Processing.
Follow these instructions to set up a local copy of the project on your machine.
- Java Development Kit 17+
- IntelliJ IDEA or any compatible Java IDE
- Clone the repository:
git clone https://github.com/GuilhermeGraca/java-boids-flocks-solarsystem-processing.git
- Open the project in your IDE:
Open the root project directory
java-boids-flocks-solarsystem-processingin IntelliJ IDEA or Eclipse. - Configure the library dependencies: Verify that the Processing core Java library included in the project structure is linked to your build path.
- Select the active simulation:
Open
java/TP2_A51736_A51827/src/setup/ProcessingSetup.javaand uncomment the desired simulation app inside themainmethod:// app = new SolarSystemApp(); // app = new BoidApp(); // app = new FlockComLiferancaApp(); app = new PredadorPresaApp();
- Run the application:
Execute the
mainmethod inProcessingSetup.javato launch the graphical simulation window.
- Switching Simulations: In
ProcessingSetup.java, uncomment only one application line before running the program. - Flocking Leader Control: When running
FlockComLiferancaApp, use the keyboard arrow keys Up, Down, Left, and Right to steer the leader boid and observe how the flock follows. - Window Navigation: Close the Processing graphical window at any time to terminate the active simulation session.
Guilherme Graça
- LinkedIn: https://www.linkedin.com/in/guilherme-graça
- GitHub: https://github.com/GuilhermeGraca
- Project Link: https://github.com/GuilhermeGraca/java-boids-flocks-solarsystem-processing
- ISEL (Instituto Superior de Engenharia de Lisboa) for the academic environment, resources, and institutional support.
- Modelação e Simulação de Sistemas Naturais course instructors for their guidance throughout the semester.
- Martim Ramos for his collaboration and teamwork in developing this academic project during 2024.
- Processing Foundation for providing the Java rendering framework used in this project.
- Craig Reynolds for the foundational research on Boids and autonomous steering behaviors.