Skip to content

Dreckhoff/cellular-automaton-game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cellular Automaton Water Simulation

A simple interactive water simulation game built with Python and Pygame, featuring cellular automaton physics.

Features

  • Interactive Water Spawning: Left-click and drag to spray water particles
  • Gravity Physics: Water falls down realistically with momentum
  • Lateral Flow: Water spreads sideways when it hits obstacles
  • Obstacle Drawing: Right-click to draw solid walls and platforms
  • Clear Function: Reset the simulation with a keypress

Installation

  1. Make sure you have Python 3.7+ installed
  2. The virtual environment and dependencies are already set up in the venv folder

If you need to reinstall dependencies:

python3 -m venv venv
./venv/bin/pip install -r requirements.txt

Usage

Run the simulation using the provided script:

./run.sh

Or run directly:

./venv/bin/python main.py

Controls

  • Left Mouse Button: Spawn water (hold and drag for continuous spray)
  • Right Mouse Button: Draw solid obstacles/walls
  • SPACE or C: Clear all water and obstacles
  • ESC: Quit the application

How It Works

This simulation uses a cellular automaton approach where the screen is divided into a grid of cells. Each cell can be:

  • Empty (air)
  • Water (blue liquid particles)
  • Solid (gray obstacles)

The water physics includes:

  • Gravity: water falls downward
  • Momentum: falling water maintains horizontal velocity
  • Lateral spreading: water flows sideways when blocked
  • Natural flow dynamics

Technical Details

  • Grid Size: 100x80 cells
  • Cell Size: 10 pixels
  • Window Size: 1000x800 pixels
  • Target FPS: 60
  • Physics Updates: Every frame

Enjoy experimenting with fluid dynamics!

About

Interactive water simulation using cellular automaton physics, built with Python and Pygame

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors