<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Caverns on Nathaniel Inman</title><link>https://nathanielinman.com/tags/caverns/</link><description>Recent content in Caverns on Nathaniel Inman</description><generator>Hugo -- 0.147.7</generator><language>en-us</language><copyright>Nathaniel Inman</copyright><lastBuildDate>Sun, 09 Jun 2024 00:00:00 +0000</lastBuildDate><atom:link href="https://nathanielinman.com/tags/caverns/index.xml" rel="self" type="application/rss+xml"/><item><title>Caverns, Automata and the Meander Revisited</title><link>https://nathanielinman.com/caverns-automata-and-meander/</link><pubDate>Sun, 09 Jun 2024 00:00:00 +0000</pubDate><guid>https://nathanielinman.com/caverns-automata-and-meander/</guid><description>&lt;p>Back in 2015 I tackled &lt;a href="https://nathanielinman.com/automata-generated-caverns/">automata generated caverns&lt;/a> for a 7DRL, and in 2018 I wrote up the &lt;a href="https://nathanielinman.com/meander-algorithm/">meander algorithm&lt;/a> for rivers. Both made it into &lt;code>compass&lt;/code> and both got a little sharper along the way, so I wanted to revisit them with the actual implementations in hand.&lt;/p>
&lt;h3 id="caverns">Caverns&lt;/h3>
&lt;p>The cavern generator is Conway&amp;rsquo;s Game of Life pointed at a terrain problem. It&amp;rsquo;s almost embarrassing how little code it takes.&lt;/p>
&lt;ol>
&lt;li>Clone the map and randomly seed roughly 55% of it as floor.&lt;/li>
&lt;li>Run a single Game of Life pass over the Moore neighborhood (the 8 surrounding cells). An empty cell is born as floor with 5 or more floor neighbors, and an existing floor cell survives with 4 or more.&lt;/li>
&lt;li>&lt;code>clipOrphaned&lt;/code> keeps only the largest connected blob so you don&amp;rsquo;t get a dozen disconnected pockets.&lt;/li>
&lt;li>Build walls around everything walkable and force the map border to wall so the cave is sealed.&lt;/li>
&lt;/ol>
&lt;p>One pass is enough. The birth and survival thresholds are doing the smoothing that I used to iterate several times to get, and the result is the lumpy organic cave you&amp;rsquo;d expect.&lt;/p></description></item></channel></rss>