Skip to content

Repository files navigation


Natural Systems Simulation: Solar System & Autonomous Agents

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
  1. About The Project
  2. Lessons Learned
  3. Getting Started
  4. Usage
  5. Contact
  6. Acknowledgments

About The Project

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.

(back to top)


Built With

  • Java
  • Processing
  • Git

(back to top)


Features & Key Highlights

  • 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.

(back to top)


Lessons Learned

  • 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.

(back to top)


Getting Started

Follow these instructions to set up a local copy of the project on your machine.

Prerequisites

  • Java Development Kit 17+
  • IntelliJ IDEA or any compatible Java IDE

Installation & Running Locally

  1. Clone the repository:
    git clone https://github.com/GuilhermeGraca/java-boids-flocks-solarsystem-processing.git
  2. Open the project in your IDE: Open the root project directory java-boids-flocks-solarsystem-processing in IntelliJ IDEA or Eclipse.
  3. Configure the library dependencies: Verify that the Processing core Java library included in the project structure is linked to your build path.
  4. Select the active simulation: Open java/TP2_A51736_A51827/src/setup/ProcessingSetup.java and uncomment the desired simulation app inside the main method:
    // app = new SolarSystemApp();
    // app = new BoidApp();
    // app = new FlockComLiferancaApp();
    app = new PredadorPresaApp();
  5. Run the application: Execute the main method in ProcessingSetup.java to launch the graphical simulation window.

(back to top)


Usage

  • 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.

(back to top)


Contact

Guilherme Graça

(back to top)


Acknowledgments

  • 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.

(back to top)

About

Interactive simulation platform in Java & Processing exploring gravitational N-body physics (Solar System) and biologically-inspired autonomous flocking behaviors (Boids, Predator-Prey). Made in colaboration of Martim Ramos in the class of Modelation and Simulation of Natural Systems

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages