Skip to content

Latest commit

 

History

History
61 lines (48 loc) · 3.13 KB

File metadata and controls

61 lines (48 loc) · 3.13 KB

Waterflow simulation

Table of Contents

Description

A multi-threaded implementation of a waterflow simulation that shows how water flows on a terrain flows downhill.

Live Demo

A live interactive demo can be found below.

Features

  • Display
     A main display window that shows the landscape as a greyscale image, with black representing the lowest elevation and white the highest. Overlaid on this should be an image representing the locations of water in blue. Note that although the water will have a depth, represented as an integer value, the colouring is the same uniform blue for any depth value greater than zero.

  • Buttons
     A ‘reset’ button that zeroes both the water depth across the entire landscape and the timestep count.
     A ‘pause’ button that temporarily stops the simulation.
     A ‘play’ button that either starts the simulation or allows it to continue running if it was previously paused.
     An ‘end’ button that closes the window and exits the program.

  • Multi-threaded processing
     The simulation is carried out by four threads each responsible for processing a random but final portion of the points on the list of grid positions.These threads are synchronised on each timestep. That is, no thread is ever allowed to start the next timestep of simulation before all others are complete. The program exhibits “fluid conservation”. Water can only be created through user mouse input and destroyed by reaching the boundary. The simulation itself is only responsible for moving water over the terrain.

Libraries Used

  • Java Abstract Window Toolkit (AWT)
  • Java's concurrency library

Project setup

To run this project make sure you have downloaded and installed java. Then run the Makefile with the commandsDownload and install Java.

make runLarge       // Runs simulation with large terrain (1024x1024 dimensions)
make runMedium      //Runs simulation with medium terrain (512x512 dimensions)

Future Scope

  • Add testing scripts to find and remove bugs
  • Add a counter that displays the number of timesteps since the start of the simulation
  • Add scripts to randomly generate terrains of any size for testing

Made with ❤️ with good ol' vim