Coolcaves
CLi to simulate some cool cave generation!
Note: This is my first actual rust project outside of the rust playground, so please take that into account when reading source-code etc!
Installation
Install via cargo (recommended)
Build manually
(Executable is now availble in target/release/coolcaves )
Information
Background
I saw this reddit post showing an awesome rendering engine in the terminal called germterm, a bit after watching this video about minecraft terrain generation which got me the idea to generate my own random caves using germterm as the renderer.
The idea was on the back on my mind for over 2 weeks, until I finally got bored and decided to see if I could actually make it work! 2 hours of work later and weve now got this, and i think it looks pretty cool!
Controls
Dont worry, you dont have to read this, controls are displayed in the program itself!
W/S - Increase / Decrease the Progressive wall density (0-8) (+/- 1)
E/D - Increase / Decrease the Init wall density (0.00-1.00) (+/- 0.01)
R - Reset
Q - Quit
How it works
It all starts with a map of random on and offs (bools), where the chance of a wall (on) spawning being controlled by the Init wall density (by default 0.50 aka 50%).
After that the map acts as a cellular automata where there are 3 rules (where neighbours are surrounding walls):
- If blank and neighbours is more or equal to
birth thresholdthen become a wall - If wall and neighbours is more or equal to
survival thresholdthen remain as a wall - Else become blank
Progressive wall density will never go outside of 0-8
birth threshold = min(Progressive wall density, 4)
survival threshold = max(Progressive wall density, 8)
These rules are applied to every pixel every tick, progressively forming caves instead of random noise, pretty cool right!