How gsg211/falling-particle works
1. Project shape
This is a single-process Java simulation built on the Processing runtime (lib/core.jar). It is not split into services or modules; the whole app lives in src/ and runs as one interactive sketch.
2. Entry point and runtime
src/Main.java is the application entry point. It likely initializes the Processing window, drives the frame loop, and hands control to the simulation world. The simulation is therefore frame-based and interactive, not batch or server-driven.
3. Core world model
src/Materials/Grid/MaterialGrid.java is the central subsystem. It represents the 2D cellular world where particles occupy discrete cells and update based on local neighborhood rules. Most simulation flow should be understood as: read current grid state, compute material interactions, then write the next state.
4. Material abstraction
src/Materials/Material.java is the base type for everything that can exist in the grid. The enums MaterialStates.java and MaterialTypes.java provide the classification layer used to distinguish behavior categories such as solid, liquid, gas, powder, energy, and empty space.
5. Behavior families
The package layout reflects separate movement/interaction rules:
• Solids/ for mostly fixed materials like Wood
• Liquids/ for flowing materials like Water
• Gasses/ for rising/dispersing materials like Steam
• Powders/ for granular materials like Sand, WetSand, and Ash
• Energy/ for transient effects like Fire
• Empty.java for unoccupied cells
6. Simulation mechanics
The main mechanic is local particle physics: gravity, settling, flowing, rising, and exchanging positions with neighboring cells. The existence of WetSand and BurningMaterial suggests materials can change state or behavior when interacting with nearby particles, not just move independently.
7. Reaction and transformation layer
The repository’s chemistry-inspired behavior is encoded as material-to-material interactions. Examples implied by the model:
• Wood can transition into a burning state via BurningMaterial
• Fire acts as an energetic, temporary agent
• Water can affect solids/powders and may produce Steam
• Sand can become WetSand when exposed to liquids
• Ash is a post-combustion residue
This implies the grid update has a reaction phase in addition to movement.
8. State progression model
The architecture is likely driven by per-material update logic: each material decides how it behaves when ticked and what it turns into when conditions change. That means the grid is the shared state container, while each material class encapsulates its own rules.
9. Boundary between engine and content
The engine boundary is clean: MaterialGrid and Material define the simulation framework, while concrete subclasses define the content and rules. Adding a new particle type should mostly involve adding a new Material subtype rather than changing the whole engine.
10. Rendering and interaction
Because the project uses Processing, rendering and user interaction are probably handled in the sketch layer (Main.java) alongside simulation stepping. The visual output is likely a direct grid-to-pixel mapping, with each material rendered by color or style.
11. External dependencies and tooling
The only visible external runtime dependency is Processing (core.jar). There is no sign of database, networking, or build orchestration complexity; this appears to be a local desktop simulation project.
12. What an architecture diagram should show
A good diagram would place Main at the top, feeding a frame loop into MaterialGrid, which contains the 2D cell state. Around the grid, show the material hierarchy and the interaction paths between categories: movement, collision, reaction, and transformation. The main data flow is grid state in → per-cell material rules → updated grid state out, repeated every frame.
Main entry points: Material.java Material · Wood.java Wood · Water.java Water · MaterialGrid.java Material Grid
Components 19
Runtime
Processing sketch entry and display loop
- Main · Entry point and frame loop
src/Main.java - Processing · External sketch runtime
lib/core.jar
Core simulation
Shared grid state and material abstractions
- Material Grid · 2D grid of cells and per-frame simulation state
src/Materials/Grid/MaterialGrid.java - Material · Common behavior and identity for all grid occupants
src/Materials/Material.java - States · Material state categories
src/Materials/MaterialStates.java - Types · Material type categories
src/Materials/MaterialTypes.java - Empty · Unoccupied grid cell
src/Materials/Empty.java
Material families
Behavior families and concrete particle types
- Solid · Base behavior for fixed or mostly fixed materials
src/Materials/Solids/Solid.java - Liquid · Base behavior for flowing materials
src/Materials/Liquids/Liquid.java - Gas · Base behavior for dispersing materials
src/Materials/Gasses/Gas.java - Powder · Base behavior for granular materials
src/Materials/Powders/Powder.java - Wood · Static solid that can burn
src/Materials/Solids/Wood.java - Burning · Burning state of a solid material
src/Materials/Solids/BurningMaterial.java - Water · Flowing liquid that interacts with powders and solids
src/Materials/Liquids/Water.java - Steam · Transient gas produced by heating or evaporation
src/Materials/Gasses/Steam.java - Sand · Granular falling particle
src/Materials/Powders/Sand.java - Wet Sand · Sand altered by liquid contact
src/Materials/Powders/WetSand.java - Ash · Combustion residue particle
src/Materials/Powders/Ash.java - Fire · Transient energetic agent that propagates reactions
src/Materials/Energy/Fire.java
Connections 26
- Processing → Main: hosts · Processing runtime executes the sketch
- Main → Material Grid: ticks · Main drives per-frame world updates
- Main → Material Grid: renders · Main likely draws the grid each frame
- Material Grid → Material: stores · Grid cells hold material instances
- Material Grid → Empty: fills · Unoccupied cells are represented explicitly
- Material → States: classified by · Materials are tagged by state category
- Material → Types: classified by · Materials are tagged by type category
- Solid → Material: extends · Solid family inherits shared material behavior
- Liquid → Material: extends · Liquid family inherits shared material behavior
- Gas → Material: extends · Gas family inherits shared material behavior
- Powder → Material: extends · Powder family inherits shared material behavior
- Wood → Solid: is a · Concrete solid material
- Burning → Solid: is a · Derived burning solid state
- Water → Liquid: is a · Concrete liquid material
- Steam → Gas: is a · Concrete gas material
- Sand → Powder: is a · Concrete granular material
- Wet Sand → Powder: is a · Liquid-altered granular material
- Ash → Powder: is a · Combustion residue material
- Fire → Material: specializes · Transient energy-like material behavior
- Wood → Burning: transforms to · Heat or fire can ignite wood
- Water → Steam: transforms to · Heating or evaporation can produce steam
- Sand → Wet Sand: absorbs · Contact with water alters sand behavior
- Wood → Ash: combusts to · Combustion can leave ash residue
- Fire → Wood: ignites · Fire triggers burning reactions in solids
- Fire → Water: heats · Fire can drive evaporation or phase change
- Water → Sand: wets · Water changes powder state and mobility