<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Rktpranjal on Medium]]></title>
        <description><![CDATA[Stories by Rktpranjal on Medium]]></description>
        <link>https://medium.com/@rktpranjal?source=rss-c2f61df8321a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*PJTm_AkrD-U1mm7I.jpg</url>
            <title>Stories by Rktpranjal on Medium</title>
            <link>https://medium.com/@rktpranjal?source=rss-c2f61df8321a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 06:27:15 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rktpranjal/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Forging A Dungeon World]]></title>
            <link>https://medium.com/@rktpranjal/forging-a-dungeon-world-24b07f516f46?source=rss-c2f61df8321a------2</link>
            <guid isPermaLink="false">https://medium.com/p/24b07f516f46</guid>
            <category><![CDATA[simulation]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[procedural-generation]]></category>
            <dc:creator><![CDATA[Rktpranjal]]></dc:creator>
            <pubDate>Sun, 01 Mar 2026 12:55:16 GMT</pubDate>
            <atom:updated>2026-03-01T12:55:16.083Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rakJ2xthAnnD--0In7xCxA.png" /></figure><p>So this is my first time writing a tech blog in my life and what better way to start this journey than by starting it with a topic that I am learning myself. I claim no expertise in working with simulations and that makes it all the more important to document this journey.</p><p>The inspiration came while playing probably one of the best dungeon crawlers named <strong>Barony</strong>. It is on steam so if any one of you reading this article is interested go check it out.</p><p>Now the first thought that came to my mind was what it would take to build one, but a couple minutes of meditation and an honest analysis of my current coding skills led me to the conclusion that I would lose interest way before the first pixel gets rendered. But what I can do instead is simulate the dungeon world mathematically. So here we are.</p><p>This article is going to be one in a long list and will probably keep me invested in the project long enough to bring it to its eventual completion.</p><h3>Tools</h3><p>Any good construct needs a good set of tools. For this case the tools are the libraries and languages in my tech stack. The language of choice is of course going to be Python. The main libraries I will be working on are Numpy, Matplotlib and OpenSimplex.</p><h3>High Level Design</h3><p>In order to construct this dungeon of mine, the first order of business is to get the high level design of the dungeon down. Here are some of the salient features of this construct of mine:</p><ol><li>The dungeon is an inverted dungeon with each higher level floor deeper than its lower level counterparts.</li><li>Each dungeon floor will have a finite number of cities/towns. We will refer to them as <strong>nodes</strong> from here on out.</li><li>The number of nodes on any given floor will depend upon the depth of the floor. The closer one is to the abyss, the fewer the nodes.</li><li>Each node will be inhabited by a certain number of entities(people).</li><li>The size of each node is determined by the number of entities inhabiting it and the number of entities inhabiting a node depends on the inherent characteristics of a node.</li><li>The entities will change the nature of the node which in turn will change the characteristics of the entities giving us a nice dynamic relationship.</li><li>Different nodes on a dungeon floor will be connected through each other by paths through which the entities can travel.</li><li>Each of these paths will have certain characteristics which will determine if the entities traversing it, survive the journey or not.</li><li>Each dungeon floor is connected directly to its immediate neighbours and the entities can travel between the floors using these connection(s).</li></ol><p>Now that we have a very general overview of the world we are trying to forge its time to dig in and craft the details.</p><h3>Conceptualising the Dungeon</h3><p>One of the primary requirements that I want this forge world to follow is to be consistent in its structure. The interactions between objects need to be genuine and organic and not forced through if else statements. This is where some basic knowledge of physics comes in. This section is going to be a bit dense but do bear with me here.</p><p>But before going into modelling our dungeon let’s decide on some properties of the dungeon.</p><ol><li>The dungeon is permeated with particles which we will call <strong>Mana</strong> for my obvious lack of originality.</li><li>The higher the concentration of <strong>Mana</strong> a place has, the less inhabitable it becomes for entities that usually find safety within nodes.</li><li>The deeper the floor is, the more Mana rich it becomes. This implies that the deeper you go, the fewer nodes you find and the more dangerous the dungeon becomes.</li></ol><p>Now that we have this relationship between Mana levels and nodes established, the question is how to get this into code?</p><p>Here comes the ideal gas equation.</p><p>PV = nRT</p><p>Though it is too simple and needs some tweaking.</p><p>Now in the physical world pressure is nothing but a representation of energy of particles bumping into each other. In our case the <strong>Mana</strong> particles perform this function of pressure generation. This fits in nicely with our world design. As we go deeper, the <strong>Mana</strong> concentration increases and so does the pressure.</p><p>n here represent the number of nodes, V is the volume of the dungeon floor, R a constant and T the temperature of the floor. For the basic setup, temperature and volume will be considered constant. Changes will be made to these parameters when our dungeon floor is more fleshed out to get some interesting behaviour.</p><p>Now we will introduce another parameter P’ which will be called the node pressure and will be the inverse of Mana pressure P.</p><p>Since the Mana pressure is a representation of the kinetic energy of Mana particles which scales quadratically with the depth of the dungeon, we will scale the Mana pressure quadratically with the depth of the dungeon.</p><p>We will let the variable d denote the depth of the dungeon floor.</p><p>Our new modified equation will then look like this;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*YY70GGoF8IsLZN31Py5WXg.png" /></figure><p>Here ⍺ is the scaling constant between the two pressures.</p><p>Now using P =kd² where k is another constant. The final equation becomes</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/206/1*AtxXsJkcbstx3vTcOCcvmQ.png" /></figure><p>where ⍺’ is the dungeon coefficient is defined by</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/286/1*tRvH7V_Tq10LHDBNOhnPYA.png" /></figure><p>Now the above equation tells us that the node count decays quadratically with the depth of the dungeon which is a tad bit too fast for us. So we are going to add a dampener to it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/442/1*h4687oq-P_WpmRlgY8kt1g.png" /></figure><p>Now we will apply some initial conditions:</p><ol><li>The deepest level of the dungeon at depth D will have a single node.</li><li>The shallowest level of the dungeon at depth 1 will have the maximum node count N which we can set up at our own discretion.</li></ol><p>Solving for it gives us the final equations:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/406/1*dVogqw37S-b1VL5ol16Gjw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/476/1*iSUpKJmkZqumW477ZPIMeA.png" /></figure><p>This makes the decay of node count with depth slower. It is still steep but we will improve this relationship later.</p><p>For a max node count of 100 and depth of 20 floors with the distance between floors being 1, the node distribution looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/556/1*4K5xqaIIPkPq5oP06S3gOw.png" /></figure><p>Again steep I know, but it will get us going.</p><p>Now that the node distribution is in place, the next step is to conceptualise the dungeon floor itself.</p><p>Through the pressure equation, we have an understanding of the mana pressure on a given floor. However the equation provides us a single value for the entire floor. In a dynamic system, this will not be the case. The Mana pressure derived from the above equations will therefore be treated as an average value and the Mana pressure on a floor will vary from point to point.</p><p>In order to keep this distribution of Mana organic, we will use Simplex noise to generate the Mana field on a dungeon floor. Our job after that will be to place the allowed number of nodes in the Mana field and if we configure this right, the floor itself will tell us where the nodes can be placed.</p><p>We will conceptualise the dungeon floor and its properties in the next article.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=24b07f516f46" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>