Doomsday: Settlers of the Wasteland
For centuries following the Doomsday event, the last remnants of humanity clung to life in a lone bunker, deep beneath the surface of the Earth.With time, the atmosphere became less toxic, and Settlers began to inhabit the vast and unforgiving Wasteland.This prosperous New Renaissance of interconnected Settlements grew, stretching the limited resources of the still-damaged Earth.It was only a matter of time until civilisation collapsed...
Pry open that hatch and take a deep breath of slightly-irradiated, dusty air because we’re going to explore the design and code of our new game, Doomsday: Settlers of the Wasteland.
Overview
For some background, we’ll give you an overview of the game, where it came from and how it works on a general level.
Doomsday: Settlers of the Wasteland is a sequel to Doomsday NFT, a project launched in January of last year. The original Doomsday game pitted players against each-other, inhabiting Bunkers and fighting to be the final survivor at the end of an Apocalypse. You can read more about it here, but the key takeaways are that it used a novel game mechanic to position bunkers under real-world cities on a map of the world and slowly eliminate them. The final prize that the winner took home was about 256 ETH.
Settlers is set several hundred years after a Doomsday event. For a long time, the last remaining humans on Earth spent centuries clinging to life in an expansive, underground Bunker. Finally, they begin to step back above the surface and start settling in the harsh Wasteland.
The age of the new Renaissance is a highly connected, interdependent society. All Settlements benefit as the civilisation grows in size and complexity, however the increasing pressures on limited resources, as well as the constant need for growth, slowly pushes this civilisation to its inevitable breaking point.
The world then enters a Dark Age. The connections between Settlements are severed and disasters ravage the Wasteland as, one-by-one, Settlements are destroyed or abandoned by their inhabitants.
The last remaining Settlement inherits all the cultural relics from the previous age, and a new age can begin.
Game Mechanics
Settlers is built with scarcity and natural cycles of boom and bust as core mechanics. The game is split into two distinct phases, Renaissance and Dark Age.
Renaissance
The Renaissance is the period of growth and expansion, as settlers leave the Bunker and found new Settlements throughout the Wasteland. Players compete by mining, the same process used to create Bitcoin (and formerly Ether), in order to find the next Settlement location.
The economy of the Renaissance is designed to mirror our own, where the whole system benefits from growth, but is also dependent on that growth. When a new Settlement is founded, the mint-cost is distributed across all existing Settlements. The mint-cost and mining-difficulty both increase as the number of existing Settlements increases and resources become more stretched.
The need for constant growth means there is a timer which is constantly counting down to civilisation’s collapse. When a new Settlement is founded, this timer extends, but the more Settlements that exist, the smaller the time-extension. Essentially, the larger and more complex the civilisation becomes, the more difficult it is to sustain itself.
Every Settlement has a Primary Industry, which determines how much ETH it earns per mint. Rarer Primary Industries earn more ETH, and can only be found in Settlements founded during periods when the number of existing Settlements is high.
Half of the ETH from mint fees is also held as a prize pot, awarded to the winner of the Dark Age period. This, coupled with the fact that ETH accrued by Settlements can only be claimed by Abandoning your Settlement (burning the token), means that players have conflicting incentives.
Early players have an advantage by being able to found Settlements when it is easier and cheaper to do so, however they don’t have the possibility of higher-earning Primary Industries in their Settlements. It’s more difficult and costly for later players to found Settlements, but they have the possibility of better Settlements.
All players may Abandon their Settlements at any time during the Renaissance, but this will eliminate the possibility of them winning the Dark Age prize. This means players must base their decisions on how they expect other players to behave during both the Renaissance as well as the coming Dark Age.
Dark Age
The Dark Age is the unforgiving period of destruction and elimination. Players compete by holding and Reinforcing their Settlements against Disasters.
Settlements that could only exist in an interconnected world are suddenly unsustainable when left to fend for themselves. Drought, famine, plague and raider attacks ravage the Wasteland, depleting the supplies of Settlements, and eventually destroying them.
Players can Reinforce their Settlements by adding Water, Food and Medical supplies, and by improving their Defences. The cost to do so increases for each level of Reinforcement, limiting the natural advantage whales have, while Reinforcement fees are added to the prize pot, increasing the stakes for all players. Each Settlement is also immune to one type of Disaster.
Abandoning a Settlement during the Dark Age will give that Settlement a portion of the prize pot, but the later in the game it is, the larger that portion will be.
During the Dark Age, players must try to anticipate the ability and willingness of their opponents to continue playing, while being careful what signals they send about their own willingness and ability to do so.
The moment the Dark Age begins, the ETH contained in a Settlement changes to reflect that half of the ETH accrued has been added to the prize pot, but that the Settlement will receive a portion of that prize pot upon Abandonment. So players must also be mindful of when the transition will occur when deciding whether to continue to the Dark Age.
Trading
Every Settlement is an ERC-721-compliant NFT, meaning that players may also buy and sell their Settlements at any time during the game. This means that players may choose to exit the game by selling their token on the secondary market, rather than by Abandoning their Settlement, and that other players who were unable to mint a Settlement during the Renaissance may enter the game this way.
Given that all Settlements gain ETH during the Renaissance, and the amount earned when Abandoning a Settlement during the Dark Age increases the longer the Settlement survives, this puts increasing upwards pressure on the secondary-market prices of all Settlements as the game continues.
All Settlements also become inherently more scarce as soon as the Renaissance ends, since it is no longer possible for new ones to be created.
The Renaissance can only continue if new Settlements are being founded, and the more Settlements that get eliminated in the Dark Age, the greater the share of the prize pool given to those who remain. So the older a Settlement is, the more it will be worth.
The Tech
Doomsday: Settlers of the Wasteland is fully on-chain, this means that all the important data is stored and calculations are done in the game’s smart contracts. It also means that nobody (including us) can interfere with the outcome of the game, and that the game contracts hold all the prize money until it is paid out. The game can theoretically be played entirely by interacting only with the smart contracts.
The tech for the game has two important features, one in each phase of the game.
Renaissance
The mining tech in the Renaissance was developed for another project, POW NFT. You can read about that project in this article, and the tech is further explored with Doomsday Garden, which is written about in this article.
The mining algorithm in Doomsday: Settlers of the Wasteland is slightly more advanced than those other two projects, and to save you reading any of those other articles we’ll break the whole thing down here.
Any mining process basically involves running the same calculations over and over with slightly different inputs until the resulting output is below a certain target number. Therefore, the smaller that target number, the less likely that any given attempt will be below it (like in real life if a target is smaller, it’s harder to hit). The calculations are designed in such a way that you can’t start from the output you want and work backwards to a desired input, but if you show someone else your input they can easily verify that it gave the desired output.
Doomsday: Settlers of the Wasteland’s mining algorithm takes three parameters:
- The address of the miner (so if you are successful, nobody else can intercept your transaction and steal your inputs).
- The previous token’s output (so tokens must be mined one at a time)
- An extra number (called a nonce) that the mining software changes for each attempt.
The biggest benefit of requiring users to mine tokens, coupled with an increasing mint fee, is that it removes arbitrary, artificial scarcity. The vast majority of projects in the crypto space, especially NFT projects, set an arbitrary limit on how many of their tokens will exist, and then seek to build artificial hype in order to create a situation where the demand for those tokens is greater than the arbitrary supply they set.
Not only is this inefficient (you may end up with a situation where not everyone who actually wants a token can get one), it also creates a situation where if the artificial limit is set too high (ie, supply is greater than demand) it devalues all the existing tokens, and basically just annoys everyone who minted a token.
Attempts have been made to address this with minting mechanisms like Open Editions, where essentially there is a window of time where there’s no limit to how many can be minted, but this is basically just an attempt to abstract away the arbitrary scarcity. Whatever window of time they pick is just as arbitrary as just picking a supply limit.
The use of mining in this regard provides two advantages:
- It forces people to form a line, since tokens have to be minted one at a time.
- It is a fair mechanism for deciding who gets to mint next, where even having advanced mining rigs only gives you a higher chance of minting next, and not a guarantee.
It also means that Whales (people with large amounts of crypto) can not use their wealth to dominate the minting process, since they still have to mine just like everyone else. However, the mint fee means that the minting process won’t be dominated only by people with fancy mining equipment but who just want to claim free tokens to sell on the secondary market.
The combination of the mining difficulty and mint cost both increasing as token supply grows, as well as the ability for tokens to be traded on the secondary market, means that whatever the actual demand is for these tokens, the supply should eventually reflect it. If 10,000 people want a token, the supply will grow until everyone either has one, or has decided it’s not worth the effort to mine/mint cost or secondary market price.
This elasticity also means that if 10,000 more people suddenly decide they want a token, the supply can grow to capture this new demand while increasing the value of existing tokens (ie, they retain their scarcity).
However, a system that allows for supply to grow with increasing demand should also be able to contract in supply when that demand is reduced. For this reason, Settlements can be Abandoned by their owners, burning the token and reducing the overall supply (and thus making new mints easier). Their incentive for doing so is that this is the only way they can extract any ETH the token has accrued from the minting process, however by doing so they lose any potential rewards from future mints. As a token-holder, you benefit most if other token holders burn their tokens (making new tokens easier to mint). But since all token holders have this incentive, they are effectively in competition with each-other.
In some ways, this mechanism is similar to a bonding curve, where a token’s mint price dynamically adjusts to supply as people mint and burn tokens. However, without the addition of mining, a bonding curve is extremely susceptible to abuse by Whales or other bad-faith actors who monopolise the minting process early on and use it to extract value from other users at the expense of the project.
The nature of crypto means that blacklisting such users is completely ineffective, as it is trivially easy to create new addresses and bypass these efforts (see Sybil attacks). Some efforts have been made to generate whitelists generated from social media interactions, but these are less “effective and fair mint distribution” systems and are more just useful as tools for marketing.
The mining/burning mechanism was used in an earlier project, Doomsday Garden, for minting tokens. Eventually the project reached an equilibrium/stalemate, where nobody was minting new tokens, but nobody was burning them either. This is theoretically the ideal state, as if anyone wanted a token they would buy or mint one, and if anyone had one but didn’t want it, they would either burn it or try to sell it on secondary.
While this was an effective proof-of-concept, the initial excitement eventually wore off as activity died down. In order for the dynamic state to continue, there need to be extra forces incentivising people both to mint new tokens, and to burn them (since only incentivising one of these behaviours would see this supply pressure diffused throughout the ecosystem and the supply would eventually end at a different equilibrium point).
In Doomsday: Settlers of the Wasteland, these added pressures are caused by the Dark Age, where players have both the possibility of winning large amounts of ETH, while also having the risk of losing their tokens.
The other mechanism is the Primary Industry that each Settlement has. This determines how much ETH that Settlement earns per mint, with rarer Primary Industries earning more ETH. However, rarer types only occur in Settlements that are minted when the current supply is already high. This creates extra incentives for players to mint tokens when its harder to do so, while incentivising players with older, lower-earning tokens to burn them.
This was supposed to be a discussion of the tech, but given that so much of the tech in the Renaissance is designed around scarcity, it inevitably turned into a discussion of player incentives. But there is one important change to the mining algorithm that was not present in Doomsday Garden: the difficulty cooldown.
Difficulty Cooldown
If mining difficulty is only dictated by the current supply, this can create issues with failing transactions if there are a lot of people trying to mint at the same time. Ethereum blocks occur once every 12 seconds, but if two or more people find a valid nonce in that time and submit a “mint” transaction, only one of them will succeed and the others will have failing transactions.
For the previous NFT mining projects, this was acceptable, as it was part of the scarcity experiments. However, it can be frustrating for users, and it wastes ETH on gas used for failing transactions. For this reason, Doomsday: Settlers of the Wasteland uses a time-sensitive cooldown function, where the difficulty spikes immediately following a token mint, and over the course of about 5 minutes it returns to where the current supply dictates that it should be. This greatly reduces the chances of collisions between mint transactions when demand spikes, without affecting the relationship between token supply supply and overall demand.
The code to determine the difficulty target is as follows:
uint difficulty = BASE_DIFFICULTY - (DIFFICULTY_RAMP * supply);
uint blockDif = (block.number - lastSettleBlock);
where:
BASE_DIFFICULTY
is a constant representing the mining difficulty if supply were 0.DIFFICULTY_RAMP
is a constant representing how much the mining difficulty changes when the supply changes.supply
is the current token supply.lastSettleBlock
is the block number in which the last Settlement was minted.DIFFICULTY_COOLDOWN
is a constant representing the number of blocks it should take for the difficulty to return to its natural, supply-based level.DIFFICULTY_COOLDOWN_SLOPE
is a constant which affects by how much the difficulty spikes.
Dark Age
The elimination mechanism in the Dark Age is based on that developed for the original Doomsday game. For anyone doing a deep dive, you can read about that project here, but again we’ll tell you everything you need to know here.
There are a few key features that work in unison for this phase:
- There is a game map, and each Settlement occupies a specific point on that map. A Settlement can’t be in two places, neither can it be nowhere (at least until it’s destroyed), ie, the same rules that apply to real life. The map coordinates are meaningful, and spacial relationships (the distance between things) are significant, as enforced by the smart contracts.
- During the Dark Age, there is a Disaster once every 15 minutes. Like Settlements, each Disaster is centred at a specific point on the map, and also has a radius of effectiveness. Basically, this means a random circle is drawn on the map, and the smart contracts know if a Settlement is inside that circle.
- Players can Reinforce their Settlements to protect them against Disasters, increasing how many they can survive before they’re destroyed, while adding ETH to the prize pot.
Settlement locations are derived from the token’s hash, an output of the mining process. The result is an x- and y- coordinate on the game map. Although the distribution of Settlements on the map is effectively random, the relative positions become more meaningful as the Dark Age progresses, since you will have to survive many of the same Disasters that your nearby neighbours have to survive.
Disasters
Disasters are derived from the blockhash
of previous blocks. For the non-technical reader, the blockhash is basically a number that represents all the data in that block mushed together.
For the technical, the Disaster function uses the blockhash of a block in the past, which updates every 75 blocks. Specifically, the blockhash is selected as follows:
uint eliminationBlock = block.number - (block.number % DISASTER_BLOCK_INTERVAL) - 1;
bytes32 _disasterHash = blockhash(eliminationBlock);
Where DISASTER_BLOCK_INTERVAL
is a constant representing the number of blocks for which the disaster should remain the same. For 75 blocks, the game will look back at specific blockhash. Since that blockhash won’t change, the disaster won’t change during that period (and eliminations can take place as needed).
Note that although blockhash is entirely known and deterministic, this is not a vulnerability because once a new elimination block is selected, it’s too late to do anything about it. If the smart contract detects that a Settlement is vulnerable (ie, it is inside a Disaster, and that Disaster hasn’t been confirmed yet), the transferFrom
, abandon
and reinforce
functions are all disabled for that Settlement.
The confirmDisaster
function can be called by anyone to confirm a Disaster on any vulnerable Settlement. The game interface exposes this with a large “Confirm Disaster” button in the action bar at the bottom of the screen, as well as specific “Confirm Disaster” buttons on Settlement info screens for any vulnerable Settlements.
Whenever a Settlement is minted or reinforced, the game takes a 0.01 ETH destruction fee. This fee is set aside, and paid to whoever confirms a disaster on that Settlement. This provides an incentive for anyone, even non-players, to monitor the game map and confirm disasters on vulnerable Settlements in order to earn this fee.
The destruction fee is intended to cover the gas-costs of the person executing the function, as well as reward them with some extra ETH. This means that if gas costs spike beyond a certain level (approximately 100–110 GWEI), the economic incentive for a non-player to execute this function is no longer there. However, rival players may still confirm disasters on each other during this time, and any extreme gas spike that is shorter than 15 minutes will not effect game progress at all.
The destruction fee was chosen as a tradeoff between covering all reasonable scenarios, without inflating mint and reinforcement fees unnecessarily. In the original Doomsday game, the destruction fee was also 0.01 ETH, and was effective if gas was below about 110 GWEI. At the time, this situation was possible, as gas wars were rather common. Due to recent meme-coin activity, gas spikes have again become a possibility, which is why 0.01 ETH was chosen. However, as shown in the graph below, gas prices were on average lower and much less volatile over the last year:
In any case, this is just a mechanism to ensure there is an incentive for someone to execute a function which will cost money to execute. There is also an incentive, especially in the late-game and even without the destruction fee, for players to confirm disasters on each other, as it brings them closer to victory (and thus increases their expected return from the game). In most cases, it’s much cheaper to confirm a disaster on an enemy than to reinforce your own Settlement, and both have the same net effect on your chances at victory.
Disaster Radius
The Disaster’s radius is derived from the Disaster blockhash. The smart contracts calculate the x- and y- distance between a Settlement and the centre of a Disaster, and then just use the Pythagorean theorem to see if this is less than the Disaster’s radius. If it is, then a Settlement will be within the red circle, if not, it will be safe.
Note that Disasters wrap around both the horizontal and vertical edges of the map. So a Settlement at the right-hand-edge of the map will be at risk from Disasters on the left-hand-side of the map. This means that Settlements on the edge of the map don’t have a lower probability of being affected by Disasters.
Towards the end of the game, when the number of remaining Settlements is low, the average radius of Disasters will begin to grow, increasing the odds of affecting one of the remaining Settlements.
Disaster Type
As mentioned earlier, there are four types of Disaster: drought, famine, plague and raider attacks. Like the radius, the Disaster type is also derived from the blockhash. Each Settlement is immune to one type of Disaster, meaning they are unaffected by Disasters of this type, even if they are within the Disaster radius.
Reinforcing Settlements
For the three Disaster types that a given Settlement can be affected by, players can Reinforce their Settlements with extra Food to protect against Famine, Water to protect against Droughts, Medical supplies for Plagues, and Defences to protect against Raiders.
Players can Reinforce their Settlements at any time during either the Renaissance or the Dark Age, except if it is currently vulnerable (ie, it is within the Disaster radius but the damage has not yet been confirmed). This prevents players from Reinforcing their Settlements only at the last second, once they know it will be affected by a Disaster.
Players may Reinforce their Settlements against different Disaster types independently. For example, if a Settlement has been affected by several Droughts, the player may acquire more Water supplies, without having to reinforce against the other Disaster types.
The cost of Reinforcement is based on the current mint cost, and doubles for each subsequent reinforcement of that type, with reinforcement fees being added to the prize pot. The doubling is designed to mitigate the advantage held by players with large amounts of ETH. The inequality of wealth distribution in the crypto space rivals that of medieval serfdom, so any project that tries to ignore this fact will inevitably be exploited when it catches the eye of a large enough Whale.
The effect of doubling the cost for each Reinforcement level effectively means that an exponential difference in how much ETH players are willing spend on reinforcements only leads to a linear difference in their chances of winning.
To use an extreme example to illustrate the point: if there were only two players in the game, and both had minted Agricultural settlements, the reinforcement cost for one type (for example, Food) would be
cost = 0.000020 ether * (2 ** current_level) / 4;
with current_level
being how many times you have reinforced for that type already.
So the first reinforcement would only cost
cost = 0.000020 ether * (2 ** current_level) / 4;
cost = 0.000020 ether * (2 ** 0) / 4;
cost = 0.000020 ether / 4;
cost = 0.000005 ether ;
Using this same formula, the second, third, fourth and fifth are as follows:
cost = 0.00001 ether ; // 2nd
cost = 0.00002 ether ; // 3rd
cost = 0.00004 ether ; // 4th
cost = 0.00008 ether ; // 5th
However, assuming one of our two players was Jeff Bezos, and he wanted to spend his entire net worth ($125.1 billion USD at time of writing) to attempt to win this game, how many times could he reinforce this settlement against this one type of Disaster?
His wealth in ETH is approximately 65,993,540 ETH. But for a current_level
of 43, the reinforcement cost in the above scenario is about 43,980,465 ETH. The cumulative cost of reinforcing to that level is approximately double that, since he has to reinforce the other 42 times first.
This means that even in the most extreme situation, where reinforcement costs are at their lowest possible level, Jeff would have to spend his entire net worth to only get a 43x advantage over his opponent, assuming his opponent chose not to reinforce at all. In this situation, the prize pot for winning will now be close to the former net worth of Jeff Bezos, and his opponent still has a 1/43 chance of winning.
Note that it’s unlikely that only two Settlements will be minted, and in such a case, its very unlikely that one of the two players will be Jeff Bezos using his entire fortune to try to win the game. The above example is intended to illustrate that even in the most extreme cases, the doubling of Reinforcement costs limits the advantage held by people with large amounts of ETH.
This is the same principle illustrated by the wheat and chessboard problem, an ancient mathematical thought experiment where a grain of wheat is placed on the first square of a chessboard, then two on the second square, then four on the third square, and so on. By the time you reach the final square, you’d need more wheat than exists in the entire world.
Note that the cost of Reinforcement also includes the destruction fee of 0.01 ETH, which was discussed earlier, and is used to pay for Disaster confirmations. If a player chooses to Abandon their Settlement, they get back all unused destruction fees that they paid to Reinforce their Settlement. Conversely, if a Settlement is destroyed by a Disaster, any unused destruction fees will be added to the prize pot.
Metadata and Aesthetics
Every Settlement has a unique map, which is generated based on the token’s hash. The placement of buildings, roads, and all other features is derived from this hash. Originally, a Settlement will only have a handful of buildings, however as the Settlement grows, roads will expand and more buildings will be built.
There are actually four Settlement layout types, with the above being one type, and the others only being possible for Settlements that are minted when the current supply is higher (ie, civilisation is more advanced).
The retro aesthetic was created for the original Doomsday game in order to evoke a 1970s cold-war-tech feel. But given the technical constraints that exist around building a fully on-chain game, a low fidelity aesthetic is always going to fit better, otherwise you are effectively illustrating details that don’t exist in a meaningful way.
Every Settlement is also named, with names generated from a large dataset compiled using various sources of ancient names for places, people and a few other categories from different cultures throughout the ancient world.
One of the main sources of inspiration for Doomsday: Settlers of the Wasteland was the Bronze Age and subsequent Bronze Age Collapse. Around the ancient Near East, the Bronze Age world was a society of different cultures and city states that were connected through political and economic relationships which seem modern by some standards. It was about as globalised as you could get in the ancient world.
However, around 1200 BCE, due to a combination of factors including environmental changes, overuse of the land, and the arrival of mysterious groups of invaders called the Sea Peoples, entire city states began to be destroyed or abandoned. Many of these once-great cities would lie empty, reclaimed by the land never to be inhabited again.
We won’t go into more detail describing the Bronze Age Collapse because this is a technical article and most of you probably didn’t sign up for a history lesson. But if you have an interest in ancient history and don’t already know about the Bronze Age and its Collapse, we suggest you read up on it and prepare to have your socks rocked off.
All of this is just to say that we were trying to build a game that captured the vibe of the Bronze Age, added in a bit of Mad Max, and gave it the aesthetic of the tech in the original Alien films.
It is the Dawn of a New Age
We believe we’ve put together something unique that will provide some unforgettable, or at the very least, enjoyable experiences for players, as well as pushing the boundaries for what web3 games can be.
Doomsday: Settlers of the Wasteland was designed from the ground up with web3 at its core, built around the limitations of this new technology while embracing the benefits it provides. We hope that other developers in this space will adopt similar approaches, and that we can see the growth of more truly crypto-native web3 games.
The game will be live on mainnet soon, read more at doomsday.ffg.com or follow us on Twitter for updates.
Best of luck in the Wasteland.