Devlog: Slashing and Burning

Goblin Camp

Goblin Camp is a fantasy city-building game inspired by Finnish mythology. Deep simulation mechanics capture the unique challenges of surviving the harsh winters and carving a thriving settlement out of the northern forest. Lead your goblins to greatness!

Hello, this is the first Goblin Camp devlog. We'll post these devlogs every now and then to highlight some of the work we've been doing lately. In this post I'll be going through what I've spent most of last month programming. [h2]Slash-and-burn agriculture[/h2] Farming is a critical activity for our little goblins, it's one of the main ways to provide food for your village. The fertility of the soil determines how much food you get out of a farm plot, so boosting fertility means boosting food output. Slash-and-burn agriculture is an effective and exciting way to do so. [h3]Slashing, establishing a swidden[/h3] [b]swidden[/b] [i]An area of land that has been cleared by cutting the vegetation and burning it; slash and burn.[/i] First the player selects a rectangular area on the map to make into a swidden: [img]{STEAM_CLAN_IMAGE}/44295898/46d68ea47685fcaed33c094c828cbb1e6b817831.gif[/img] All of the flora (trees, bushes and the like) within the swidden are marked for clearing and the goblins get to work. They'll grab axes to fell trees or just use their hands if they need to clear bushes and smaller plants. For each tree we take the approximate center of the swidden and record a 'preferred fall direction' that points towards the center. The goblins use this information when they decide which side of a tree to be on while chopping it with an axe, the goal being to minimize the amount of branches and logs that fall outside of the swidden. Any burnable items that make their way into the swidden one way or another are reserved by the swidden to prevent other jobs from trying to use the branches and logs within. For example, any branches inside a swidden should not be used by the carpenter to make digging sticks out of. [img]{STEAM_CLAN_IMAGE}/44295898/460274d4dc73c25c61131cc5b2cbb8135225015b.gif[/img] A two tile wide perimeter is established around the swidden as a firebreak. Any items within the firebreak get moved closer to the center of the swidden. [img]{STEAM_CLAN_IMAGE}/44295898/2c1da2a5f921300a3a856e8d332590f83f504402.gif[/img] [h3]Burning[/h3] Once everything is in place the player can open the slash and burn dialog and enable fires. [img]{STEAM_CLAN_IMAGE}/44295898/0273ae070fe93ecd454763f05ed355afe414fdc4.gif[/img] Goblins will equip branches and station themselves within the firebreak. If there are no active fires they will start new ones, based off of wind direction so that the fires are started upwind. This ensures that the fires spread in approximately the right direction. [img]{STEAM_CLAN_IMAGE}/44295898/b1017c9fa83ee67a5902bbad8b4da3306bf11e93.gif[/img] As an aside, this required me to write code to differentiate between "wild fires" and "swidden fires". We already had existing code that told goblins to put out any fires that were threatening their village so when swidden fires were started other goblins would rush in with buckets and put them out immediately. Whenever fires spread into the firebreak goblins will go there and put out the fire with their branches. Selecting a fire is not done strictly by selecting the nearest one, this would lead to goblins clumping up when there are few fires and they would consequently all go to the same fires as a group. Instead random fires are selected for each goblin so that they tend to spread out. If a goblin encounters a new fire while moving they will stop and put that fire out as well as any other adjacent ones, which minimizes the chances that they foolishly run past fires to put out far away ones. [img]{STEAM_CLAN_IMAGE}/44295898/ea58e3b036fb9bbdec73bf599e90e7d1a188e965.gif[/img] This cycle of igniting fires and putting them out is carried on until all tiles and burnable items within the swidden have been burned. [img]{STEAM_CLAN_IMAGE}/44295898/47a07ceac2edc5cca6b5d530a5467694d573073a.gif[/img] At that point the swidden is automatically removed and the firewatcher goblins freed to do other work. This is the point where the player can then create a farm plot over the now much more fertile ground. Tilling the new farm plot will incorporate the ashes into the soil and increase crop yields. [img]{STEAM_CLAN_IMAGE}/44295898/89227af83dbd403a696622f3de0e8c252e7898fc.gif[/img] This was a very interesting feature to get done, it required quite a bit of coordination between various elements in our game. Combining a chaotic element like fire with intelligent behaviour of goblins can easily lead to things happening in game that look "dumb" to the player even if the code is technically doing the right thing. The end result here is satisfying, it's fun to watch the goblins scramble to contain a fire they started themselves.