Dark Forest is a decentralized strategy game based on the Ethereum blockchain. Players can gather resources, build bases, develop technology, collect weapons, and engage in battles with other players to compete for resources.
In Dark Forest, each player controls their own planet and needs to gather resources, build bases, and develop technology to enhance their combat abilities. Players can use resources to construct buildings, research technology, and manufacture weapons in order to gain an advantage in battles.
When players are flying in interstellar space, they need to continuously scout and explore to discover other planets and resources. When two players simultaneously discover the same planet, they can choose to attack the planet or choose to flee. During an attack, players need to use their weapons to attack the opponent's base and seize their resources.
The unique feature of Dark Forest is that the game is completely based on blockchain technology, with each player's planet and resources stored on the blockchain, making it tamper-proof and unable to be deleted. In addition, Dark Forest is a decentralized game (DeGame) without a central server controlling the game process, but rather maintained and decided by all players together.
Dark Forest is also the first game in the fully decentralized gaming industry to introduce a fog of war system, which has been recognized by Vitalik Buterin. In this article, we will delve into how such a real-time strategy game is implemented in a blockchain environment. @DfArchon will occasionally hold "Community Rounds," and interested students can also participate in testing.
Let's start with the game types and compare MMORPG and MMORTS games:
-
MMO-RPG games: Massively Multiplayer Online Role-Playing Games, open world, with no end to the game, and the fun of the game lies in experiencing the immersive story and the game universe. For example, World of Warcraft.
-
MMO-RTS games: Massively Multiplayer Online Real-Time Strategy games, relatively small closed worlds, with a definite end to each round, and the fun of the game lies in multiplayer confrontations within the story background, requiring strategy to obtain resources, develop, and eliminate enemies. Typical examples are StarCraft and Warcraft, with each round lasting 20-40 minutes.
-
DF is an MMORTS game, as it allows a large number of simultaneous participants (up to thousands of players), but due to the limitations of blockchain TPS, each round lasts about 10 days, and the victory or defeat is determined by the ranking based on ladder scores, which mainly come from the resources obtained in the game (freely obtained in PVE and plundered in PVP). During the game pause, users cannot interact with the game contract.
In terms of gameplay, Dark Forest may seem complex, but its basic rules are simple: planets have energy values, which decay with distance. Jumping between planets is an attack on each other, and the outcome of the attack is determined by the size of the energy value after decay. Of course, there are already many articles and videos that explain how to play the game in more detail, so we won't go into further details here.
The developer documentation provides a framework explanation of the game's development architecture, specifically for plugin developers, web client developers, game contract developers, and ZK circuit developers.
The game runs on the xDai layer2, which is the current Gnosis Chain. Since the game requires a lot of interaction with contracts during runtime, it has built-in RPC nodes. The Gnosis team has even opened a dedicated node for this game.
Dark Forest allows players to customize the default web client through a plugin system. Plugins are code snippets that players can write to generate alternative views of game data, automate common game processes, and even redesign game skins. Essentially, Dark Forest allows players to interact with the web client in any way they like through programming.
The key mechanism of Dark Forest is its cryptographic fog of war. When joining the game for the first time, players do not know the locations of other players. Players must calculate hash values to discover points of interest in the universe, such as planets and the positions of other players. These hash values are stored in the browser's local storage and treated as secret data. By default, the Dark Forest web client uses a single-threaded JavaScript miner to explore the universe, but you can take various measures to increase the hash rate, such as changing the CPU core next to the mining button. If you try to set the number of cores to be greater than the actual number of cores on your computer, your mining performance will tend to stabilize.
When a player's miner discovers a region of the universe, the web client saves the information related to these undiscovered regions to the browser's local storage. Dark Forest saves data to IndexedDB. Players can also run a remote server to act as a miner for exploring location maps.
Dark Forest is supported by ZK-Snark technology, which is a cryptographic technology that can be used to prove the correctness of a function without revealing the input or logic of the function. Dark Forest uses this technology to verify the validity of movements in the game without revealing the positions of planets to on-chain observers. This technology (Zk-snark Proof Generation) is computationally expensive! So the ZK-Proof is calculated outside the browser and requires running a Node.JS locally. Of course, the game also allows the use of a remote server to run this service.
In conclusion, as a highly innovative blockchain game, Dark Forest's development has been relatively slow. One possible reason is that it is a community-driven project, which ensures decentralization but also affects development efficiency. The last official round was in February 2022. The web client was last updated in October 2020, and third-party (community) plugins have been slightly more active, including the night market (anonymous trading of planet coordinates) in July 2022 and the lobby in March 2022.